[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/games/astrododge/data/shaders
From: Rivo Laks <rivolaks () hot ! ee>
Date: 2009-08-09 12:42:58
Message-ID: 1249821778.938616.31300.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1009233 by rivol:
Fix specular lighting calculation.
M +7 -3 material-object.frag
M +7 -3 material-ship.frag
--- trunk/playground/games/astrododge/data/shaders/material-object.frag #1009232:1009233
@@ -14,10 +14,14 @@
float specularity = 30.0;
float NdotL = max(dot(N, L), 0.0);
- vec3 R = 2.0 * NdotL * N - L;
- vec3 V = normalize(-vertexEye.xyz);
- float spec = pow(max(dot(R, V), 0.0), specularity);
+ float spec = 0.0;
+ if (NdotL > 0.0) {
+ vec3 R = 2.0 * NdotL * N - L;
+ vec3 V = normalize(-vertexEye.xyz);
+ spec = pow(max(dot(R, V), 0.0), specularity);
+ }
+
return (texColor * NdotL + specular*spec) * Lcolor;
}
--- trunk/playground/games/astrododge/data/shaders/material-ship.frag #1009232:1009233
@@ -10,10 +10,14 @@
float specularity = 30.0;
float NdotL = max(dot(N, L), 0.0);
- vec3 R = 2.0 * NdotL * N - L;
- vec3 V = normalize(-vertexEye.xyz);
- float spec = pow(max(dot(R, V), 0.0), specularity);
+ float spec = 0.0;
+ if (NdotL > 0.0) {
+ vec3 R = 2.0 * NdotL * N - L;
+ vec3 V = normalize(-vertexEye.xyz);
+ spec = pow(max(dot(R, V), 0.0), specularity);
+ }
+
return shipBaseColor * Lcolor * (NdotL * diffuse + spec * specular);
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic