Skip to main content
GameDev.net gamedev.net
🔒 Locked

Quick Question on shadow mapping and terrains

Started by wizardpc Mar 6, 2013 at 11:43 PM 1 replies 1.1k views
Original Post
wizardpc
wizardpc

I've found tutorials that impliment shadows on objects in a small scene. My question is what simple appoach do you take to do this on a large world terrain (think MMORPG Terrain).

I have a terrain and a light (the sun) that moves depending on time of day. So it's position changes and thus the need for dynamic shadows on my terrain.

So my question is about the best way to set up the "projection from the light"

Do you move to the position of the sun and look at the center of the world (0,0,0) and make sure every object can be drawn to the depth buffer. My guess is the light would have to be positioned really far away?

or

Do you adjust the view to point to some bounded box region (your view frustrum) and then draw objects. My guess is this would allow the light to be closer ?

If these methods are both wrong, What is the correct appoach to setting up the light view/projection matrix for shadow mapping?

programmer_tom
programmer_tom

Basically, if the terrain is to receive shadows, you need to first render the shadow casters (objects other than terrain) into a shadow map in a first pass.

Then, when you want to render the terrain, you apply shadows to the terrain in the pixel shader, using the shadow map that the

casters rendered into.

beans222
beans222

One of the more common solutions for dynamic shadows on a large terrain (usually from the sun) is "cascaded shadow maps" (just throw that at google). Basically you could do either one of those options you listed, but putting the light viewpoint way out there will likely result in low quality shadows unless you use huge textures (which is one reason to things like CSM, they try to put the resolution where it's needed).

New C/C++ Build Tool 'Stir' (doesn't just generate Makefiles, it does the build): https://github.com/space222/stir  

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.