summaryrefslogtreecommitdiff
path: root/gfx/gl/shaders/shadowDynamicPointStencil.gs
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-09-23 20:12:48 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2024-09-23 20:12:48 +0100
commitdbbfd39eef3b4d063ab7cdeb8d139b1bc11ba72c (patch)
tree0a880b2d14ac152014649d32088b73f17bf77297 /gfx/gl/shaders/shadowDynamicPointStencil.gs
parentMerge branch 'sunpos' (diff)
parentPopulate all layers of shadow stencil with view from all around (diff)
downloadilt-dbbfd39eef3b4d063ab7cdeb8d139b1bc11ba72c.tar.bz2
ilt-dbbfd39eef3b4d063ab7cdeb8d139b1bc11ba72c.tar.xz
ilt-dbbfd39eef3b4d063ab7cdeb8d139b1bc11ba72c.zip
Psycho-rebased branch billboard-shadows on top of main
Diffstat (limited to 'gfx/gl/shaders/shadowDynamicPointStencil.gs')
-rw-r--r--gfx/gl/shaders/shadowDynamicPointStencil.gs33
1 files changed, 33 insertions, 0 deletions
diff --git a/gfx/gl/shaders/shadowDynamicPointStencil.gs b/gfx/gl/shaders/shadowDynamicPointStencil.gs
new file mode 100644
index 0000000..b91937d
--- /dev/null
+++ b/gfx/gl/shaders/shadowDynamicPointStencil.gs
@@ -0,0 +1,33 @@
+#version 330 core
+#extension GL_ARB_viewport_array : enable
+
+const vec2[] corners = vec2[4](vec2(-1, -1), vec2(-1, 1), vec2(1, -1), vec2(1, 1));
+
+uniform mat4 viewProjection[4];
+uniform int viewProjections;
+uniform vec3 sizes[4];
+uniform float size;
+
+in ivec3 vworldPos[];
+
+flat out vec3 scale;
+out vec3 texCoord;
+
+layout(points) in;
+layout(triangle_strip, max_vertices = 16) out;
+
+void
+main()
+{
+ for (gl_Layer = 0; gl_Layer < viewProjections; ++gl_Layer) {
+ scale = 2.0 * size / sizes[gl_Layer];
+ vec4 pos = viewProjection[gl_Layer] * vec4(vworldPos[0], 1);
+ for (int c = 0; c < corners.length(); ++c) {
+ gl_Position = pos + vec4(scale.xy * corners[c], 0, 0);
+ gl_Position.z = max(gl_Position.z, -1);
+ texCoord = vec3((corners[c] * 0.5) + 0.5, 0);
+ EmitVertex();
+ }
+ EndPrimitive();
+ }
+}