depth correction

With Permission from Jeff Faust.

   // AFX CODE BLOCK (bug-fix) <<
   // This fix prevents some bad rendering artifacts that occur at the edge of the visibleDistance.
   // The artifacts are most obvious when there is fog present.
This commit is contained in:
Azaezel 2014-12-22 17:58:12 -06:00
parent 84430a46a8
commit b2a4f3fd44

View file

@ -25,7 +25,7 @@
#include "materials/materialFeatureTypes.h"
#include "materials/materialFeatureData.h"
#include "terrain/terrFeatureTypes.h"
void EyeSpaceDepthOutHLSL::processVert( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd )
@ -85,7 +85,12 @@ void EyeSpaceDepthOutHLSL::processPix( Vector<ShaderComponent*> &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" );