I am building terrain using a lod algorithm and deferred cascaded shadowmaps. The tessellated terrain is about 6,000,000 triangles. I tried this using 2 methods.
1st method: Both the deferred shadow program and the drawing program use tessellation shaders to tessellate the terrain. The tessellation stage for each program is exactly the same.
2nd method: I have 3 programs. The first program tessellates the terrain and stores it on the GPU using transform feedback. The second program uses the transform feedback buffer to render to shadow depth buffer. The third program uses the transform feedback buffer to draws the scene. This way I avoid tessellating the terrain twice.
To my surprise, the 2nd method was actually much slower until I started using the separation of the tessellation phase to tessellate the terrain less frequently. Now the methods are about the same fps, but in the 2nd method the terrain mesh is being updated less frequently.
Shouldnt the 2nd method be faster even if I tessellate every frame like the first method? The only thing I can think of is that the passthrough vertex shaders for the shadow and main program both have to copy 6,000,000*3 vertices even though they are just passthrough shaders. In the first method, the data would be passed right from tessellation shader to the fragment shader. So...
Does a passthrough vertex shader use the transform feedback buffer data directly, or does it copy every single vertice (even though it's the same), and use the copied data?
...
{
out_position = in_position;
out_normal = in_normal;
out_uv = in_uv;
}
Is there any way I can speed this up?
Thanks in advance :)
Edit:
I should note that the example is for the shadow program, the geometry shader applies different mvp matrices, culls, and asigns layers.
In the main program, I use gl_Position=mvp*in_position; to allow gl to cull back facing triangles, but the normals and uvs are still passthrough.