Feature: Simple Extra Emitters

This light-emitter I have already implemented in the assignment 1. Therefore I simple copied the text from there.

To be able to perform the calculations for the spotlight, more parameters can be set in the xml-file. Namely the direction, the total-width angle and the falloff-angle. The parameters are defined as in the book (see picture "Figure 12.4 for illustrations).

direction
Vector3f for the direction in which the spot shines.
totalWidth
Float to store the degree of the light (this is for one side, so in fact the complete cone will be the double of the angle set here)
falloffStart
Float to store the degree of the light where it sines fully (this is for one side, so in fact the complete cone will be the double of the angle set here)

The biggest problem I faced was to calculate the correct angle between the light-ray and the given direction of the spotlight. Even thought it is easy to achieve with the functionality provided by the framework and math-library, I mixed up between the units, resulting in funny illumination-models.

Another learning I had to make on the hard way was to not reuse the same intersection-object for recursive rays as from the primary-ray. This resulted in wrong intersection-calculations for more than one light-source. Even though the effect looked quite fascinating, I do not think that it could have any useful application. (see comparisons below.)

Below I have some renderings with different light settings. (I don't have a scene-file for each rendering, basically I just commented some lights out or changed the angles accordingly).

External libraries:
No further libraries than nori-framework has been used to complete this task.
Time spent:
3:00 (approximately)
Acknowledgements:
  • Physically Based Rendering 2010 - Chapter 12.2.1
Files:
  • include/nori/spotlight.h (new)
  • src/spotlight.cpp (new)
  • include/nori/emitter.h (updated / restructured polymorphism)
  • include/nori/pointlight.h (updated / restructured polymorphism)
  • src/pointlight.cpp (updated / restructured polymorphism)
  • src/direct.cpp (updated)
  • scenes/mine/cube-spot.xml
  • scenes/mine/sponza-spot.xml

Spotlight Comparison: Overriding intersection from primary-ray with found intersections from secondary ray

Overriding

Spotlight Comparison: Different totalWidth-angle

70 degree 45 degree

Spotlight Comparison: Sharp (totalWidth = falloffStart) vs smooth (totalWidth > falloffStart)

Sharp Smooth

Spotlight/Pointlight Comparison: Different ambiance

Pointlight Spotlight

Spotlight/Pointlight Comparison: Colors

Pointlight Spotlight
Pointlight Spotlight
Pointlight Spotlight