From ae9087aea7aa2b19bf78daa6593d14dfba98183d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 28 Aug 2024 03:48:19 +0100 Subject: Initial cut of shadow map creation with support for billboard shadows --- gfx/gl/shaders/shadowDynamicPointStencil.fs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 gfx/gl/shaders/shadowDynamicPointStencil.fs (limited to 'gfx/gl/shaders/shadowDynamicPointStencil.fs') diff --git a/gfx/gl/shaders/shadowDynamicPointStencil.fs b/gfx/gl/shaders/shadowDynamicPointStencil.fs new file mode 100644 index 0000000..57b8aa3 --- /dev/null +++ b/gfx/gl/shaders/shadowDynamicPointStencil.fs @@ -0,0 +1,16 @@ +#version 330 core +#extension GL_ARB_shading_language_420pack : enable + +layout(binding = 0) uniform sampler2D stencilDepth; +flat in vec3 scale; +in vec2 texCoord; + +void +main() +{ + float stDepth = texture(stencilDepth, texCoord).r; + if (stDepth >= 1) { + discard; + } + gl_FragDepth = gl_FragCoord.z + (stDepth * scale.z); +} -- cgit v1.2.3 From 052b2b49d9bfdaaa7f7c5603fa7c47b881df93c2 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 2 Sep 2024 21:00:41 +0100 Subject: Update stencil texture to 2d array --- gfx/gl/shaders/shadowDynamicPointStencil.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gfx/gl/shaders/shadowDynamicPointStencil.fs') diff --git a/gfx/gl/shaders/shadowDynamicPointStencil.fs b/gfx/gl/shaders/shadowDynamicPointStencil.fs index 57b8aa3..e612691 100644 --- a/gfx/gl/shaders/shadowDynamicPointStencil.fs +++ b/gfx/gl/shaders/shadowDynamicPointStencil.fs @@ -1,9 +1,9 @@ #version 330 core #extension GL_ARB_shading_language_420pack : enable -layout(binding = 0) uniform sampler2D stencilDepth; +layout(binding = 0) uniform sampler2DArray stencilDepth; flat in vec3 scale; -in vec2 texCoord; +in vec3 texCoord; void main() -- cgit v1.2.3 From c9bf24c7d1c10e2ff7349fa2d9010895860977a9 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 10 Oct 2024 00:48:06 +0100 Subject: Fix stencil shadow depth offset --- gfx/gl/shaders/shadowDynamicPointStencil.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gfx/gl/shaders/shadowDynamicPointStencil.fs') diff --git a/gfx/gl/shaders/shadowDynamicPointStencil.fs b/gfx/gl/shaders/shadowDynamicPointStencil.fs index e612691..fe91b07 100644 --- a/gfx/gl/shaders/shadowDynamicPointStencil.fs +++ b/gfx/gl/shaders/shadowDynamicPointStencil.fs @@ -12,5 +12,5 @@ main() if (stDepth >= 1) { discard; } - gl_FragDepth = gl_FragCoord.z + (stDepth * scale.z); + gl_FragDepth = gl_FragCoord.z + ((stDepth - 0.5) * scale.z); } -- cgit v1.2.3