PDA

View Full Version : Shadow mapping and cubemap



capedica
06-04-2005, 12:38 AM
Hi,
i've finally realized shadow mapping via shaders, now i have a cone of light that makes shadow (a directional light), what if i want to realized omni light? Is it correct this solution?
- i take 6 depth texture rotating camera of 90 degrees every time;
- i build a cubemap;
- in my shader i do something similiar to directional light but using a cubemap as shadow texture.

Is this method correct? is it normally used in real time application like games, because taking 6 texture reduce very much framerate? or is there a trick?
Thank you

capedica
06-05-2005, 11:16 PM
please,even yes or not, on web i didn't find any information...

Chuck0
06-05-2005, 11:52 PM
well the main problem is that the normal shadowmapping (i.e. using depth maps and the shadow mapping extension) does not work for cube maps. the only workaround to this is either using normal rgba textures and using a fragment program that packs the light distance into it or utilizing a float cubemap to do this. naturally you will have to do the distance comparison in a fragment program as well when rendering the shadowed geometry.

if by implementing shadowmapping with shaders you mean that you already use non depth map shadowmaps then yes you can do nearly exactely the same with a cube map (only difference being that the coordinate lookup is easier to compute because you wont need a perspective light transformation matrix anymore).

if this approach is really fast enough for game scenarios i dont know since, as you stated, rendering the scene 6 times for one light is quite expensive, even though by using view frustum culling for all the faces the cost of this can be reduced greatly. btw i wrote a little demo that can be downloaded here (http://http://stud3.tuwien.ac.at/~e0125958/shadowmapping.zip)
which demonstrates the speed of this approach when using a floatingpoint cubemap and absolutely no optimisations rendering a (i think) approximately 40000 polygon scene (tested on r3xx hw... wont work on nv3x hw since no float cubemap pbuffer support).