Преглед изворни кода

Revert "waterMaterial more physically realistc"

This reverts commit 5d7322dfc53175a48421b3aeda83090816ef71fa.
László Matuska пре 9 година
родитељ
комит
feb7933921
1 измењених фајлова са 8 додато и 15 уклоњено
  1. 8 15
      materialsLibrary/materials/water/water.fragment.fx

+ 8 - 15
materialsLibrary/materials/water/water.fragment.fx

@@ -69,8 +69,7 @@ void main(void) {
 	float alpha = vDiffuseColor.a;
 
 #ifdef BUMP
-    //smaller bumps superimposed (better moving waves, no "conveyor belt" look):
-	baseColor = (texture2D(normalSampler, vNormalUV) + texture2D(normalSampler,vec2(-vNormalUV.y*0.33,vNormalUV.x*0.33)))/2.0;
+	baseColor = texture2D(normalSampler, vNormalUV);
 	vec3 bumpColor = baseColor.rgb;
 
 #ifdef ALPHATEST
@@ -89,9 +88,8 @@ void main(void) {
 
 	// Bump
 #ifdef NORMAL
-    //reflection angle is also perturbed
+	vec3 normalW = normalize(vNormalW);
 	vec2 perturbation = bumpHeight * (baseColor.rg - 0.5);
-	vec3 normalW = normalize(vNormalW + vec3(perturbation.x*3.0,perturbation.y*3.0,0.0));
 #else
 	vec3 normalW = vec3(1.0, 1.0, 1.0);
 	vec2 perturbation = bumpHeight * (vec2(1.0, 1.0) - 0.5);
@@ -103,21 +101,17 @@ void main(void) {
 	
 	vec2 projectedRefractionTexCoords = clamp(vRefractionMapTexCoord.xy / vRefractionMapTexCoord.z + perturbation, 0.0, 1.0);
 	vec4 refractiveColor = texture2D(refractionSampler, projectedRefractionTexCoords);
-
-    //refraction (sea bed) combined with the water color: TODO: fog-like shallow underwater
-    refractiveColor = colorBlendFactor*waterColor + (1.0-colorBlendFactor)*refractiveColor;
-
+	
 	vec2 projectedReflectionTexCoords = clamp(vReflectionMapTexCoord.xy / vReflectionMapTexCoord.z + perturbation, 0.0, 1.0);
 	vec4 reflectiveColor = texture2D(reflectionSampler, projectedReflectionTexCoords);
 	
 	vec3 upVector = vec3(0.0, 1.0, 0.0);
-
-	//physically correct water reflection by look angle
-	float fresnelTerm = min(0.95, pow(max(dot(eyeVector, upVector), 0.0),1.5));
+	
+	float fresnelTerm = max(dot(eyeVector, upVector), 0.0);
 	
 	vec4 combinedColor = refractiveColor * fresnelTerm + reflectiveColor * (1.0 - fresnelTerm);
 	
-	baseColor = combinedColor;
+	baseColor = colorBlendFactor * waterColor + (1.0 - colorBlendFactor) * combinedColor;
 #endif
 
 	// Lighting
@@ -140,13 +134,12 @@ void main(void) {
 #endif
 
 #ifdef SPECULARTERM
-    //specular glare: more concentrated (no flat surface, specular is only for hard lights)
-	vec3 finalSpecular = specularBase * 2.0 * specularColor * specularColor;
+	vec3 finalSpecular = specularBase * specularColor;
 #else
 	vec3 finalSpecular = vec3(0.0);
 #endif
 
-	vec3 finalDiffuse = clamp(baseColor.rgb, 0.0, 1.0);
+	vec3 finalDiffuse = clamp(diffuseBase * diffuseColor, 0.0, 1.0) * baseColor.rgb;
 
 	// Composition
 	vec4 color = vec4(finalDiffuse + finalSpecular, alpha);