Spotlights
Another feature of point lights is that they shine equally in every direction. But it can be fun to break that assumption and have your lights focus on a particular point. The result is a spotlight, like this:
To make this work, assign your light a direction and an angle that describes the beam’s width. Then, any point that falls outside the light’s cone is considered to be in shadow. If you want the beam to have a soft boundary, you can define a second “fade” angle, inside of which the beam blends from full intensity to none.
Implementing Spotlights | |
---|---|
Remember, the dot product of two unit vectors is the same as the cosine of the angle ... |
Get The Ray Tracer Challenge now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.