Point light dynamic shadows
Download demo .exe and source
Features:
- Add colored point lights (shines in all directions unlike single directional lights)
- Objects will cast realistic shadows, the darkness of shadows can be changed
- Shadows are updated in real time
- The code supports any number of lights, without taking up more RAM
Issues:
Speed. A majority of the code is done in the fragment shaders and thus the FPS drops drastically when jumping from 3 to 4 lights (or earlier depending on your computer). The number of triangles on-screen also affects this, as the scene has to be redrawn 7 times per light + 1.
Artifacts/"shadow acne". All the papers I've found about this suggests using a fixed "bias" when comparing floating point values to avoid artifacts, but there doesn't seem to be a perfect balance. A higher bias (currently at 0.02) removes the acne, but objects will start to "hover".
As much as I'd love to increase the smoothness of the shadows, it too greatly contributes to this problem (amount of samples & sample distance).
Left: The table appears to be floating (it's at Z=0), and artifacts can be seen on the ceiling.
Right: Weird patters on the wall when a light is close to it.
Edited by Davve, 11 December 2015 - 09:56 PM.