diff options
| author | Ray <[email protected]> | 2021-03-17 14:37:29 +0100 |
|---|---|---|
| committer | Ray <[email protected]> | 2021-03-17 14:37:29 +0100 |
| commit | 58f6668cee821a3bfb91ba5f49a1ff670a2ef245 (patch) | |
| tree | 03277f48d1d5fe06e24d7db28cdd18f44b54fd0f /examples/web/shaders/resources | |
| parent | d183a297da01dbd70b6e38d5f4226fa38cdbd5a3 (diff) | |
| download | raylib.com-58f6668cee821a3bfb91ba5f49a1ff670a2ef245.tar.gz raylib.com-58f6668cee821a3bfb91ba5f49a1ff670a2ef245.zip | |
Updated instancing sample
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)); } |
