diff options
Diffstat (limited to 'examples/web/shaders/resources')
| -rw-r--r-- | examples/web/shaders/resources/shaders/glsl100/lighting.fs | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/examples/web/shaders/resources/shaders/glsl100/lighting.fs b/examples/web/shaders/resources/shaders/glsl100/lighting.fs index 5fddcca..bb26bb9 100644 --- a/examples/web/shaders/resources/shaders/glsl100/lighting.fs +++ b/examples/web/shaders/resources/shaders/glsl100/lighting.fs @@ -14,9 +14,9 @@ uniform vec4 colDiffuse; // NOTE: Add here your custom variables -#define MAX_LIGHTS 4 -#define LIGHT_DIRECTIONAL 0 -#define LIGHT_POINT 1 +#define MAX_LIGHTS 4 +#define LIGHT_DIRECTIONAL 0 +#define LIGHT_POINT 1 struct MaterialProperty { vec3 color; @@ -46,24 +46,15 @@ void main() vec3 viewD = normalize(viewPos - fragPosition); vec3 specular = vec3(0.0); - // NOTE: Implement here your fragment shader code - for (int i = 0; i < MAX_LIGHTS; i++) { if (lights[i].enabled == 1) { vec3 light = vec3(0.0); - if (lights[i].type == LIGHT_DIRECTIONAL) - { - light = -normalize(lights[i].target - lights[i].position); - } - - if (lights[i].type == LIGHT_POINT) - { - light = normalize(lights[i].position - fragPosition); - } - + if (lights[i].type == LIGHT_DIRECTIONAL) light = -normalize(lights[i].target - lights[i].position); + if (lights[i].type == LIGHT_POINT) light = normalize(lights[i].position - fragPosition); + float NdotL = max(dot(normal, light), 0.0); lightDot += lights[i].color.rgb*NdotL; @@ -75,7 +66,7 @@ void main() vec4 finalColor = (texelColor*((colDiffuse + vec4(specular, 1.0))*vec4(lightDot, 1.0))); finalColor += texelColor*(ambient/10.0); - + // Gamma correction gl_FragColor = pow(finalColor, vec4(1.0/2.2)); } |
