diff --git a/Templates/BaseGame/game/core/rendering/shaders/foliage.hlsl b/Templates/BaseGame/game/core/rendering/shaders/foliage.hlsl index 9952c29d6..8fc2fc48e 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/foliage.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/foliage.hlsl @@ -124,7 +124,7 @@ void foliageProcessVert( inout float3 position, in float3 eyePos ) { // Assign the normal and tagent values. - //normal = float3( 0, 0, 1 );//cross( gc_camUp, gc_camRight ); + normal = float3( 0, 0, 1 ); T = gc_camRight; // Pull out local vars we need for work. @@ -166,15 +166,6 @@ void foliageProcessVert( inout float3 position, texCoord.x = uvSet.x + ( uvSet.z * sUVCornerExtent[corner].x ); texCoord.y = uvSet.y + ( uvSet.w * sUVCornerExtent[corner].y ); - // Animate the normal to get lighting changes - // across the the wind swept foliage. - // - // TODO: Expose the 10x as a factor to control - // how much the wind effects the lighting on the grass. - // - normal.xy += wind.xy * ( 10.0 * texCoord.w ); - normal = normalize( normal ); - // Get the alpha fade value. float fadeStart = gc_fadeParams.x; diff --git a/Templates/BaseGame/game/core/rendering/shaders/gl/foliage.glsl b/Templates/BaseGame/game/core/rendering/shaders/gl/foliage.glsl index 38b66e767..8452d2d88 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/gl/foliage.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/gl/foliage.glsl @@ -124,7 +124,7 @@ void foliageProcessVert( inout vec3 position, in vec3 eyePos ) { // Assign the normal and tagent values. - //normal = vec3( 0, 0, 1 );//cross( gc_camUp, gc_camRight ); + normal = vec3( 0, 0, 1 ); T = gc_camRight; // Pull out local vars we need for work. @@ -166,15 +166,6 @@ void foliageProcessVert( inout vec3 position, texCoord.x = uvSet.x + ( uvSet.z * sUVCornerExtent[corner].x ); texCoord.y = uvSet.y + ( uvSet.w * sUVCornerExtent[corner].y ); - // Animate the normal to get lighting changes - // across the the wind swept foliage. - // - // TODO: Expose the 10x as a factor to control - // how much the wind effects the lighting on the grass. - // - normal.xy += wind.xy * ( 10.0 * texCoord.w ); - normal = normalize( normal ); - // Get the alpha fade value. float fadeStart = gc_fadeParams.x; diff --git a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl index e90dd41bd..e49bf308d 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl @@ -393,21 +393,18 @@ void dampen(inout Surface surface, sampler2D WetnessTexture, float accumTime, fl { if (degree<=0.0) return; vec3 n = abs(surface.N); - - float ang = dot(float3(0,0,-1),surface.N); - float grav = 2.0-pow(ang,3); - if (grav<0) grav*=-1.0; + float ang = clamp(n.z, 0.04, 0.96); - float speed = accumTime*(1.0-surface.roughness)*grav; - vec2 wetoffset = vec2(speed,speed/2)*0.1; + float speed = accumTime*(1.0-surface.roughness)*ang; + vec2 wetoffset = vec2(speed,speed/2); - float wetness = texture(WetnessTexture, vec2(surface.P.xy*0.2+wetoffset)).b; - wetness = lerp(wetness,texture(WetnessTexture,vec2(surface.P.zx*0.2+wetoffset)).b,n.y); - wetness = lerp(wetness,texture(WetnessTexture,vec2(surface.P.zy*0.2+wetoffset)).b,n.x); - wetness = pow(wetness,3)*degree; + float wetness = texture(WetnessTexture, vec2(surface.P.xy*0.1+wetoffset)).b; + wetness = lerp(wetness,texture(WetnessTexture,vec2(surface.P.zx*0.1+wetoffset)).b,n.y); + wetness = lerp(wetness,texture(WetnessTexture,vec2(surface.P.zy*0.1+wetoffset)).b,n.x); + wetness = pow(wetness*ang*degree,3); - surface.roughness = lerp(surface.roughness,(1.0-wetness*surface.roughness)*0.92f+0.04f,ang); - surface.baseColor.rgb = lerp(surface.baseColor.rgb*(2.0-wetness),surface.baseColor.rgb,ang*surface.roughness); + surface.roughness = lerp(surface.roughness, 0.04f, wetness); + surface.baseColor.rgb = lerp(surface.baseColor.rgb, surface.baseColor.rgb*0.96+vec3(0.04,0.04,0.04), pow(wetness,5)); updateSurface(surface); } diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index 5abb7be6c..ecf846a21 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -396,20 +396,18 @@ void dampen(inout Surface surface, TORQUE_SAMPLER2D(WetnessTexture), float accum { if (degree<=0.0) return; float3 n = abs(surface.N); - float ang = dot(float3(0,0,-1),surface.N); - float grav = 2.0-pow(ang,3); - if (grav<0) grav*=-1.0; + float ang = clamp(n.z, 0.04, 0.96); - float speed = accumTime*(1.0-surface.roughness)*grav; - float2 wetoffset = float2(speed,speed/2)*0.1; + float speed = accumTime*(1.0-surface.roughness)*ang; + float2 wetoffset = float2(speed,speed/2); - float wetness = TORQUE_TEX2D(WetnessTexture, float2(surface.P.xy*0.2+wetoffset)).b; - wetness = lerp(wetness,TORQUE_TEX2D(WetnessTexture,float2(surface.P.zx*0.2+wetoffset)).b,n.y); - wetness = lerp(wetness,TORQUE_TEX2D(WetnessTexture,float2(surface.P.zy*0.2+wetoffset)).b,n.x); - wetness = pow(wetness,3)*degree; + float wetness = TORQUE_TEX2D(WetnessTexture, float2(surface.P.xy*0.1+wetoffset)).b; + wetness = lerp(wetness,TORQUE_TEX2D(WetnessTexture,float2(surface.P.zx*0.1+wetoffset)).b,n.y); + wetness = lerp(wetness,TORQUE_TEX2D(WetnessTexture,float2(surface.P.zy*0.1+wetoffset)).b,n.x); + wetness = pow(wetness*ang*degree,3); - surface.roughness = lerp(surface.roughness,(1.0-wetness*surface.roughness)*0.92f+0.04f,ang); - surface.baseColor.rgb = lerp(surface.baseColor.rgb*(2.0-wetness),surface.baseColor.rgb,ang*surface.roughness); + surface.roughness = lerp(surface.roughness, 0.04f, wetness); + surface.baseColor.rgb = lerp(surface.baseColor.rgb, surface.baseColor.rgb*0.96+float3(0.04,0.04,0.04), pow(wetness,5)); surface.Update(); }