alecjacobson / computer-graphics-ray-casting

Computer Graphics Assignment about Ray Casting
30 stars 28 forks source link

Correct output for sphere-and-plane and two-spheres-and-plane but no spheres on sphere-packing #28

Open nativia002 opened 2 years ago

nativia002 commented 2 years ago

On sphere-packing, my ppm output is just the background colour. So all red for id, all dark gray for depth and the light lilac colour for normal. ex. image

But my sphere-and-plane and my two-spheres-and-plane look exactly like the photos provided. I'm not sure if my inside-sphere is correct as there were no inside-sphere photos to reference but this is what I'm getting for the inside image

If I remove the plane from the json file, then I just get an all black ppm image.

Bunny and triangle are working fine as well, so I'm assuming that it might be a problem with the Sphere file, but if so, why are the other sphere images working fine?

Update: I tried adding a sphere to the two-spheres-and-plane json file to see if it was a problem with overlapping spheres but it rendered fine as well? I'm really not sure why sphere-packing is not showing anything except for the background image

haoda-li commented 2 years ago

If you check the json file, you will find that the camera for sphere-packing is not the standard basis. You need to check your viewing rays and verify whether they correctly use the camera's information.

For inside-a-sphere, note that there are 2 intersections. One of the intersection is smaller than min_t, but the other one is greater than min_t. You have to take the other intersection.