Browse Source

Simplified the FogParams shader parameter.

Lasse Öörni 14 years ago
parent
commit
f0951eed31

+ 1 - 1
Engine/Graphics/Batch.cpp

@@ -310,7 +310,7 @@ void Batch::Prepare(Graphics* graphics, Renderer* renderer, bool setModelTransfo
             if (fogStart >= fogEnd * (1.0f - M_LARGE_EPSILON))
             if (fogStart >= fogEnd * (1.0f - M_LARGE_EPSILON))
                 fogStart = fogEnd * (1.0f - M_LARGE_EPSILON);
                 fogStart = fogEnd * (1.0f - M_LARGE_EPSILON);
             float fogRange = Max(fogEnd - fogStart, M_EPSILON);
             float fogRange = Max(fogEnd - fogStart, M_EPSILON);
-            Vector4 fogParams(fogStart / farClip, fogEnd / farClip, farClip / fogRange, 0.0f);
+            Vector4 fogParams(fogEnd / farClip, farClip / fogRange, 0.0f, 0.0f);
             
             
             graphics->SetShaderParameter(PSP_FOGPARAMS, fogParams);
             graphics->SetShaderParameter(PSP_FOGPARAMS, fogParams);
         }
         }

+ 2 - 2
SourceAssets/GLSLShaders/Fog.frag

@@ -1,9 +1,9 @@
 vec3 GetFog(vec3 color, float depth)
 vec3 GetFog(vec3 color, float depth)
 {
 {
-    return mix(color, cFogColor, clamp((depth - cFogParams.x) * cFogParams.z, 0.0, 1.0));
+    return mix(cFogColor, color, clamp((cFogParams.x - depth) * cFogParams.y, 0.0, 1.0));
 }
 }
 
 
 vec3 GetLitFog(vec3 color, float depth)
 vec3 GetLitFog(vec3 color, float depth)
 {
 {
-    return color * clamp((cFogParams.y - depth) * cFogParams.z, 0.0, 1.0);
+    return color * clamp((cFogParams.x - depth) * cFogParams.y, 0.0, 1.0);
 }
 }

+ 1 - 1
SourceAssets/GLSLShaders/Uniforms.frag

@@ -1,6 +1,6 @@
 uniform vec3 cAmbientColor;
 uniform vec3 cAmbientColor;
 uniform vec2 cDepthReconstruct;
 uniform vec2 cDepthReconstruct;
-uniform vec3 cFogParams;
+uniform vec2 cFogParams;
 uniform vec3 cFogColor;
 uniform vec3 cFogColor;
 uniform vec2 cGBufferInvSize;
 uniform vec2 cGBufferInvSize;
 uniform vec4 cLightColor;
 uniform vec4 cLightColor;

+ 2 - 2
SourceAssets/HLSLShaders/Fog.hlsl

@@ -1,9 +1,9 @@
 float3 GetFog(float3 color, float depth)
 float3 GetFog(float3 color, float depth)
 {
 {
-    return lerp(color, cFogColor, saturate((depth - cFogParams.x) * cFogParams.z));
+    return lerp(cFogColor, color, saturate((cFogParams.x - depth) * cFogParams.y));
 }
 }
 
 
 float3 GetLitFog(float3 color, float depth)
 float3 GetLitFog(float3 color, float depth)
 {
 {
-    return color * saturate((cFogParams.y - depth) * cFogParams.z);
+    return color * saturate((cFogParams.x - depth) * cFogParams.y);
 }
 }

+ 1 - 1
SourceAssets/HLSLShaders/Uniforms.hlsl

@@ -22,7 +22,7 @@ uniform float4 cVertexLights[6*3];
 // Pixel shader uniforms
 // Pixel shader uniforms
 uniform float3 cAmbientColor;
 uniform float3 cAmbientColor;
 uniform float2 cDepthReconstruct;
 uniform float2 cDepthReconstruct;
-uniform float3 cFogParams;
+uniform float2 cFogParams;
 uniform float3 cFogColor;
 uniform float3 cFogColor;
 uniform float2 cGBufferInvSize;
 uniform float2 cGBufferInvSize;
 uniform float4 cLightColor;
 uniform float4 cLightColor;