diff --git a/Engine/source/terrain/glsl/terrFeatureGLSL.cpp b/Engine/source/terrain/glsl/terrFeatureGLSL.cpp index 63bc8cb60..eba99371a 100644 --- a/Engine/source/terrain/glsl/terrFeatureGLSL.cpp +++ b/Engine/source/terrain/glsl/terrFeatureGLSL.cpp @@ -458,7 +458,7 @@ void TerrainDetailMapFeatGLSL::processPix( Vector &component } // Add to the blend total. - meta->addStatement( new GenOp( " @ = max( @, @ );\r\n", blendTotal, blendTotal, detailBlend ) ); + meta->addStatement( new GenOp( " @ += @;\r\n", blendTotal, detailBlend ) ); // If we had a parallax feature... then factor in the parallax // amount so that it fades out with the layer blending. diff --git a/Templates/Empty/game/shaders/common/terrain/terrain.glsl b/Templates/Empty/game/shaders/common/terrain/terrain.glsl index 1fe7a483e..414c5de24 100644 --- a/Templates/Empty/game/shaders/common/terrain/terrain.glsl +++ b/Templates/Empty/game/shaders/common/terrain/terrain.glsl @@ -32,10 +32,12 @@ float calcBlend( float texId, vec2 layerCoord, float layerSize, vec4 layerSample vec4 diff = clamp( abs( layerSample - texId ), 0.0, 1.0 ); float noBlend = float(any( bvec4(1 - diff) )); - // Use step to see if any of the layer samples // match the current texture id. - vec4 factors = step( texId, layerSample ); - + vec4 factors = vec4(0); + for(int i = 0; i < 4; i++) + if(layerSample[i] == texId) + factors[i] = 1; + // This is a custom bilinear filter. vec2 uv = layerCoord * layerSize; diff --git a/Templates/Full/game/shaders/common/terrain/terrain.glsl b/Templates/Full/game/shaders/common/terrain/terrain.glsl index 1fe7a483e..414c5de24 100644 --- a/Templates/Full/game/shaders/common/terrain/terrain.glsl +++ b/Templates/Full/game/shaders/common/terrain/terrain.glsl @@ -32,10 +32,12 @@ float calcBlend( float texId, vec2 layerCoord, float layerSize, vec4 layerSample vec4 diff = clamp( abs( layerSample - texId ), 0.0, 1.0 ); float noBlend = float(any( bvec4(1 - diff) )); - // Use step to see if any of the layer samples // match the current texture id. - vec4 factors = step( texId, layerSample ); - + vec4 factors = vec4(0); + for(int i = 0; i < 4; i++) + if(layerSample[i] == texId) + factors[i] = 1; + // This is a custom bilinear filter. vec2 uv = layerCoord * layerSize;