Shadow map code for ATI


I have several hardware shadow map code which work on nVidia, but I would like to write one for the ATI card, without fragment program.

I currently use a rectangular depth pbuffer to capture the shadow maps and then I use the nvidia’s texture shader extensions to perform the shadow mapping.

And I have actually no idea about how to do something similar that works for ATI cards. Especially for the depth pbuffer.

So if anyone have some links to a tutorial about that, it would be great.

ATI hardware has no native support for shadow maps like nvidia does, that is, no depth textures and no free bilinear-PCF. The easiest way to get things to work reliably is probably to use the ARB_shadow extension which abstracts away the details and is implemented by ATI.

If you need more control you need to implement a different path on ATI where you render depth either encoded into a regular RGB(A) texture or into a single channel floating point texture and do the decoding and comparison in the fragment shader manually. IF you need PCF you’ll have to it yourself in the shader which can get pretty expensive.

Instead of using a rectangular depth pbuffer and bind it as a texture, I’ll just use a rectangular pbuffer, render the scene from the light position into it and then copy the z-buffer of the pbuffer to a rectangular texture of GL_DEPTH_COMPONENT format. It will slow down the render loop but … I am using a nVidia so…