summaryrefslogtreecommitdiff
path: root/gfx/gl/shaders/directionalLight.fs
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-11-19 15:04:30 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-11-23 18:38:43 +0000
commitffdaa93edf5eeaf9db7dc17e51554a77dd9d596d (patch)
tree5ec8af60e0761417d4f80a012679e3071de59888 /gfx/gl/shaders/directionalLight.fs
parentShared context, persist main window in test, send test for upcoming pointlight (diff)
downloadilt-ffdaa93edf5eeaf9db7dc17e51554a77dd9d596d.tar.bz2
ilt-ffdaa93edf5eeaf9db7dc17e51554a77dd9d596d.tar.xz
ilt-ffdaa93edf5eeaf9db7dc17e51554a77dd9d596d.zip
Separate out the illumation of the scene
Diffstat (limited to 'gfx/gl/shaders/directionalLight.fs')
-rw-r--r--gfx/gl/shaders/directionalLight.fs18
1 files changed, 18 insertions, 0 deletions
diff --git a/gfx/gl/shaders/directionalLight.fs b/gfx/gl/shaders/directionalLight.fs
new file mode 100644
index 0000000..7562f96
--- /dev/null
+++ b/gfx/gl/shaders/directionalLight.fs
@@ -0,0 +1,18 @@
+#version 330 core
+#extension GL_ARB_shading_language_420pack : enable
+
+out vec3 FragColor;
+
+in vec2 TexCoords;
+
+layout(binding = 1) uniform sampler2D gNormal;
+
+uniform vec3 lightDirection;
+uniform vec3 lightColour;
+
+void
+main()
+{
+ const vec3 Normal = texture(gNormal, TexCoords).rgb;
+ FragColor = dot(-lightDirection, Normal) * lightColour;
+}