Hello,
Here it is an implementation of the PSSM algorithm for Panda3D that has been developed for the Estrada Real Digital (ERD) game (a game from UFMG/Brazil university).
Using pssm, it’s possible to render real-time shadow maps on large terrains and with great quality. The algorithm basically splits the view frustum into different parts, so each part has a different shadow map. That way, it’s possible to maintain a good shadow map resolution, even on large scenes. For more details, you can find the paper here: appsrv.cse.cuhk.edu.hk/~fzhang/pssm_project/
PSSM is basically the same as Cascaded Shadow maps (from NVIDIA).
In order to use pssm, all you have to do is:
self.pssm = ParallelSplitShadowMap.ParallelSplitShadowMap(Vec3(0, -1, -1), lightsQuality = [2048, 2048, 1024], pssmBias = 0.8, pushBias = 0.03, lightColor = VBase3(0.125, 0.149, 0.160), lightIntensity = 0.8)
The lightsQuality parameter tells the algorithm how many times you want to split your view frustum, and the quality of each shadow map. Another important parameter is pssmBias, wich is responsable for changing the clip position. You can also change the light color, intensity, etc…
At each frame, you have to call:
self.pssm.update()
The python code handles the lights frustums positions, directions, and the calculations that are needed in order to change the width/height of the Orthographic lens.
The vertex shader is basically the same as the one found in the shadow map sample. The fragment shader, on the other hand, is a bit different, because it’s responsable for choosing what shadow map is going to be used at a particular fragment.
Here is a list of a few commands:
insert/delete: change the ‘sun’ position.
home/end: change the pssmBias.
page up/page down: change the pushBias.
f5: turn off the shader.
f6: view the buffers.
f7: view the different frustum parts (each one has a different color).
I have uploaded two videos to youtube:
http://www.youtube.com/watch?v=wjnELNMC5kA
http://www.youtube.com/watch?v=_z6KKxpvTgo
You can see how good pssm really is. At a certain point, I zoom out to see the whole scene, and the shadow resolution is quite good.
You can also see the impact of the pssmBias change. As I increase its value, the depth of each part also increases, so a shadow map has to cover a larger area (decreasing the shadow quality).
Feel free to criticize. =)
There are a few minor bugs left, but I’m working on them. Oh, and I’m using an ATI video card, but it will probably work on a NVIDIA one.
======
Code:
Roaming Ralpha sample + PSSM:
http://homepages.dcc.ufmg.br/~fmiranda/pssm/Roaming-Ralph-PSSM.rar
(if you want to use the PSSM code, all you need is the PSSM folder)
Edit1: fixed link…
Edit2: Roaming Ralph sample + PSSM
Edit3: Roaming Ralph sample + PSSM, with a better visual quality. There is also a new .bat