Game Development Community

EnvironmentMapAlpha incorrectly set to 0

by Clint S. Brewer · in Torque Game Engine · 11/05/2005 (11:40 pm) · 5 replies

Problem background:
read this thread for a more complete description of the problem.
basically, envmaps worked fine for me with the old max2dts and max 5, but behave strangely with max7 and the new exporter. running unmessdts on it makes the problem go away



Guess at what the problem really is:

in tsShapeInstance.cc in the setuptexturing function
there is a chunk of code that looks like this:
smRenderData.environmentMapAlpha = mEnvironmentMapAlpha *
                                      (
                                        (((mShape->mExportMerge && dl<mShape->mSmallestVisibleDL/2) ||
                                            (!mShape->mExportMerge && dl<mMaxEnvironmentMapDL)) ||
                                           intraDL>0.5f) ? 1.0f : 2.0f * intraDL );

Maybe someone who knows more about this code could take a look, but it appears to me that mExportMerge gets set for newer versions of DTS and is not set for old versions ( < version 23 or something like that).


If you look above this section of code you'll see where wantEMap is set up like so:
bool wantEMap = ((mShape->mExportMerge && dl<=mShape->mSmallestVisibleDL/2) ||
                    (!mShape->mExportMerge && dl<=mMaxEnvironmentMapDL)) &&
                   mEnvironmentMapOn && (TextureObject*)mEnvironmentMap && mEnvironmentMapAlpha>0.01f;

Note that in that section of code we check for dl<=, but when we set the environmentMapAlpha we only check for <

so if dl == 0 and mSmallestVisibleDL == 0 then we will get false when setting up environmentMapAlpha, and will result in 0 env mapping.

changing those checks to be <= makes the environment mapping work for my problem models.



So, It's a lot of code to trace through that I'm not completely familiar with, I'd love to hear someone more familiars thoughts on it. If this is the symptom I'm getting does it show some problem in my own model that I can either fix in Max, or the exporter, or is it actually a bug?

thanks for your help.

#1
11/06/2005 (1:15 am)
Issue #711. Thank you Clint!
#2
11/06/2005 (11:50 am)
Thanks Ben, does my guess at the problem look correct to you?
#3
11/08/2005 (11:57 pm)
....he said, only to notice that no one was around, chills went up his neck as he looked for a quick exit before the zombies returned
#4
11/09/2005 (12:23 am)
It's noted for review for next TGE release... so haven't had chance to check this, I've been working 12 hour days getting TGE 1.4 out. :)
#5
11/09/2005 (10:12 am)
I understand, thanks for the reply. The fix seems to be working great for me, so I'm gonna assume it's sound for now. I guess the only problem could possibly be that environment map alpha is not 0 for small objects....I think I can pay that price :)