tsoding / ray-tracer

My ongoing effort to learn how to make Ray Tracers
MIT License
15 stars 2 forks source link

Shadows! #33

Open w23 opened 6 years ago

rexim commented 6 years ago

@w23 do shadows require anything special to implement? I thought they gonna naturally emerge from the ray tracing itself. Like if a ray never hits an area it's just black. Please correct me if I'm wrong.

w23 commented 6 years ago

They kind of appear naturally in path-tracing. For other methods, however, where you're stuck with enumerating all light sources to account for each light influence, you do need to check that the light is not obstructed. That usually involves casting a ray into each light's direction and checking whether it has hit anything opaque or not. As it is basically a boolean yes/no check, this will give you hard shadows. There are various ways to approximate soft shadows, but that will come later.