Use GS instancing to speed up shadow gen a little.

This commit is contained in:
Vincent Lejeune 2014-03-26 22:27:11 +01:00
parent b9d0088ff9
commit 1740407e1e

View File

@ -1,23 +1,36 @@
uniform mat4 ModelViewProjectionMatrix[4];
#if __VERSION__ >= 400
layout(triangles, invocations=4) in;
#else
layout(triangles) in;
#endif
layout(triangle_strip, max_vertices=12) out;
in vec2 tc[3];
out vec2 uv;
void emitToLayer(int layerId)
{
gl_Layer = layerId;
for(int i=0; i<3; i++)
{
uv = tc[i];
gl_Position = ModelViewProjectionMatrix[layerId] * gl_in[i].gl_Position;
EmitVertex();
}
EndPrimitive();
}
void main(void)
{
#if __VERSION__ >= 400
emitToLayer(gl_InvocationID);
#else
for (int j = 0; j<4; j++)
{
gl_Layer = j;
for(int i=0; i<3; i++)
{
uv = tc[i];
gl_Position = ModelViewProjectionMatrix[j] * gl_in[i].gl_Position;
EmitVertex();
}
EndPrimitive();
emitToLayer(j);
}
#endif
}