summaryrefslogtreecommitdiffhomepage
path: root/examples/web/shaders/shaders_rlgl_mesh_instanced.data
diff options
context:
space:
mode:
authorRay <[email protected]>2021-03-17 14:37:29 +0100
committerRay <[email protected]>2021-03-17 14:37:29 +0100
commit58f6668cee821a3bfb91ba5f49a1ff670a2ef245 (patch)
tree03277f48d1d5fe06e24d7db28cdd18f44b54fd0f /examples/web/shaders/shaders_rlgl_mesh_instanced.data
parentd183a297da01dbd70b6e38d5f4226fa38cdbd5a3 (diff)
downloadraylib.com-58f6668cee821a3bfb91ba5f49a1ff670a2ef245.tar.gz
raylib.com-58f6668cee821a3bfb91ba5f49a1ff670a2ef245.zip
Updated instancing sample
Diffstat (limited to 'examples/web/shaders/shaders_rlgl_mesh_instanced.data')
-rw-r--r--examples/web/shaders/shaders_rlgl_mesh_instanced.data23
1 files changed, 7 insertions, 16 deletions
diff --git a/examples/web/shaders/shaders_rlgl_mesh_instanced.data b/examples/web/shaders/shaders_rlgl_mesh_instanced.data
index eb8d9fd..8542c54 100644
--- a/examples/web/shaders/shaders_rlgl_mesh_instanced.data
+++ b/examples/web/shaders/shaders_rlgl_mesh_instanced.data
@@ -76,9 +76,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;
@@ -108,24 +108,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;
@@ -137,7 +128,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));
}