Selaa lähdekoodia

Merge pull request #1212 from seanpaultaylor/next

Changed the lighting.frag from phong to blinn-phong shading
Sean Taylor 12 vuotta sitten
vanhempi
sitoutus
ca7fbb6aa3
2 muutettua tiedostoa jossa 9 lisäystä ja 8 poistoa
  1. 6 5
      gameplay/res/shaders/lighting.frag
  2. 3 3
      samples/browser/res/common/light.form

+ 6 - 5
gameplay/res/shaders/lighting.frag

@@ -6,11 +6,12 @@ vec3 computeLighting(vec3 normalVector, vec3 lightDirection, vec3 lightColor, fl
 
     #if defined(SPECULAR)
 
-    vec3 vertexToEye = normalize(v_cameraDirection);
-    vec3 reflect = normalize(normalVector * diffuse * 2.0 - lightDirection);  
-    float specular = pow(clamp(dot(reflect, vertexToEye), 0.0, 1.0), u_specularExponent);
-    vec3 specularColor = vec3(specular, specular, specular); 
-    
+	// Blinn-Phong shading
+    vec3 vertexToEye = normalize(v_cameraDirection); 
+    vec3 halfDirection = normalize(lightDirection + v_cameraDirection);
+    float specularAngle = max(dot(halfDirection, normalVector), 0.0);
+    vec3 specularColor = pow(specularAngle, u_specularExponent);
+
     return (diffuseColor + specularColor) * attenuation;
 
     #else

+ 3 - 3
samples/browser/res/common/light.form

@@ -116,9 +116,9 @@ form formLightSelect
 			size = 210, 60
 			orientation = HORIZONTAL
             textAlignment = ALIGN_LEFT
-			min = 1
-			max = 500
-			value = 1
+			min = 4
+			max = 128
+			value = 4
 			text = Specular
 		}
 		checkbox specularCheckBox