From a272461d85cf7a14bb764bd463489ffc8f1b933e Mon Sep 17 00:00:00 2001 From: "re.kovalev" Date: Tue, 31 Oct 2023 21:51:45 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A8=D0=B5=D0=B9=D0=B4=D0=B5=D1=80=D1=8B=20?= =?UTF-8?q?=D0=B2=D1=8B=D1=87=D0=B8=D1=81=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=81=D0=BA=D0=B0=D0=B4=D0=BE=D0=B2=20=D1=82=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shaders/empty.frag | 6 ++++++ shaders/sun_shadow.geom | 22 ++++++++++++++++++++++ shaders/sun_shadow.vert | 9 +-------- 3 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 shaders/empty.frag create mode 100644 shaders/sun_shadow.geom diff --git a/shaders/empty.frag b/shaders/empty.frag new file mode 100644 index 0000000..0f8d755 --- /dev/null +++ b/shaders/empty.frag @@ -0,0 +1,6 @@ +#version 330 core + +void main() +{ + +} \ No newline at end of file diff --git a/shaders/sun_shadow.geom b/shaders/sun_shadow.geom new file mode 100644 index 0000000..4912b94 --- /dev/null +++ b/shaders/sun_shadow.geom @@ -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(); +} \ No newline at end of file diff --git a/shaders/sun_shadow.vert b/shaders/sun_shadow.vert index 05306dc..cbe3f11 100644 --- a/shaders/sun_shadow.vert +++ b/shaders/sun_shadow.vert @@ -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); }