This scene has a triangle count of 2.

Relief Mapping Terrain demo
You are looking at a flat plane consists of 2 triangles running in the Blender 2.5 Game Engine.  There is no run-time subdivision, no geometry shader, using only a minimum pass-through vertex shader, all the magic is happening in the pixel shader.  The terrain is completely 3D looking, you can fly around it, view it from different angles, there is lights, shadows, bumps, shiny lakes, and even a height-based fog.  Below is a video of the technique in motion:

Isn’t Relief Mapping great?

Apart from all games that will inevitably take advantage of this technique, another application I can think of that will reap huge benefit from this is the loading and displaying of large-scale terrain visualization at virtually no CPU overhead.  A 4096×4096 DEM texture can be easily displayed at 60fps.  Whereas if the same data were to be converted to real geometry, most computers will die trying to render those 33million triangles.

The effect is achieved by a rather complex fragment shader (pixel shader) that effectively does ray-casting on each pixel to determine the location and visibility of each pixel.  The shader requires at least 2 textures.  A diffuse color texture; and a normal-height texture that contains the surface normal stored in the RGB channel and the height value stored in the Alpha channel.  Supplied with a miminum of these two textures, the shader is able to reconstruct the 3D surface like you saw.  (I also used a specular texture to control the specularity of the lakes, but this is optional)

Download the demo (4MB)

27 thoughts on “This scene has a triangle count of 2.

  1. I had a ‘dumb-ass’ in high school talking all the time about pixel shader (as he read some computer magazine), but I had no idea…

  2. I tried the demo. A message popped up saying ‘You have opened a 250 file, key information will get lost, like animation data. Continue?’

  3. Hi Snateraar, I used Blender 2.5 Alpha 2 to build the demo. You can download 2.5 from blender.org

  4. Pretty awesome shader. Does anyone know how to map it correctly to a sphere?

  5. It doesn’t run on my computer.

    ATI3850, Blender 2.5

    It says:

    Blender Game Engine Started

    —- Vertex Shader Error —-
    Vertex shader was successfully compiled to run on hardware.

    —- Fragment Shader Error —-
    Fragment shader was successfully compiled to run on hardware.
    —- GLSL Program —-
    Fragment shader(s) linked, vertex shader(s) linked.

    Blender Game Engine Finished

  6. I tried it on a sphere but the shader doesn’t look right, all the raised points are pointing up. not along the normal of the face as they should.

  7. WHOA!!!!!! this is VERY impressive!!! thanks for sharing the blend too :-)

  8. I am having a problem. I load it up but it is just a flat plane with a 2d texture on it. Why isn’t it working in 3d? I am using an Intel Core 2 Duo iMac with blender 2.53

  9. I had the same problem as Devyn (flat plane, even in the game engine) with a similar setup (MacBook Pro, though). If you change the right pane from texture to render you can change the shading from Multitexture to GLSL. Then it should work as expected when you run the game engine. Though, slowly, at least on my system (6-10fps).

  10. I am interested in this vertex shader very much as well, although the link is broken!
    May I ask you how this system works? Or will it become apparent once I open it?
    Thanks!

  11. Hey idont understand what to do after i open the blend. its just the plane. so that video was all just the camera watching the plane?

  12. yes it’s flat. But if you run the game (Press P) on a computer with a OpenGL 3.0 graphics card, you should see the shader.

  13. I tried and got same problem, I just see a plane.
    Intel Core i5
    ATI HD5550 (GL 4.0)
    I don’t know what’s going on… Any idea? (Blender 2.55)

  14. I got the same problem, I can see the plane and the animation, but if I start the game Engine, I just see the animation. I’m using Blender 2.56.
    Blender says the same like the one of qv51, but I only can see the plane with the texture.

    Blender Game Engine Started

    —- Vertex Shader Error —-
    Vertex shader was successfully compiled to run on hardware.

    —- Fragment Shader Error —-
    Fragment shader was successfully compiled to run on hardware.
    —- GLSL Program —-
    Fragment shader(s) linked, vertex shader(s) linked.

    Blender Game Engine Finished

    Thanks for helping, and sorry for the bad english
    Leo

  15. The link doesn’t work, and I would badly love to see how you did this?

    Could you repost it?

  16. If you see a flat plane, try the following.

    Move cursor inside render window, don´t klick. Type ‘n’, then in the newly opened property tab go down to “Render” and set “Shading” from Multitexture to “GLSL”. Type ‘n’ again, start game, enjoy.

  17. I was about to call BS when I looked at the memory usage and triangle count….but then after following your link to here, I have been most enlightened!

    Nice Job!

    I look forward to seeing your future work! =]

  18. Really nice work! That is very impressive. I just have a question, especially since you mentioned DEM data:
    I generated a normal map from a high resolution mesh, which was created from height maps (AsterGDEM). Then i placed the original height map in the alpha-channel of the normal map, imported the image into the blender file you provided and mapped it to the plane (instead of your normal/heightmap). But in BGE the plane stays flat. I guess this might be related to the original height map data?!
    Do you have any idea why this doen’t work? Does one have to change something in the script? It’s definetly not related to the graphic card, since i just got a new quadro.

    Any help would be really appreciated.
    Many greetings.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>