diff options
Diffstat (limited to 'gfx/gl/shaders/directionalLight.fs')
-rw-r--r-- | gfx/gl/shaders/directionalLight.fs | 9 |
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); |