Game Development Community

T3D 1.1 Beta 3 - no zWriteEnable when generating imposters - LOGGED

by Fyodor -bank- Osokin · in Torque 3D Professional · 03/02/2011 (6:55 am) · 7 replies

Build: T3D 1.1 Beta 3 Pro

Platform: Windows (not sure about Mac/Linux)

Target: Rendering of auto-billboards / imposters

Issues: When generating auto-billboards / imposters, the RenderState used for rendering have zWriteEnable set to false, so on complex shapes the rendered billboards are bad.

Steps to Repeat:
Use complex model (with something "inside" or "covered" with polys).
Catch the moment when imposters are rendered with PerfHud and you will notice that zWriteEnable is set to false.
If we change it manually to true, shape rendered fine.

The RenderState used for imposters differs from the one used for regular render. The regular one have zWriteEnable set to true, while the other one have false.

Good render vs Bad render

Suggested Fix:
None yet.

#1
03/03/2011 (9:45 pm)
Nice catch... That would be really bad.
#2
03/15/2011 (4:12 pm)
Greetings!

Logged as THREED-1474. Thanks!

- Dave
#3
03/21/2011 (7:50 pm)
Hey Bank.

Here is a fix.

In EnginesourceutilimposterCapture.cpp at line 96...

mDiffuseMatInst = MATMGR->createMatInstance( matName );
   mDiffuseMatInst->getFeaturesDelegate().bind( &ImposterCaptureMaterialHook::_overrideFeatures ); // ADDED!
   mDiffuseMatInst->init( features, inMat->getVertexFormat() );

   features.addFeature( MFT_IsDXTnm ); // ADDED!
   features.addFeature( MFT_NormalMap );
   features.addFeature( MFT_NormalsOut );

Then a few lines down at line 115:

void ImposterCaptureMaterialHook::_overrideFeatures(  ProcessedMaterial *mat,
                                                      U32 stageNum,
                                                      MaterialFeatureData &fd, 
                                                      const FeatureSet &features )
{
   if ( features.hasFeature( MFT_NormalsOut) ) // ADDED!
      fd.features.addFeature( MFT_NormalsOut );
   fd.features.addFeature( MFT_ForwardShading ); // ADDED!
}

Finally in EnginesourcematerialsprocessedMaterial.cpp around line 270:

// The prepass will take care of writing to the 
   // zbuffer, so we don't have to by default.
   // The prepass can't write to the backbuffer's zbuffer in OpenGL.
   if (  MATMGR->getPrePassEnabled() && 
         !GFX->getAdapterType() == OpenGL && 
         !mFeatures.hasFeature(MFT_ForwardShading)) // ADDED!
      result.setZReadWrite( result.zEnable, false );

Let me know if this fix works for you.
#4
03/22/2011 (2:22 am)
Unfortunately, it doesn't help. E-mail sent.
#5
03/23/2011 (12:34 am)
@Bank - Did you did delete the existing imposters after you merged the code? If you didn't it would have reused the old ones and you wouldn't have seen any changes.
#6
03/24/2011 (2:39 am)
Actually, there was no imposters at all when I placed DTS.
I took a clean T3D (r33279 - the latest I have), implemented your changes and placed my DTS + textures. Setup an imposters via ShapeEditor - and the bug is still there. I've sent you an email with the DTS I've used.
#7
04/11/2011 (5:31 am)
The "T3D 1.1 Preview" doesn't have this bug, so the case can be closed.