diff --git a/Engine/source/shaderGen/GLSL/depthGLSL.cpp b/Engine/source/shaderGen/GLSL/depthGLSL.cpp index 71bdbb96e..2eb5663e9 100644 --- a/Engine/source/shaderGen/GLSL/depthGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/depthGLSL.cpp @@ -25,7 +25,7 @@ #include "materials/materialFeatureTypes.h" #include "materials/materialFeatureData.h" - +#include "terrain/terrFeatureTypes.h" void EyeSpaceDepthOutGLSL::processVert( Vector &componentList, const MaterialFeatureData &fd ) @@ -85,7 +85,12 @@ void EyeSpaceDepthOutGLSL::processPix( Vector &componentList, LangElement *depthOutDecl = new DecOp( depthOut ); meta->addStatement( new GenOp( "#ifndef CUBE_SHADOW_MAP\r\n" ) ); - meta->addStatement( new GenOp( " @ = dot(@, (@.xyz / @.w));\r\n", depthOutDecl, vEye, wsEyeVec, wsEyeVec ) ); + + if (fd.features.hasFeature(MFT_TerrainBaseMap)) + meta->addStatement(new GenOp(" @ =min(0.9999, dot(@, (@.xyz / @.w)));\r\n", depthOutDecl, vEye, wsEyeVec, wsEyeVec)); + else + meta->addStatement(new GenOp(" @ = dot(@, (@.xyz / @.w));\r\n", depthOutDecl, vEye, wsEyeVec, wsEyeVec)); + meta->addStatement( new GenOp( "#else\r\n" ) ); Var *farDist = (Var*)Var::find( "oneOverFarplane" );