diff options
| author | Ray <[email protected]> | 2016-10-11 00:39:07 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2016-10-11 00:39:07 +0200 |
| commit | 97e3277d58060df96cd002b1377a51ca4adcbb9e (patch) | |
| tree | f41675cee02117049edb9c0628865be1b343e1cc /examples | |
| parent | 648676f46b01327f0fbd6f017292a3159ea9ab2f (diff) | |
| download | raylib-97e3277d58060df96cd002b1377a51ca4adcbb9e.tar.gz raylib-97e3277d58060df96cd002b1377a51ca4adcbb9e.zip | |
Updated standard shader
Corrects weird artifacts on web
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/resources/shaders/glsl100/standard.fs | 17 | ||||
| -rw-r--r-- | examples/resources/shaders/glsl330/standard.fs | 8 |
2 files changed, 8 insertions, 17 deletions
diff --git a/examples/resources/shaders/glsl100/standard.fs b/examples/resources/shaders/glsl100/standard.fs index 6ce2a186..fe604e2a 100644 --- a/examples/resources/shaders/glsl100/standard.fs +++ b/examples/resources/shaders/glsl100/standard.fs @@ -38,7 +38,6 @@ uniform Light lights[maxLights]; vec3 ComputeLightPoint(Light l, vec3 n, vec3 v, float s) { -/* vec3 surfacePos = vec3(modelMatrix*vec4(fragPosition, 1.0)); vec3 surfaceToLight = l.position - surfacePos; @@ -51,17 +50,14 @@ vec3 ComputeLightPoint(Light l, vec3 n, vec3 v, float s) if (diff > 0.0) { vec3 h = normalize(-l.direction + v); - spec = pow(dot(n, h), 3.0 + glossiness)*s; + spec = pow(abs(dot(n, h)), 3.0 + glossiness)*s; } return (diff*l.diffuse.rgb + spec*colSpecular.rgb); -*/ - return vec3(0.5); } vec3 ComputeLightDirectional(Light l, vec3 n, vec3 v, float s) { -/* vec3 lightDir = normalize(-l.direction); // Diffuse shading @@ -72,18 +68,15 @@ vec3 ComputeLightDirectional(Light l, vec3 n, vec3 v, float s) if (diff > 0.0) { vec3 h = normalize(lightDir + v); - spec = pow(dot(n, h), 3.0 + glossiness)*s; + spec = pow(abs(dot(n, h)), 3.0 + glossiness)*s; } // Combine results return (diff*l.intensity*l.diffuse.rgb + spec*colSpecular.rgb); -*/ - return vec3(0.5); } vec3 ComputeLightSpot(Light l, vec3 n, vec3 v, float s) { -/* vec3 surfacePos = vec3(modelMatrix*vec4(fragPosition, 1)); vec3 lightToSurface = normalize(surfacePos - l.position); vec3 lightDir = normalize(-l.direction); @@ -108,12 +101,10 @@ vec3 ComputeLightSpot(Light l, vec3 n, vec3 v, float s) if (diffAttenuation > 0.0) { vec3 h = normalize(lightDir + v); - spec = pow(dot(n, h), 3.0 + glossiness)*s; + spec = pow(abs(dot(n, h)), 3.0 + glossiness)*s; } return (falloff*(diffAttenuation*l.diffuse.rgb + spec*colSpecular.rgb)); -*/ - return vec3(0.5); } void main() @@ -140,7 +131,7 @@ void main() // Calculate specular texture color fetching or set to maximum specular value by default float spec = 1.0; - if (useSpecular == 1) spec *= normalize(texture2D(texture2, fragTexCoord).r); + if (useSpecular == 1) spec = texture2D(texture2, fragTexCoord).r; for (int i = 0; i < maxLights; i++) { diff --git a/examples/resources/shaders/glsl330/standard.fs b/examples/resources/shaders/glsl330/standard.fs index 14497839..0d461484 100644 --- a/examples/resources/shaders/glsl330/standard.fs +++ b/examples/resources/shaders/glsl330/standard.fs @@ -50,7 +50,7 @@ vec3 ComputeLightPoint(Light l, vec3 n, vec3 v, float s) if (diff > 0.0) { vec3 h = normalize(-l.direction + v); - spec = pow(dot(n, h), 3.0 + glossiness)*s; + spec = pow(abs(dot(n, h)), 3.0 + glossiness)*s; } return (diff*l.diffuse.rgb + spec*colSpecular.rgb); @@ -68,7 +68,7 @@ vec3 ComputeLightDirectional(Light l, vec3 n, vec3 v, float s) if (diff > 0.0) { vec3 h = normalize(lightDir + v); - spec = pow(dot(n, h), 3.0 + glossiness)*s; + spec = pow(abs(dot(n, h)), 3.0 + glossiness)*s; } // Combine results @@ -101,7 +101,7 @@ vec3 ComputeLightSpot(Light l, vec3 n, vec3 v, float s) if (diffAttenuation > 0.0) { vec3 h = normalize(lightDir + v); - spec = pow(dot(n, h), 3.0 + glossiness)*s; + spec = pow(abs(dot(n, h)), 3.0 + glossiness)*s; } return (falloff*(diffAttenuation*l.diffuse.rgb + spec*colSpecular.rgb)); @@ -131,7 +131,7 @@ void main() // Calculate specular texture color fetching or set to maximum specular value by default float spec = 1.0; - if (useSpecular == 1) spec *= normalize(texture(texture2, fragTexCoord).r); + if (useSpecular == 1) spec = texture(texture2, fragTexCoord).r; for (int i = 0; i < maxLights; i++) { |
