diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-01-31 02:51:16 +0000 |
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-01-31 02:51:16 +0000 |
| commit | bc0958cc863083b4082161bf12456fdf28ab1c77 (patch) | |
| tree | f970782f232d86325f14a36b83125791f24335af /gfx/gl/shaders/spotLight.frag | |
| parent | Initial commit using tesselation shader to create curves (diff) | |
| download | ilt-bc0958cc863083b4082161bf12456fdf28ab1c77.tar.bz2 ilt-bc0958cc863083b4082161bf12456fdf28ab1c77.tar.xz ilt-bc0958cc863083b4082161bf12456fdf28ab1c77.zip | |
Rename shader source in keeping with glsl expectations
Swaps name/type of generated files to match class names and source
files.
Diffstat (limited to 'gfx/gl/shaders/spotLight.frag')
| -rw-r--r-- | gfx/gl/shaders/spotLight.frag | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gfx/gl/shaders/spotLight.frag b/gfx/gl/shaders/spotLight.frag new file mode 100644 index 0000000..1305dbd --- /dev/null +++ b/gfx/gl/shaders/spotLight.frag @@ -0,0 +1,33 @@ +#version 460 core + +out vec3 FragColor; + +layout(binding = 0) uniform isampler2D gPosition; +layout(binding = 1) uniform sampler2D gNormal; +uniform ivec4 viewPort; +flat in vec4 geo_centre; +flat in vec4 geo_direction; +flat in vec3 geo_colour; +flat in float geo_kq; + +void +main() +{ + const vec2 texCoord = gl_FragCoord.xy / viewPort.zw; + const vec3 position = texture(gPosition, texCoord).xyz; + const vec3 lightv = position - geo_centre.xyz; + const float lightDist = length(lightv); + if (lightDist > geo_centre.w) { + discard; + } + const vec3 lightDirection = normalize(lightv); + if (dot(lightDirection, geo_direction.xyz) < geo_direction.w) { + discard; + } + const vec3 normal = texture(gNormal, texCoord).xyz; + const float normalDot = dot(-lightDirection, normal); + if (normalDot < 0) { + discard; + } + FragColor = (geo_colour * normalDot) / (1 + (geo_kq * pow(lightDist / 1000.0, 2))); +} |
