PDA

View Full Version : Best method to Shadow large terrains



Mars_999
04-23-2006, 05:46 PM
As of now I am using the basic shadowmapping technique, and this worked fine for my smaller terrain meshes. Now with 1025x1025 size meshes this no longer working for me. So any ideas on how I can improve my current shadow mapping or maybe a different method that isn't to complex would be great. Thanks

RigidBody
04-24-2006, 03:15 AM
do you filter the shadow texture?

Obli
04-24-2006, 03:16 AM
You should at least mention your terrain rendering method... If you're brute-forcing a 1Mvert mesh, no doubt you're getting sub-optimal performance.

Groovounet
04-24-2006, 05:31 AM
I really think that shadow volumes are best for terrain rendering. However, they are really great for objects shadows on the terrain but for self terrain shadow you could have some problem due to terrain culling. Shadow volumes like closed meshes.

zeoverlord
04-24-2006, 07:22 AM
Originally posted by Groovounet:
I really think that shadow volumes are best for terrain rendering. However, they are really great for objects shadows on the terrain but for self terrain shadow you could have some problem due to terrain culling. That is not what kills a 1024*1023 mesh, it's the shear number of polygons.
If you want dynamic shadows on terrain then Depthshadows is the way to go.

But as i understand the OP is that on such a large mesh a texture has to be absolutly enormous to look as good as a small mesh, and the simple anver is, split the large mesh into several small ones with separate lightmap textures on each of them.
Just make shure that the ends meet up ok.


Originally posted by Groovounet:
Shadow volumes like closed meshes. It depends on the method you use, my method couldn't care less, the only restriction i have is that at most 2 polygons can share one edge, not more, but i guess everybody has that problem.

Mars_999
04-24-2006, 12:08 PM
I am using a patching system to do my rendering now, i have a 1025x1025 mesh patched to 33x33 and frustum culled to break down the amount of polygons, at most I have about 200k on the screen at once. zeoverlored how do I go about that, I mean the shadow is rendered from the lights position won't I have to move my light around and won't that make the lighting look wrong? Thanks

zeoverlord
04-25-2006, 02:51 AM
No the light can stay where it belongs as long as it is in the right relative position to the patch.
However on large terrains it would be better to have directional lighting instead of omnidirectional lighting like pointlights.
A quick fix is to move the lightsource to a position that is far far away.
About the other stuff, i can't help you much there, it's one of those things you have to do for yourself.

Mars_999
04-25-2006, 09:16 AM
Well its supposed to be directional because its the sun... I am assuming by moving the light to a place far far away I will be able to move the light position back far enough to get the whole terrain in the light frustum?

zeoverlord
04-25-2006, 10:06 AM
You don't have to have the whole terrain in the frustum, just the bit you can see, then just move the light as you move, and if you have a directional lightsource it will not look that bad as you move.
(though you might want to move the light in steps and not directly acording to the camera position).

Mars_999
04-25-2006, 02:42 PM
Originally posted by RigidBody:
do you filter the shadow texture? Yes, I have a 7800GT and am using GL_LINEAR with FBO's so I should be using NVIDIA's PCF method to have a softer shadow, but the issue is getting the whole terrain into the frustum.

k_szczech
04-25-2006, 05:26 PM
If your light source does not move (daytime does not change) then use precompiled lightmap(s).

If that's not enough, then using stencil shadows may be a good idea - you can combine stencil shadows (terrain) with shadowmaps (small objects nearby).

If for some reason you do not want to use sencil shadows, then create large (for example 2048x2048) depth texture and render 4 views covering (for example) 50x50m, 200x200m, 800x800m and 3200x3200m. You can switch between these 4 depth texture fragments on per-polygon basis or on per-pixel basis (using pixel shders of course). Note than rendering quarters covering 800x800m and 3200x3200m you can skip drawing small objects to gain some performance and avoid flickering.

Mars_999
04-25-2006, 05:41 PM
Originally posted by k_szczech:
If your light source does not move (daytime does not change) then use precompiled lightmap(s).

If that's not enough, then using stencil shadows may be a good idea - you can combine stencil shadows (terrain) with shadowmaps (small objects nearby).

If for some reason you do not want to use sencil shadows, then create large (for example 2048x2048) depth texture and render 4 views covering (for example) 50x50m, 200x200m, 800x800m and 3200x3200m. You can switch between these 4 depth texture fragments on per-polygon basis or on per-pixel basis (using pixel shders of course). Note than rendering quarters covering 800x800m and 3200x3200m you can skip drawing small objects to gain some performance and avoid flickering. I am using a lightmap already to do my self shadowing of the terrain onto itself, but the issue is with my units on the terrain where my frustum isn't larger enough to capture the whole terrain size 1025x1025. I run out of shadowing on the sides of the projection far plane is fine but my near plane apparently cuts off my one side of my terrain and will not cover the one side completely... Not sure if this makes sense, but I posted in a new thread to get some info on how to extract the frustum info so I can draw a cube from the light POV so I can see what is going on with the projection. Also my light source is static it will not move. Thanks

k_szczech
04-26-2006, 03:19 AM
I just got one idea:
1. Create alternative terrain geometry - copy the original geometry, and raise these vertices that are in shadow, so they would be on the edge of shadow.
2. Now create static top-down 1024x1024 shadowmap based on that alternative geometry. It will in fact be a heightmap, but instead of terrain height it will represend shadow height.

This way you have a static shadowmap covering entire map.
When drawing objects compare fragment's y coordinates to that shadowmap (assuming y points up).

Instead of using shadowmap you can use that alternative geometry 'as is' to create stencil shadows.

For small objects you still need a shadowmap from light source's point of view.

Hope, you find this solution interesting enough to be worth reading ;)

Mars_999
04-27-2006, 10:25 AM
Originally posted by k_szczech:
I just got one idea:
1. Create alternative terrain geometry - copy the original geometry, and raise these vertices that are in shadow, so they would be on the edge of shadow.
2. Now create static top-down 1024x1024 shadowmap based on that alternative geometry. It will in fact be a heightmap, but instead of terrain height it will represend shadow height.

This way you have a static shadowmap covering entire map.
When drawing objects compare fragment's y coordinates to that shadowmap (assuming y points up).

Instead of using shadowmap you can use that alternative geometry 'as is' to create stencil shadows.

For small objects you still need a shadowmap from light source's point of view.

Hope, you find this solution interesting enough to be worth reading ;) It sounds like a good idea. I will keep it in mind if I can't get my current method to work. I wasn't planning on changing my shadowing method, but may have to.