karansher / computer-graphics-ray-tracing

Computer Graphics Assignment about Ray Tracing
0 stars 0 forks source link

bunny output looks dark/grey #31

Open yuetsai93 opened 2 years ago

yuetsai93 commented 2 years ago

My bunny output looks dark and grey. Any idea on what might be wrong here? I see other people mentioning normalization problem, but I think my vectors are properly normalized and all my other outputs look fine.

Screen Shot 2022-10-03 at 21 22 43
eon704 commented 2 years ago

I had a similar issue. I am not 100% sure you are encountering the same, but for me the problem was in the shadows. Basically almost all points in the scene thought they are in the shadow - hence the dark color. When checking for the shadows, ensuring that the hit object is between the point and the light source has fixed it for me.

Hope this helps!

yuetsai93 commented 2 years ago

I had a similar issue. I am not 100% sure you are encountering the same, but for me the problem was in the shadows. Basically almost all points in the scene thought they are in the shadow - hence the dark color. When checking for the shadows, ensuring that the hit object is between the point and the light source has fixed it for me.

Hope this helps!

@eon704 Thanks for the suggestion! Just want to confirm: by 'hit object is between the point and the light source', do you mean checking if the t produced by first_hit is less than max_t? i.e. only calculating lambertian and specular shading when not first_hit and having a larger t

eon704 commented 2 years ago

We need to check whether or not a pixel point in the scene is in the shadow, to do that we shoot a "shadow ray" to each of the light source in the scene, right?

If shadow ray hits something, we skip adding any diffuse or specular colors to the pixel.

What I meant is we need to check what exactly did the shadow ray hit and if this hit is between the pixel point and the light source. Because it is possible that the shadow ray hit something past the light source, in which case there is no shadow.

Hope this makes more sense 😅