Game Development Community

T3d 1.1 beta 2 (and 1) Dx5_NM == No SpecMap [w/FIX] - RESOLVED

by Steve Acaster · in Torque 3D Professional · 03/01/2010 (2:50 pm) · 11 replies

T3d 1.1 beta 1/2

Windows 7

Code/materials

Spec not working with Dxt5_nm

Suggest add fix below - apparently already done for b3. But bumping anyhow.

original 1.1b1 below
Suddenly noticed ('cos I only use it on a few models) ... but when using DX5_NM to preserve the detail in my NormalMap ... and suddenly the SpecMap doesn't function at all.

Pre-1.1, in material.cs, DX5_NM required a SpecMap with PixelSpecular off (or it all became a terrible mess). But in 1.1, now SpecMap doesn't show anything like this.

Using a standard DX5 for NormalMap, PixelSpecular on, and a SpecMap = SpecMap works, strength of it variable through pixelspecular strength.

DX5 NormalMap, PixelSpecular on, no SpecMap = Spec from specPower etc(so no change there).

No messing with detail maps of any kind in this, just Diffuse, Normal and Spec.

scroll down to Manoel's post for the fix

#1
03/01/2010 (3:05 pm)
Pic Related.

img16.imageshack.us/img16/6406/dx5nmspecularbug.jpg

Pic1: No specular - as expected
Pic2: No specular - but there should be from that SpecMap
Pic3: Specular - as expected

I didn't include a pic of DX5_NM + SpecMap + PixelSpecular cos I'm sure we all know what happens.
#2
05/28/2010 (7:56 am)
Just to point out:

In previous versions a SpecMap did not need "specular" ticked in Lighting Properties to work - that was just for using the nm/diffuse - but in 1.1 they do need that checkbox flagged - which in turns neutralizes the ability of a DXT5_NM to function.

edit: actually that's what I said first time round isn't it ... must've forgotten ... damn you brain
#3
05/28/2010 (8:54 am)
I was dealing with this yesterday. No specular on DXT5 normal maps, which are crucial for our game. Here are the source changes to enable it:

In ProcessedShaderMaterial::_determineFeatures(), replace:
// If we have a DXT5 texture we can only assume its a DXTnm if
         // per-pixel specular is disabled... else we get bad results.
         if (  !fd.features[MFT_PixSpecular] && 
               mStages[stageNum].getTex( MFT_NormalMap )->mFormat == GFXFormatDXT5 )
            fd.features.addFeature( MFT_IsDXTnm );
...by:
// If we have a DXT5 texture we can only assume its a DXTnm if
         // per-pixel specular is disabled... else we get bad results.
         if (  /*!fd.features[MFT_PixSpecular] && */
               mStages[stageNum].getTex( MFT_NormalMap )->mFormat == GFXFormatDXT5 )
            fd.features.addFeature( MFT_IsDXTnm );

Also, to enable specular mask in Basic Lighting (however I don't think it'll work with SM 2.0):

In PixelSpecularHLSL::processPix(), replace:
// We we have a normal map then mask the specular 
   if ( fd.features[MFT_NormalMap] )
   {
      Var *bumpColor = (Var*)LangElement::find( "bumpNormal" );
      final = new GenOp( "@ * @.a", final, bumpColor );
   }

...by:
if ( fd.features[MFT_SpecularMap] )
   {
      Var *specularColor = (Var*)LangElement::find( "specularColor" );
      if (specularColor)
         final = new GenOp( "@ * @", final, specularColor );      
   }
   else if ( fd.features[MFT_NormalMap] && !fd.features[MFT_IsDXTnm] )
   {
      Var *bumpColor = (Var*)LangElement::find( "bumpNormal" );
      final = new GenOp( "@ * @.a", final, bumpColor );
   }
#4
05/28/2010 (9:26 am)
This is one of the most awesome things I've seen in a while. Someone get this bug fix integrated, stat! It's this kind of take-charge bugfixing that makes Torque the engine that it is.
#5
05/28/2010 (9:31 am)
My comment made no sense, ignore me!
#6
05/28/2010 (9:56 am)
Well done, Manoel. That works very nicely.
:)

Wrong name there, Sven!
#7
05/28/2010 (10:26 am)
It helps a lot my current pay job is developing a big game using T3D ;)
#8
05/28/2010 (10:41 am)
bug logged Key: TQA-154
#9
08/01/2010 (10:25 pm)
FYI... this will make it into beta 3.
#10
09/06/2010 (10:07 pm)
Fixed in 1.1 Beta 3.
#11
09/19/2010 (8:58 pm)
Kudos to Steve for his massive bug reporting...

We all owe you a beer Steve! :-D

EDIT: uhmmm... maybe better something else or then your future bug reports will become unreliable! LOL! :-D