diff --git a/examples.c b/examples.c index e972ec1..e1a3799 100644 --- a/examples.c +++ b/examples.c @@ -47,7 +47,7 @@ void exampleSphere( int width, int height, int channels, unsigned char **image) objectList[2] = &obj3; sphere obj4 = (sphere){vec3Add(sphereOrigin, (vec3){1,1,3}), sphereRadius, (RGBA){0.5,1,1,1},0}; objectList[3] = &obj4; - sphere light1 = (sphere){(vec3){2,1,0}, sphereRadius, (RGBA){1,1,1,1},1}; + sphere light1 = (sphere){(vec3){1,2,4.5}, sphereRadius, (RGBA){1,1,1,1},1}; objectList[4] = &light1; int objectCount = 5; diff --git a/raytrace.c b/raytrace.c index 2a2f8cc..1edd7c4 100644 --- a/raytrace.c +++ b/raytrace.c @@ -7,15 +7,17 @@ RGBA raytraceSphere(sphere **objectList, ray *lightray) { RGBA pixel = (RGBA){0,0,0,0}; - const int lightBounces = 2; - sphere **spheresHitList = (sphere **)calloc( (lightBounces + 1),sizeof(sphere*) ); - vec3 *spheresNormalList = (vec3 *)calloc( lightBounces + 1,sizeof(vec3) ); + #define lightBounces 1 + //sphere **spheresHitList = (sphere **)calloc( (lightBounces + 1),sizeof(sphere*) ); + //vec3 *spheresNormalList = (vec3 *)calloc( lightBounces + 1,sizeof(vec3) ); int hitLightIndex = -1; vec3 sphereNormal; int raysPerPixel = 50; ray originalRay = *lightray; for (int k = 0; k < raysPerPixel; k++) { + sphere *spheresHitList[lightBounces + 1] = {0}; + vec3 spheresNormalList[lightBounces + 1] = {0}; *lightray = originalRay; RGBA tempPixel = (RGBA){1,1,1,1}; sphere *nearestSphere = nullptr; @@ -92,8 +94,8 @@ RGBA raytraceSphere(sphere **objectList, ray *lightray) { pixel.a = pixel.a / raysPerPixel; - free(spheresHitList); - free(spheresNormalList); + //free(spheresHitList); + //free(spheresNormalList); return pixel; } \ No newline at end of file diff --git a/test.png b/test.png index 937f825..f4ffba8 100644 Binary files a/test.png and b/test.png differ