Question

I have two light sources, three spheres and two triangles. Spheres placed on two triangles. I alrady did intersectSphere and computeColorSphere functions. I somehow started implementing intersectTriangle and computeColorTriangle functions. How should it be different from Sphere functions ? and how can i implement shadows of spheres on triangles plane ?enter image description here

Was it helpful?

Solution

Computing cast shadows is done as follows: when you hit a surface with a ray and apply the illumination model there, you add the contribution of all light sources (like you did); but you need to check if there is no obstacle to the light sources by casting secondary rays from the hit point to the sources. If you find an obstacle, just ignore the contribution for this source.

Very similarly, you can implement reflections by casting a secondary ray in the reflected direction (incidence angle = reflection angle) and seeing if you hit another surface.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top