Tessellate(displacement map) a cube.

Hey!

I have used the Geometry shader to create all the faces on a cube. This has been done by first creating two vertices on the cpu for each face which has then been expanded into two triangles (per face) in the geometry shader.

The draw call: glDrawArrays(GL_LINES, …, …)

I wonder now how I can do the same with tessellation and a displacement map? Two vertices for each face on the cpu and then expand everything to two triangles for each face and tessellate the surface with a displacement map.

I’m asking this because the geometry shader is after the tessellation evaluation shader… Need to expand it before the tessellation occur…

Thanks

Read this OpenGL Step by Step - OpenGL Development

I know how tessellation with displacement mapping works. That link doesn’t provide anything to my problem.

I don’t want to create all the 24 vertices on the cpu, only 12. 2 vertices/face. When using the vertex, geometry and fragment shader pipeline then I can expand every 2 vertices(lines) in the geometry shader to 4 vertices(triangle_strip).

But I want to take it further and add a displacement map with tessellation for each face with the same method described above!

Do not use the geometry shader to do tessellation. It is far to slow. If your graphics card does not support tesselation you should do it on the cpu. Displacement mapping is done in the fragment shader - here is one reference http://www.opengl.org/sdk/docs/tutorials/TyphoonLabs/Chapter_4.pdf