Game Development Community

Strange behaviour of PSSM shadows drawcalls & polycount

by Oscar Velzi · in Torque 3D Professional · 06/01/2010 (1:01 pm) · 1 replies

I'm having some trouble in discerning the logic behind the rendering of the PSSM shadows. I'm working on an isometric game, which means that the camera is not the player character. From almost all positions, the PSSM shadows drawcalls are a constant, as if the whole level shadows are rendered all the time, despite they are on screen or not. Let me show you some screenshots:

In the first screen the whole level is rendered, and the shadow count of drawcalls is 304.

img686.imageshack.us/img686/7659/screenshot04000000.jpg
Now we have a shot completely zoomed in, where not many shadows are rendered, and the drawcalls are 316. This shot is taken near the left side of the level.

img695.imageshack.us/img695/526/screenshot04000001.jpg
And even with the shadows not being rendered (you can see that the rendering is cut from the middle part upward since I used a different shadow distance value), the drawcalls, polycount and performance stay the same.

img693.imageshack.us/img693/909/screenshot04200001.jpg
BUT if we go to the upper right corner of the level, closer to position of the sun, the drawcalls are 23.

img704.imageshack.us/img704/563/screenshot04000002.jpg
Can someone knowledgeable explain to me why it works this way? I've come to accept the shadows drawcalls as a constant no matter what I'm looking in the level, but it would be nice if there's a way to make it relative to what is being rendered on the screen.

BTW, we've devised a way to have really high quality looking shadows with very little performance hit. Those shadows you see in the screenshots are using just 2 split passes. It only works with isometric games, though. If you want to know how we did it, I can post a thread about it.

#1
06/01/2010 (2:01 pm)
Simple: the shadows don't draw the entire scene. Each PSSM split calculates a bounding box around the camera position based on max shadow distance and some internal logic to encompass possible shadow casters, and builds a shadow frustum that encompasses that box. So it's only logical that in your map outer limits you have less objects being drawn into the shadows.

Since your game uses a top-down camera, you can both boost your shadow quality *and* reduce the number of draw calls by reducing the shadow caster box in LightShadowMap::calcLightMatrices():

// Calculate the bonding box of the shadowed area 
         // we're interested in... this is the shadow box 
         // transformed by the frustum transform.
         Box3F viewBB( -p->shadowDistance, -p->shadowDistance, -p->shadowDistance,
                        p->shadowDistance, p->shadowDistance, p->shadowDistance );
Scale that box down by some constant and you're set. A very good optimization is to clamp the box height to the height of the highest building/mountain in your level (or the maximum height at which you have flying shadow casters).