diff options
Diffstat (limited to 'examples/web/shaders/resources')
| -rw-r--r-- | examples/web/shaders/resources/shaders/glsl100/lighting.fs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/examples/web/shaders/resources/shaders/glsl100/lighting.fs b/examples/web/shaders/resources/shaders/glsl100/lighting.fs index 1d60a83..1a4faa7 100644 --- a/examples/web/shaders/resources/shaders/glsl100/lighting.fs +++ b/examples/web/shaders/resources/shaders/glsl100/lighting.fs @@ -2,7 +2,7 @@ precision mediump float; -// Input vertex attributes (from vertex shader) +// Input vertex attributes varying vec3 fragPosition; varying vec2 fragTexCoord; varying vec4 fragColor; @@ -12,11 +12,9 @@ varying vec3 fragNormal; uniform sampler2D texture0; 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; @@ -51,7 +49,7 @@ void main() 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); @@ -59,7 +57,7 @@ void main() lightDot += lights[i].color.rgb*NdotL; float specCo = 0.0; - if (NdotL > 0.0) specCo = pow(max(0.0, dot(viewD, reflect(-(light), normal))), 16.0); // 16 refers to shine + if (NdotL > 0.0) specCo = pow(max(0.0, dot(viewD, reflect(-(light), normal))), 16.0); specular += specCo; } } |
