Jump to content
  • Advertisement
Sign in to follow this  
DoomAngel

casting Object's Shadowmap on terrain

This topic is 3632 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all.. I'm working on the shadowMap in my engine, the objects cast shadows each on other in a good performance and quality, but I have a problem in casting these shadows on terrain, cuz I have no idea how I can determine the area of the terrain which will be affeced by the shadow which is casted by an object. My terrain is patch based (i.e it's devided in to equal squared patches). thanks for your attention.

Share this post


Link to post
Share on other sites
Advertisement
As far as I know you don't handle the object's shadows seperately.
You just render the whole light's view frustum. In your case (I guess you're talking about sun light?) this would mean rendering the WHOLE terrain.

Optimizations would be reducing the rendering to the area visible by the user and using cascaded shadow maps to get higher shadow quality...

Share this post


Link to post
Share on other sites
no.I handle the object's shadow separetly..
and so I can do the shadow map not just for the sun light but..for any other light.
I calculate the shadow map for each objects, and then I do some math stuff to determine the objects affected by this shadow (I use the bounding aabb cast volume to determine which objects are affected by the shadow map.)

so there are no problem in casting shadow maps between objects, but the problem is in determining the terrain mesh area which is affected by the object's shadow map (for each object).

Share this post


Link to post
Share on other sites
If you can use every objects BB to create a shadow volume and determine the objects affected by this objects shadow, why can't you just do the same thing with every terrain patch?

For the sun you will have to render the hole visible terrain, and this will also work for every other light source (even if its a brute force approach).

But I don't see any sense in handling objects and terrains seperately. Are you really rendering a different shadowmap for every object?

[Edited by - DraganO on January 18, 2009 1:23:35 PM]

Share this post


Link to post
Share on other sites
okay..I think that there is some mis understanding..
let's ask the quistion in a diffrent way..
how can I do intersection between frustom and terrain.
the frustom is casted from the light source and on the aabb.

I hope my quistion is clear now..

Share this post


Link to post
Share on other sites
Just put a bounding box around every terrain patch and do it the same way you do when checking an objects bb.

Share this post


Link to post
Share on other sites
I too don't see why objects and terrain should be treated separately. Actually, if you think about there's a lot of common behavior which you can safely factor out. For one thing, rendering objects (including terrain) from light's point of view is pretty much the same as rendering them from the point of view of the camera. In both cases, a visible set is first calculated. For each object inside this visible set appropriate pipeline states are set and a draw call is issued afterwards. The point is that you can use whatever culling algorithm you already use for rendering terrain patches from camera's point of view, to cull objects and terrain patches in the shadow map generation pass. Put another way, this problem is not strictly related to shadowing. It's a general VSD problem. You're looking for an answer in the wrong place. So to sum it up, you roughly need to follow these steps:

For each light: {
- Send a query to your scene database and ask for all objects that intersect light's view frustum. For instance, if you're using quadtrees to accelerate queries, your database would take advantage of it and return a list of objects AND terrain patches that intersect the light's view frustum.
- Render these objects to shadow map
}

- Send a query to your scene database and ask for all objects that intersect camera's view frustum.
- Render all visible objects using the generated shadow maps in the previous step.

There's of course a lot of room for optimizations. For instance, you can cull those lights that don't cast shadows into the scene to gain a healthy speedup by skipping the shadow generation pass.

Share this post


Link to post
Share on other sites
okay..Thanks Ashkan, but read the following:
first of all..plz help me with intersection between terrain and frustom.
secondly: for doing the shadowmap rendering I do the following:
for each light affect the scene
Objects = Get all objects Affected by this light.
for( each object)
generate the shadow map (I render it from the light view point.)
now for each visible object affected by shadowmap casted by another one
render the shadow map using this shadow map.

I don't do update all the shadow map in each frame..and there are many improvments of this algo..
so, I think It's a good way to render each objects shadow map separetly..

quote<Just put a bounding box around every terrain patch and do it the same way you do when checking an objects bb.
>
your idea may be good If I wanna render the hole patch for any intersection between the shadow map and the terrain patch, but I want to render just the part affected by the shadow map.

Share this post


Link to post
Share on other sites
Quote:
Original post by DoomAngel
your idea may be good If I wanna render the hole patch for any intersection between the shadow map and the terrain patch, but I want to render just the part affected by the shadow map.


If your patches aren't too large this shouldn't be a problem. Checking every polygon of your terrain for visibility will be slower than rendering a few unnecessary polygons. You should use your CPU to speed up rendering, but don't overdo it or it's very likely your application will become CPU bound. And you still need your CPU for collision detection, ai, etc...

Also you should render one shadowmap per light and not one per object.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!