Шейдеры вычисления каскадов теней

This commit is contained in:
parent 1d2a659c46
commit a272461d85
3 changed files with 29 additions and 8 deletions

6
shaders/empty.frag Normal file
View File

@ -0,0 +1,6 @@
#version 330 core
void main()
{
}

22
shaders/sun_shadow.geom Normal file
View File

@ -0,0 +1,22 @@
#version 420 core
layout(triangles, invocations = 4) in; // здесь invocations должно соответствовать количеству каскадов
layout(triangle_strip, max_vertices = 3) out;
layout(std140, binding = 3) uniform Sun
{
vec3 direction;
vec3 color;
mat4 vp[4];
} sun;
void main()
{
for (int i = 0; i < 3; ++i)
{
gl_Position = sun.vp[gl_InvocationID] * gl_in[i].gl_Position;
gl_Layer = gl_InvocationID;
EmitVertex();
}
EndPrimitive();
}

View File

@ -4,14 +4,7 @@ layout (location = 0) in vec3 pos;
uniform mat4 model;
layout(std140, binding = 3) uniform Sun
{
vec3 direction;
vec3 color;
mat4 vp;
} sun;
void main()
{
gl_Position = sun.vp * model * vec4(pos, 1.0);
gl_Position = model * vec4(pos, 1.0);
}