Shadow mapping, part 6


I had some problems on other levels, everything was pitch black… after trying to correct that for a few hours I finally decided to clean up everything… and the problem disappeared, I guess there was something bad happening in my code 🙂

Here’s a video of the start of the second level of Alien Blitz


Combining old & new

And now for some new tests I wanted to try to combine the old render and the new one, basically I will first render exactly as before, and add shadows on top of it (removing the new lights calculation, just using shadows). So wall shadows will be rendered twice (old + new).

Old / old + new :

capture_2014-12-19_21-03-16_0815_Alien_Blitz_ capture_2014-12-19_21-02-34_0526_Alien_Blitz_

Just re-rendering second level :


So basically it’s the same as before except there are more shadows and they are more accurate. The down side is that everything is a bit darker, but not as much as I was expecting.



In previous videos/screenshots I was using a 1024px depth map, so there was not that much aliasing, but I think for performance reasons the quality should be selectable. But at lower resolutions aliasing appear.

256 / 512 / 1024 px depth maps :

capture_2014-12-20_12-26-00_0432_Alien_Blitz_ capture_2014-12-20_12-26-17_0173_Alien_Blitz_ capture_2014-12-20_12-26-38_0822_Alien_Blitz_

(Aliasing is not very visible on the thumbnails)

This test case is probably the worst that could happen, the light is just a little higher than ground a few meters away. I tried various PCF techniques (adapted to cube maps) but nothing really worked. One possible way to solve this could be to use a bigger viewport for shadow frame buffer.

512px depth map, x1 viewport / x2 viewport :

capture_2014-12-20_12-32-15_0487_Alien_Blitz_ capture_2014-12-20_12-32-31_0972_Alien_Blitz_

Using a x2 viewport makes small artifacts blend, this is indeed nicer, I couldn’t see a difference with x4 so it’s not included

I also tried mixing PCF in the different processing steps, but got nothing really good.

So I think I will stick to something like :

  • No shadows : same as current
  • Low quality : 256px depth map, x1 viewport
  • Medium quality (default) : 512px depth map, x2 viewport
  • High quality : 1024px depth map, x2 viewport

And I might change some levels to avoid problems in low quality (for example adding a small wall around the path might help in above case)

Updated video, with new render & medium quality shadows



I had some problems on Android, textures were not read properly, nothing was working. The problem was quite stupid, it’s just that I wasn’t binding my textures correctly, I guess it worked on desktop because MAX_TEXTURES might be higher.

Now shadow mapping seems to work exactly the same on my Nexus 7 as on PC, but still nothing on my Nexus 10 (black screen, empty depth map, empty shadow buffer), still needs some debugging.
Anyway it’s way too slow to do anything (even with caching), but I just want to make sure I can get it to work in case I do a tutorial later.

Comments are closed.