Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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: Dynamic shadows with the infinite terrain.

share|improve this question
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
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

Your Answer


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