[GeeXLab] Shadow Mapping and Large Depth Map on Radeon HD 5770

While updating GPU Caps Viewer (available very soon), I saw the max texture size for Radeon HD 5770 (and HD 5870 as well) is 16k or 16384×16384. I said wow! In the previous generation of Radeon and in current GeForce, the max texture size is 8k (8192×8192). With such a big resolution, I decided to see how this will impact the shadow mapping by using largest possible depth map.

I coded a small demo with a textured ground, a textured torus, a light and, of course, the shadow mapping enabled. You can download the demo here:

As usual to run the demo you need the latest version of GeeXLab, and for this demo it’s the version 0.1.13. If you don’t have Python, just download GeeXLab NO PYTHON.

Unzip the demo anywhere and drop ShadowMappingTest.xml in GeeXLab.

I did two kind of tests: the first one with the light near (x=0.0 y=150.0 z=50.0) the torus and the second one with the light further (x=0.0 y=500.0 z=200.0). The light position does not impact the FPS but impacts the visual aspect of the shadow due to depth map resolution.

In the first test, the depth map size varies from 128×128 to the possible max size with a 16-bit resolution (OpenGL format = GL_DEPTH_COMPONENT16). When the light is near the object, a 16-bit depth map is enough. In the second test, the light is far from the object and a 32-bit depth map (OpenGL format = GL_DEPTH_COMPONENT32) is required. The filtering type (LINEAR or NONE) of the depth map does not change the FPS. I did the test with no filtering in order to visualize the depth map precision.

Linear depth map look up is actually the PCF (Percentage Closer Filtering) algorithm with 4 samples (equivalent to 4 texture fetches). GeForce and Radeon cards have a built-in PCF depth map look-up and this look-up is free. Linear depth map look up is called fetch4 on Radeon. I’ll discuss about depth map filtering in another post.

Here are the results of this first test :

– Demo settings: 800×600 windowed, no AA.

16-bit depth-map

128×128: 830 FPS

256×256: 830 FPS

512×512: 830 FPS

1024×1024: 830 FPS – depth map size: 2MB

2048×2048: 830 FPS – depth map size: 8MB

4096×4096: 830 FPS – depth map size: 32MB

8192×8192: 300 FPS – depth map size: 128MB

10000×10000: 260 FPS – depth map size: 190MB

12000×12000: 270 FPS – depth map size: 274MB

14000×14000: 350 FPS – depth map size: 373MB

15350×15350: 380 FPS – depth map size: 449MB

In this first test, 15350×15350 seems to be the max size of the depth map. Up to 4k, the FPS is constant (830) and drops to 300 for a 8k depth map. Oddly for larger depth map the FPS goes up again. The Radeon HD 5770 supports NPOT (non power of two) textures that’s why we end up with a size like 15350.

Let’s see the results of the second test:

– Demo settings: 800×600 windowed, no AA.

32-bit depth-map

512×512: 820 FPS

1024×1024: 820 FPS – depth map size: 4MB

2048×2048: 820 FPS – depth map size: 16MB

4096×4096: 690 FPS – depth map size: 24MB

8192×8192: 230 FPS – depth map size: 256MB

14015×14015: 220 FPS – depth map size: 749MB

Ouch! 749MB for the largest depth map. With 1GB of graphics memory, such a depth map is useless (except in this test ). As for 16-bit depth map, there is a FPS collapse with 8k+ depth map (maybe a 2GB video card could improve a bit the situation…).

Here are the screenshots with the light close to the torus (16-bit depth map):

128×128 depth map

256×256 depth map

512×512 depth map

1024×1024 depth map

2048×2048 depth map

4096×4096 depth map

8192×8192 depth map

12000×12000 depth map

15350×15350 depth map

Under 128×128, the depth map resolution is too low and no shadow is rendered.

Now the screenshots with the light far from the torus (32-bit shadow map):

512×512 depth map

1024×1024 depth map

2048×2048 depth map

4096×4096 depth map

8k x 8k depth map

14015×14015 depth map

14020×14020 depth map – it’s too much!

Under 512×512, the depth map resolution is too low and no shadow is rendered.

As you see, high resolution depth maps are graphics memory ogres and FPS killers that ‘s why usually low resolution depth maps are used in games. Low resolution depth maps combined with some algorithms like cascaded shadow maps (CSM) make it possible to shadow large areas where light is far from objects.