summaryrefslogtreecommitdiff
path: root/gfx/gl/shaders/lightingShader.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/lightingShader.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/lightingShader.fs')
-rw-r--r--gfx/gl/shaders/lightingShader.fs52
1 files changed, 4 insertions, 48 deletions
diff --git a/gfx/gl/shaders/lightingShader.fs b/gfx/gl/shaders/lightingShader.fs
index b0ca20a..4646b75 100644
--- a/gfx/gl/shaders/lightingShader.fs
+++ b/gfx/gl/shaders/lightingShader.fs
@@ -5,58 +5,14 @@ out vec3 FragColor;
in vec2 TexCoords;
-layout(binding = 0) uniform sampler2D gPosition;
-layout(binding = 1) uniform sampler2D gNormal;
layout(binding = 2) uniform sampler2D gAlbedoSpec;
-
-// struct Light {
-// vec3 Position;
-// vec3 Color;
-
-// float Linear;
-// float Quadratic;
-// float Radius;
-//};
-// const int NR_LIGHTS_MAX = 12;
-// uniform Light lights[NR_LIGHTS_MAX];
-// uniform vec3 viewPos;
-
-uniform vec3 lightDirection = normalize(vec3(1, 0, -1));
-uniform vec3 lightColor = vec3(0.6, 0.6, 0.6);
-uniform vec3 ambientColor = vec3(0.5, 0.5, 0.5);
+layout(binding = 3) uniform sampler2D gIllumination;
void
main()
{
- // retrieve data from gbuffer
- // const vec3 FragPos = texture(gPosition, TexCoords).rgb;
- const vec3 Normal = texture(gNormal, TexCoords).rgb;
- const vec3 Diffuse = texture(gAlbedoSpec, TexCoords).rgb;
- // float Specular = texture(gAlbedoSpec, TexCoords).a;
-
- // then calculate lighting as usual
- // vec3 lighting = Diffuse;
- const vec3 lighting = ambientColor + clamp((dot(-lightDirection, Normal) * lightColor), 0, 0.5);
- // vec3 viewDir = normalize(viewPos - FragPos);
- // for (int i = 0; i < NR_LIGHTS_MAX; ++i) {
- // calculate distance between light source and current fragment
- // float distance = length(lights[i].Position - FragPos);
- // if (distance < lights[i].Radius) {
- // diffuse
- // vec3 lightDir = normalize(lights[i].Position - FragPos);
- // vec3 diffuse = max(dot(Normal, lightDir), 0.0) * Diffuse * lights[i].Color;
- // specular
- // vec3 halfwayDir = normalize(lightDir + viewDir);
- // float spec = pow(max(dot(Normal, halfwayDir), 0.0), 16.0);
- // vec3 specular = lights[i].Color * spec * Specular;
- // attenuation
- // float attenuation = 1.0 / (1.0 + lights[i].Linear * distance + lights[i].Quadratic * distance * distance);
- // diffuse *= attenuation;
- // specular *= attenuation;
- // lighting += diffuse + specular;
- //}
- //}
- // FragColor = vec4(lighting, 1.0);
+ const vec3 Albedo = texture(gAlbedoSpec, TexCoords).rgb;
+ const vec3 Illumination = texture(gIllumination, TexCoords).rgb;
- FragColor = vec3(Diffuse * lighting);
+ FragColor = Albedo * Illumination;
}