Shadow mapping, part 5

Correcting far

The problem I had previously on the far was because of the pack/unpack functions I was using to store depth data on all the rgba values, now I will just use an alpha texture for lights depth map. So I will loose precision, but in a third person view it doesn’t really matter.

capture_2014-12-19_13-27-04_0323_Alien_Blitz_

All far values work now

 

Correcting multiple lights

My problem with multiple lights was just a small bug in my multi render pass, no idea why it was working on my nvidia card and not on my intel card.

The shadow map :

screenshot200

The render :

capture_2014-12-19_13-38-21_0142_Alien_Blitz_

Of course as there are lots of lights there’s not so much shadows.

 

Colored lights

Adding basic colors is pretty straight forward from here, the shadows & render :

screenshot212 capture_2014-12-19_14-00-28_0090_Alien_Blitz_

Comparing to the current render :

capture_2014-12-14_15-53-51_0733_Alien_Blitz_

There’s still some work to do to get a similar result, mainly because in the current solution I do a lot of smoothing. But the advantage of shadow mapping is that even sprites have a shadow…

After just a few modifications, and trying to smooth a bit (2nd image)

capture_2014-12-19_16-04-50_0762_Alien_Blitz_ capture_2014-12-19_16-05-05_0799_Alien_Blitz_

It doesn’t change that much :)

 

Tests on PC

I ran 2 tests on different configurations and checked the FPS, using the sample level (7 lights)

Tests :

  1. Render everything every frame
  2. Cache depth map, render shadow map, blend shadow map

Results (first number is test 1, second is test 2) :

  • Recent laptop, Integrated Intel card : 26/60
  • Recent laptop, Nvidia card : 53/60
  • Old computer (6 years old), Nvidia card : 60/60

I’m surprised my old computer has such a good result, but even in some recent games it performs better than my laptop (Borderlands Pre Sequel for example), but it can’t render all the effects on these games (old graphical card)

In the first test the depth map is computed each frame, I didn’t try to optimize anything (my shaders are certainly full of bottlenecks), in a final version it should cache the depth map and re-render it only if something is moving in its range. So it would save A LOT of time, I think it will always render at 60fps on these configurations with proper optimizations and caching.

Sadly my netbook is broken, it needs a new memory kit, so I can’t test on it.

 

Futur

I prefer the old rendering, maybe I could do a mix between old and new, to get dynamic shadows but keep the light colors.

I don’t know yet if it will be included on PC version, I will continue working on it for now, and we will see.

 

Tutorial

I think I’ll try to do a clean tutorial with all I learned, basically it will cover

  • Point lights and directional lights
  • Cubemap frame buffers
  • Multiple lights
  • Multi pass rendering (forward rendering)
  • Everything using Libgdx, and Android/iOs/PC compatible

It will not cover caching of lights, everything will be rendered each frame. Because this is a very specific work that depends on your game engine.

The problem I have is I’m pretty sure there are better ways to do it, but at least it works 😉

Comments are closed.