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.

  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Invor
    Nov 6, 2013 at 20:12
  • \$\begingroup\$ 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. \$\endgroup\$
    – House
    Nov 6, 2013 at 20:57
  • \$\begingroup\$ It's important to know if you plan on rotating your sunlight as these would require real dynamic shadows rather than static predefined ones. \$\endgroup\$ Nov 6, 2013 at 23:47

1 Answer 1


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.


You must log in to answer this question.