Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm creating an infinite terrain engine, which generates the terrain either with fractals or noise. How can I make dynamic shadows for the sun on this terrain, if I don't know in advance what will be rendered in front of the sun.

My terrain: The sun is the only light, it is directional, my terrain is generated on a plane which is positioned before the camera, frustum culled and fits the size of the viewing frustum. It is height mapped with generated noise texture, and using tessellation shaders on it.

Video:http://www.youtube.com/watch?v=tk6yFwYusOs Dynamic shadows with the infinite terrain.

share|improve this question
1  
Is the noise texture generated in the shader? Is it randomized in a way that you could theoretically reproduce the exact same texture if the same seed was used for the noise function? If yes, then I think standard shadowing techniques like shadow mapping can be applied here. Just render the plane, height-mapping it using the same random noise that will later be used for the actual terrain rendering, but from the sun's point of view using an orthographic projection to generate a shadow map. –  Invor Nov 6 '13 at 20:12
    
That video doesn't show any shadows being generated for terrain that doesn't exist. If you want to generate shadows for terrain that isn't yet visible, you need to generate the terrain in advance of the camera view distance. –  Byte56 Nov 6 '13 at 20:57
    
It's important to know if you plan on rotating your sunlight as these would require real dynamic shadows rather than static predefined ones. –  Benjamin Danger Johnson Nov 6 '13 at 23:47
add comment

1 Answer 1

up vote 1 down vote accepted

Generate shadows as part of your render, this way you render shadows around the camera and as the camera moves your detailed shadows relocate. Many games operate this way and apply lower detailed shadows (e.g. lower resolution shadow textures) the further from the camera a portion of the scene is.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.