Simple Extra Emitter: Spotlight (5 pts)
Implementation
Added files:
spotlight.cpp
A spotlight is a variant of a standard point light that can be used to explicitly highlight some objects.
One can specify two angles to define the illumination of the spotlight: totalWidth
is the maximum angle of illumination, whereas
the smaller falloffStart
defines where the intensity of the spotlight will start to fall off.
While the code structure is similar to the point light, I chose to follow PBRTv3 and let the user specify the intensity instead of the total power.
To evaluate our spotlight, we have to compute the angle between our hit point direction and the spotlight direction.
If we are outside of the cone of illumination we return 0, if we are inside the cone and before the falloff we return intensity
divided
by the squared distance, and in the case that we are inside the falloff zone we linearly interpolate.
Note that PBRTv3 uses a quartic falloff function while Mitsuba uses a linear falloff function.
As I am validating against Mitsuba, I also went with a linear falloff, but added the option to switch to a quadratic falloff (which I prefered over
the quartic falloff).
Importantly, the spotlight can also be oriented, which is achieved by setting the look_at
parameter.
Validation
I validate my implementation by comparing with Mitsuba. First, I varied the falloffStart, then I compared the effect of the look_at position.
Comparison with Mitsuba (totalWidth = 5, falloffStart = 5
)


Comparison with Mitsuba (totalWidth = 14, falloffStart = 5
)


Comparison with Mitsuba (4 spotlights with same origin, different look_at positions)


Different falloff functions
As a little extra, I have added an option to toggle between two falloff functions, namely a linear (like Mitsuba uses) or a quadratic one. The following comparison showcases this difference.

