Game Development Community

T3D Beta 1 Bug: Terrain Artifacts at Max Distance with Fog

by Tim Dix (Raverix) · in Torque 3D Professional · 05/10/2009 (5:53 am) · 8 replies

Not sure if anyone else has reported this, but I'm getting some weird rendering on the edges of the terrain at max distance rendered?

Further testing shows it will only show up at MAX distance, and with fog. Looks like the furthest polys aren't getting the proper fog?


Anyone else seeing this?

#1
05/10/2009 (6:18 am)
I thought that might be the lighting striking the back of the terrain, which folds down if you look closely. Then again maybe not, if the terrain folds down surely it shouldn't be in LOS of the player ...
#2
05/10/2009 (12:18 pm)
The problem is in fogP.hlsl:

// Skip fogging the extreme far plane so that 
   // the canvas clear color always appears.
   clip( 0.9999 - depth );

So you either see the sky and this artifact or neither. I've been thinking of a solution, but nothing simple came up yet.

This is just one good reason why it'd be nice to separate visibility distance from cull distance, and let everything have its own cull distance on the SceneObject level (which could default to visibility-0.0001).

Add an optional alpha transition, and I'm gonna shut up till Christmas.
#3
05/10/2009 (12:21 pm)
@Tim: btw, that's an awesome tank! It looks like one of the 3drt tanks. Are you using the tank pack to drive it or something else?
#4
05/10/2009 (2:22 pm)
@Konrad - Yeah, they're the ones from 3DRT. The tank code is based off the tank pack as well, but at this point have been heavily modified.
#5
05/10/2009 (4:02 pm)
Konrad is correct... it is that line in the fog shader that causes it.

At one point we had moved the sky rendering till after fogging and opaque objects. This would ensure no fogging on the sky while also saving some fillrate. We should return to this technique and fix the bugs that stumped us the first time around so we can remove the clip().
#6
05/11/2009 (4:36 pm)
Logged as THREED-433
#7
09/17/2009 (6:51 am)
Problem still exists in T3D Beta 5.
Recommended fix:
depthHLSL.cpp
...
#include "materials/materialFeatureTypes.h"
#include "terrain/terrFeatureTypes.h"

void EyeSpaceDepthOutHLSL::processVert(   Vector<ShaderComponent*> &componentList, 
                                          const MaterialFeatureData &fd )
...

void EyeSpaceDepthOutHLSL::processPix( Vector<ShaderComponent*> &componentList, 
                                       const MaterialFeatureData &fd )
{      
   ...
   LangElement *depthOutDecl = new DecOp( depthOut );

   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 ) );

   // If there isn't an output conditioner for the pre-pass, than just write
   // out the depth to rgba and return.
   ...
}
Added include of terrain/terrFeatureTypes.h
Added IF to check if we are working with terrain + passing min().
So far no noticeable bugs.
#8
08/04/2010 (3:20 pm)
Hi All...

Thanks for this fix! but the same problem and with forest.
how can fix for forest?