Game Development Community

Bug in ClipMapEffects.cs

by Scott Goodwin · in Torque X 3D · 05/24/2009 (8:06 pm) · 2 replies

In ClipMapEffects.cs there seems to be a bug when texturesUsed is 3. In two places (each shader model), the test has 1 instead of 3 so ClipMap3_2_lit and ClipMap3_1 will never be selected. Here's the snippet:
// choose a technique.
            if (_isLightingEnabled && srs.Gfx.ShaderProfile >= ShaderProfile.PS_2_0)
            {
                // select a shader model 2 technique with lighting
                if (texturesUsed == 1)
                    return "ClipMap1_2_lit";
                else if (texturesUsed == 2)
                    return "ClipMap2_2_lit";
                else if (texturesUsed == 1) // sdg: I think this should be 3
                    return "ClipMap3_2_lit";
                else
                    return "ClipMap4_2_lit";
            }
            else
            {
                // select a shader model 1 technique (no terrain lighting)
                if (texturesUsed == 1)
                    return "ClipMap1_1";
                else if (texturesUsed == 2)
                    return "ClipMap2_1";
                else if (texturesUsed == 1) // sdg: I think this should be 3
                    return "ClipMap3_1";
                else
                    return "ClipMap4_1";
            }

#1
05/27/2009 (5:19 pm)
These sort of string rewrites (although in this case very specific) are probably better done using more powerful string templates. You may want to investigate this for shader generation, as I am.

http://www.stringtemplate.org/

#2
08/29/2009 (7:21 pm)
Fixed for 3.1.4 Release.

John K.