diff --git a/examples.c b/examples.c index 586f51d..94d67fa 100644 --- a/examples.c +++ b/examples.c @@ -45,8 +45,8 @@ void exampleSphere(int height, int width, int channels, unsigned char *image) { vec3 screenMiddlePoint = vec3Add(cam1.origin, vec3Scale(cam1.direction, cam1.screenDistance)); vec3 screenTopLeft = vec3Add( vec3Add(screenMiddlePoint, - vec3Scale(screenY, cam1.height)), - vec3Scale(screenX, cam1.width) + vec3Scale(screenY, -cam1.height/2.0)), + vec3Scale(screenX, -cam1.width/2.0) ); double pixelStepX = cam1.width / cam1.resolutionX; double pixelStepY = cam1.height / cam1.resolutionY; @@ -69,7 +69,7 @@ void exampleSphere(int height, int width, int channels, unsigned char *image) { ray *lightRay = (ray *)malloc(sizeof(ray));; lightRay->origin = cam1.origin; - lightRay->direction = vec3Subtract(*pixelOrigin, cam1.origin); + lightRay->direction = vec3Normalize(vec3Subtract(*pixelOrigin, cam1.origin)); pixelColor = raytraceSphere(&obj, lightRay); free(pixelOrigin); diff --git a/test.png b/test.png index 0bb731f..ee59d03 100644 Binary files a/test.png and b/test.png differ