## [Algorithms] Static shadows for terrain (from light's perspective)

 [Algorithms] Static shadows for terrain (from light's perspective) From: O'dell Hicks - 2004-03-23 03:33:01 ``` My terrain has a big 2048x2048 texture mapped across. I generate a shadow map for this texture by placing the camera above the terrain in the center and using an orthographic view to map the whole thing exactly to a rendered texture. Things that cast shadows (like rocks, trees, and bridges) are rendered, darkened, and then multiplied with the main terrain color texture. The result is a nice, statically shadowed terrain. However, this produces shadows based on the camera's position. Being at the center, the shadows are always cast as if the sun were at it's highest point in the horizon. I'd like the same orthographic view that maps to the color texture, but I need someway to transform the geometry as if it were being done from the light's position. If I've been clear enough, does anyone have any suggestions? ```

 [Algorithms] Static shadows for terrain (from light's perspective) From: O'dell Hicks - 2004-03-23 03:33:01 ``` My terrain has a big 2048x2048 texture mapped across. I generate a shadow map for this texture by placing the camera above the terrain in the center and using an orthographic view to map the whole thing exactly to a rendered texture. Things that cast shadows (like rocks, trees, and bridges) are rendered, darkened, and then multiplied with the main terrain color texture. The result is a nice, statically shadowed terrain. However, this produces shadows based on the camera's position. Being at the center, the shadows are always cast as if the sun were at it's highest point in the horizon. I'd like the same orthographic view that maps to the color texture, but I need someway to transform the geometry as if it were being done from the light's position. If I've been clear enough, does anyone have any suggestions? ```
 RE: [Algorithms] Static shadows for terrain (from light's perspective) From: Jon Watte - 2004-03-23 16:57:28 ```We do something very similar for our static shadows, except we have Earth-sized terrain so we slice it into many, smaller textures. You need to skew (shear) the orthographic projection, such that the direction of the orthographic projection is the direction of the sunlight. Skewing it will keep the projection square when it hits your ground shadow texture; rotating won't do that. You skew the matrix by adding skew factors to the other columns of each row. You can likely do this in the projection matrix. The skew factors, assuming sun direction is "0,0,1" in camera space when the sun is at the camera, are something like dx/dz and dy/dz. Note that these go towards infinity when dz goes toward 0; i e, your shadows won't work right if the sun is setting, which is to be expected with this kind of projection. Cheers, / h+ -----Original Message----- From: gdalgorithms-list-admin@... [mailto:gdalgorithms-list-admin@...]On Behalf Of O'dell Hicks Sent: Monday, March 22, 2004 7:35 PM To: gdalgorithms-list@... Subject: [Algorithms] Static shadows for terrain (from light's perspective) My terrain has a big 2048x2048 texture mapped across. I generate a shadow map for this texture by placing the camera above the terrain in the center and using an orthographic view to map the whole thing exactly to a rendered texture. Things that cast shadows (like rocks, trees, and bridges) are rendered, darkened, and then multiplied with the main terrain color texture. The result is a nice, statically shadowed terrain. However, this produces shadows based on the camera's position. Being at the center, the shadows are always cast as if the sun were at it's highest point in the horizon. I'd like the same orthographic view that maps to the color texture, but I need someway to transform the geometry as if it were being done from the light's position. If I've been clear enough, does anyone have any suggestions? ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ GDAlgorithms-list mailing list GDAlgorithms-list@... https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=6188 ```