diff --git a/raytrace.c b/raytrace.c index 179e1a5..2a2f8cc 100644 --- a/raytrace.c +++ b/raytrace.c @@ -7,14 +7,16 @@ RGBA raytraceSphere(sphere **objectList, ray *lightray) { RGBA pixel = (RGBA){0,0,0,0}; - const int lightBounces = 5; + const int lightBounces = 2; sphere **spheresHitList = (sphere **)calloc( (lightBounces + 1),sizeof(sphere*) ); vec3 *spheresNormalList = (vec3 *)calloc( lightBounces + 1,sizeof(vec3) ); int hitLightIndex = -1; vec3 sphereNormal; - int raysPerPixel = 1; + int raysPerPixel = 50; + ray originalRay = *lightray; for (int k = 0; k < raysPerPixel; k++) { + *lightray = originalRay; RGBA tempPixel = (RGBA){1,1,1,1}; sphere *nearestSphere = nullptr; vec3 nearestCollisionPoint = {10000,10000,10000}; @@ -62,7 +64,11 @@ RGBA raytraceSphere(sphere **objectList, ray *lightray) { tempPixel = (RGBA){0,0,0,1}; } else - { pixel = spheresHitList[firstLightHitIndex]->color; + { + pixel.r += spheresHitList[firstLightHitIndex]->color.r; + pixel.g += spheresHitList[firstLightHitIndex]->color.g; + pixel.b += spheresHitList[firstLightHitIndex]->color.b; + pixel.a += spheresHitList[firstLightHitIndex]->color.a; for (int i = firstLightHitIndex - 1; i >= 0; i--) { tempPixel.r = tempPixel.r * spheresHitList[i]->color.r; tempPixel.g = tempPixel.g * spheresHitList[i]->color.g; diff --git a/test.png b/test.png index f94983b..937f825 100644 Binary files a/test.png and b/test.png differ