View Full Version : about the lod of a shadow map

amhood

03-23-2004, 08:09 PM

hi, i've just finished the implementation of the simple two pass algorithm of shadow mapping and i am trying to improve the level of detail, i.e. i don't wanna see the aliased effects when moving the viewpoint closer to the scene, there have already been quite a few ways to achieve this such as adaptive shadow mapping and perspective shadow mapping, anyway, the method i wanna use is to narrow the field of view from the light source during the first pass when the view point moves closer to the scene with viewing angle unchanged, so that the problem of texture undersampling can be prevented to some extent, but i am having a tough time trying to find the relationship between decrement of the field of view of the light and the decrement of the viewpoint-to-scene distance, is there any suggestion you can give me? Thanks so much!

--amhood

jwatte

03-23-2004, 08:57 PM

You could treat this analytically, and construct the intersection of the viewing frustum, and the lighting frustum. This is likely to be an 11-sided polyhedron (10-sided if you treat the camera as a pyramid rather than cut-off pyramid). Then find a shadow map plane and extent which optimally covers this polyhedron.

"optimally" is of course hard. Here's a heuristic:

1) Calculate the center of all the vertices of the polyhedron.

2) Create normal vector from this center towards light position (Pl), call this Nc.

3) Calculate the minimum distance D for each polyhedron point Pp where D = (Pl - Pp) dot Nc.

4) Create a plane that has normal Nc and distance D from the light point. This plane will graze the "closest" polyhedron vertex.

5) Project each Polyhedron point onto this plane.

6) Calculate the covariance body of these points. This will be an ellipse. Use this ellipse to orient width/height of your shadow map. Place the shadow map near plane in this plane; far plane at the furthest vertex distance.

This approach runs into trouble if you have omni lights, rather than directional or spot/projector lights; it also runs into trouble if the light position is inside the viewing frustum. Both of these can be worked around.

Note that re-calculating the shadow map projection each frame will cause creepy-crawlies along the map edge; you might want to snap the map to some quantized grid to avoid this.

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.