summaryrefslogtreecommitdiff
path: root/gfx/gl/shaders/directionalLight.fs
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-01 17:56:26 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-01 17:56:26 +0000
commitd5cdbbf38380239524e351cb69aec94090884ca5 (patch)
tree5d7dff2f2775701069806eceb4eaef23b22eba3f /gfx/gl/shaders/directionalLight.fs
parentReformat with new clang-format (diff)
parentRemove more use of legacy types (diff)
downloadilt-d5cdbbf38380239524e351cb69aec94090884ca5.tar.bz2
ilt-d5cdbbf38380239524e351cb69aec94090884ca5.tar.xz
ilt-d5cdbbf38380239524e351cb69aec94090884ca5.zip
Merge remote-tracking branch 'origin/terrain'
Diffstat (limited to 'gfx/gl/shaders/directionalLight.fs')
-rw-r--r--gfx/gl/shaders/directionalLight.fs9
1 files changed, 5 insertions, 4 deletions
diff --git a/gfx/gl/shaders/directionalLight.fs b/gfx/gl/shaders/directionalLight.fs
index ca10ef5..f36d83f 100644
--- a/gfx/gl/shaders/directionalLight.fs
+++ b/gfx/gl/shaders/directionalLight.fs
@@ -7,12 +7,13 @@ out vec3 FragColor;
in vec2 TexCoords;
-layout(binding = 0) uniform sampler2D gPosition;
+layout(binding = 0) uniform isampler2D gPosition;
layout(binding = 1) uniform sampler2D gNormal;
layout(binding = 2) uniform sampler2D shadowMap;
uniform vec3 lightDirection;
uniform vec3 lightColour;
+uniform ivec3 lightPoint;
uniform mat4 lightViewProjection[MAX_MAPS];
uniform vec4 shadowMapRegion[MAX_MAPS];
uniform uint lightViewProjectionCount;
@@ -27,10 +28,10 @@ insideShadowCube(vec3 v)
}
float
-isShaded(vec3 Position)
+isShaded(vec4 Position)
{
for (uint m = 0u; m < lightViewProjectionCount; m++) {
- vec3 PositionInLightSpace = (lightViewProjection[m] * vec4(Position, 1.0f)).xyz;
+ const vec3 PositionInLightSpace = (lightViewProjection[m] * Position).xyz;
const float inside = insideShadowCube(PositionInLightSpace);
if (inside > 0) {
const float lightSpaceDepth
@@ -44,7 +45,7 @@ isShaded(vec3 Position)
void
main()
{
- const vec3 Position = texture(gPosition, TexCoords).xyz;
+ const vec4 Position = vec4(texture(gPosition, TexCoords).xyz - lightPoint, 1);
const vec3 Normal = texture(gNormal, TexCoords).rgb;
const float shaded = isShaded(Position);
FragColor = (1 - shaded) * max(dot(-lightDirection, Normal) * lightColour, 0);