The main attraction of my project is dynamic shadows using shadow mapping. Originally, this was going to be an indoor scene of a tavern, but I thought that an outdoor scene would show off dynamic shadows better.
Shades of Green
Shades of Green is a jungle scene with dynamic shadows, using a direct light, the sun, as the only light source. Included in the scene are many trees and grasses,
as well as a boiding group of bats. There is also a day/night cycle.
The user can move around the scene with WASD keys and the mouse.
1. Shadow Mapping
Shadow mapping in Shades of Green is done in the modern way, as a two-pass rendering:
The result of using the shadow texture and coordinates to darken fragments in the fragment shader: Shadows!
Included in the complex subject of shadow mapping, is aliasing. Shades of Green has two types of anti-aliasing: Percentage closer filtering and Poisson sampling. Poisson sampling uses an array of 16 pre or algorithmically defined values. For this project, I used pre-defined poisson values.
Above is percentage closer filtering (PCF). If you look hard enough, you can see the texels on the edge of the shadows.
This is actually being used in tandem with a four sample poisson filter (using the first four poisson values). The large projection frame causes the texels to become more noticeable,
so it's generally recommended to keep your projection frames small (create shadow maps for small parts of larger scenes, instead of just once for a large scene)
in order to get better quality shadows. For this project though, I used a large projection frame, because for each light in your scene that
you would like to use to cast shadows, you must do another rendering pass. This way, while the shadow quality is not great, I can only do
two rendering passes instead of three or four.
Above is stratified poisson sampling. Notice the noise this time on the edge of the shadows. This method chooses different samples
for each pixel, thus creating the noise. To use stratified poisson sampling, you pick a random index in your array of 16 poisson values,
instead of only using the first four (like in PCF+poisson). The poisson values you choose will change the noise of your shadow.
Play around with them a bunch and you can get your shadows looking nice!
3. Other Features