I am using modern OpenGL to render a 2D non grid/tiled world map. I've generated some simple normal map textures to render over the base world map to provide terrain elevation/detail shading. Terrain is not tiled (triangulated from noise), so the majority of these terrain elevation features can overlap. This is good as it gives a more continuous appearance to mountains etc.

However the normal map shader needs to sample the base terrain color and apply the lighting value to it before returning the output color. So I can't render two overlapping normal textures without the second 'cutting out' the first where they overlap (the second texture render cannot see the output of the first).

My solution to this was to use a 3 pass render to texture via FBO. I attempt to divide the normal textures destination locations into 3 non overlapping groups and render 1 group in each pass. This works to a point, but of course where a texture overlaps more than 3 neighbours the cut out problem remains.

I could just increase the number of passes/groups to 4, 5, 6... and perhaps this will resolve most cut out issues. While this would probably still provide reasonable performance on my system I am guessing there is a limit where integrated graphics cards may struggle.

Is there an alternative solution for this that could scale better to lower end systems? Or is perhaps even a 5 or 6 pass full-screen render viable on even integrated graphics these days?


The first render pass draws the entire 2D scene (minus terrain shading) and is obviously the slowest, but it happens only once. The remaining passes make a screen size copy of the previous pass to a second texture (rendering to a screen sized quad) and then render normal textures to this copy using the first texture as input. Adding more passes would only repeat the screen sized texture copy and normal texture rendering.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.