summaryrefslogtreecommitdiff
path: root/gfx/gl
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/gl')
-rw-r--r--gfx/gl/shaders/shadowStencil.fs6
-rw-r--r--gfx/gl/shaders/shadowStencil.gs28
-rw-r--r--gfx/gl/shaders/shadowStencil.vs10
-rw-r--r--gfx/gl/shadowStenciller.cpp3
4 files changed, 40 insertions, 7 deletions
diff --git a/gfx/gl/shaders/shadowStencil.fs b/gfx/gl/shaders/shadowStencil.fs
index f149c23..1164cc9 100644
--- a/gfx/gl/shaders/shadowStencil.fs
+++ b/gfx/gl/shaders/shadowStencil.fs
@@ -3,13 +3,15 @@
layout(binding = 0) uniform sampler2D textureAlbedo;
-include(`materialInterface.glsl')
+include(`materialDetail.glsl')
include(`materialCommon.glsl')
+in vec2 gTexCoords;
+flat in MaterialDetail gMaterial;
void
main()
{
- if (getTextureColour(Material, TexCoords).a < 0.5) {
+ if (getTextureColour(gMaterial, gTexCoords).a < 0.5) {
discard;
}
gl_FragDepth = gl_FragCoord.z;
diff --git a/gfx/gl/shaders/shadowStencil.gs b/gfx/gl/shaders/shadowStencil.gs
new file mode 100644
index 0000000..eea4643
--- /dev/null
+++ b/gfx/gl/shaders/shadowStencil.gs
@@ -0,0 +1,28 @@
+#version 330 core
+#extension GL_ARB_viewport_array : enable
+
+include(`materialDetail.glsl')
+
+layout(triangles) in;
+layout(triangle_strip, max_vertices = 24) out;
+
+uniform mat4 viewProjection;
+in vec3 FragPos[];
+in vec2 TexCoords[];
+flat in MaterialDetail Material[];
+out vec2 gTexCoords;
+flat out MaterialDetail gMaterial;
+
+void
+main()
+{
+ for (gl_Layer = 0; gl_Layer < 8; ++gl_Layer) {
+ for (int v = 0; v < FragPos.length(); ++v) {
+ gl_Position = viewProjection * vec4(FragPos[v], 1);
+ gTexCoords = TexCoords[v];
+ gMaterial = Material[v];
+ EmitVertex();
+ }
+ EndPrimitive();
+ }
+}
diff --git a/gfx/gl/shaders/shadowStencil.vs b/gfx/gl/shaders/shadowStencil.vs
index 45a0867..a15c4fb 100644
--- a/gfx/gl/shaders/shadowStencil.vs
+++ b/gfx/gl/shaders/shadowStencil.vs
@@ -4,15 +4,17 @@
layout(binding = 1) uniform usampler2DRect materialData;
include(`meshIn.glsl')
-include(`materialInterface.glsl')
+include(`materialDetail.glsl')
include(`getMaterialDetail.glsl')
-uniform mat4 viewProjection;
+
+out vec3 FragPos;
+out vec2 TexCoords;
+flat out MaterialDetail Material;
void
main()
{
TexCoords = texCoord;
Material = getMaterialDetail(material);
-
- gl_Position = viewProjection * vec4(position, 1);
+ FragPos = position;
}
diff --git a/gfx/gl/shadowStenciller.cpp b/gfx/gl/shadowStenciller.cpp
index 01248bd..1063b71 100644
--- a/gfx/gl/shadowStenciller.cpp
+++ b/gfx/gl/shadowStenciller.cpp
@@ -1,13 +1,14 @@
#include "shadowStenciller.h"
#include "gfx/gl/program.h"
#include "gfx/gl/shaders/fs-shadowStencil.h"
+#include "gfx/gl/shaders/gs-shadowStencil.h"
#include "gfx/gl/shaders/vs-shadowStencil.h"
#include "gfx/models/mesh.h"
#include "glArrays.h"
#include "gl_traits.h"
#include <stdexcept>
-ShadowStenciller::ShadowStenciller() : shadowCaster {shadowStencil_vs, shadowStencil_fs}
+ShadowStenciller::ShadowStenciller() : shadowCaster {shadowStencil_vs, shadowStencil_gs, shadowStencil_fs}
{
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glDrawBuffer(GL_NONE);