Game Development Community

RESOLVED Fog and Transparency Issues

by Steve Acaster · in Torque 3D Professional · 03/02/2010 (8:28 am) · 7 replies

Apparently fog and transparent textures are not the best of friends ...

img14.imageshack.us/img14/9444/fogtransparency.jpg
Pic related.



However, I've noticed that coronas on a light object do not suffer from this ... and surely they're using some sort of transparency ...


RESOLVED IN 1.1BETA2

#1
03/02/2010 (9:25 am)
Looks like the alpha portion of the texture is being fogged. Should only be applying fogging to the RGB values...

I'm not sure if this is still the same issue in Torque3D 1.1 Beta 1, but I had to fix this problem in 1.0.

In shaderFeatureHLSL.cpp, change the following:

// Lerp between the fog color and diffuse color.
   LangElement *fogLerp = new GenOp( "lerp( @, @, @ )", fogColor, color, fogAmount );
   meta->addStatement( new GenOp( "   @ = @;\r\n", color, fogLerp ) );

To this:

// Lerp between the fog color and diffuse color.
   LangElement *fogLerp = new GenOp( "lerp( @.rgb, @.rgb, @ )", fogColor, color, fogAmount );
   meta->addStatement( new GenOp( "   @.rgb = @;\r\n", color, fogLerp ) );

Hope that helps!
#2
03/02/2010 (11:48 am)
@Stephane

That is a good fix and it will be in 1.1 beta 2. Its amazing that this bug has persisted since 1.0. We in fact ran into it ourselves just yesterday when preparing for GDC.
#3
03/02/2010 (12:05 pm)
My terrain disappeared after the fix, maybe there is something more i have to change. I am using 1.1 Beta 1.
#4
03/02/2010 (2:04 pm)
@Zealander - Look in the console for shader compiler errors. I suspect maybe you incorrectly typed in the fix and your shaders are not compiling.
#5
03/02/2010 (2:36 pm)
//   should
@;rn
//   be
@;/r/n
//   ?

EDIT:
I forgot that editing a post wipes your / and you have to put them back in. Code tag issue on site - hit edit and watch your code get mangled!

So it should look like:
LangElement *fogLerp = new GenOp( "lerp( @.rgb, @.rgb, @ )", fogColor, color, fogAmount );
   meta->addStatement( new GenOp( "   @.rgb = @;\r\n", color, fogLerp ) );

Also, great fix, Stephane.
#6
03/02/2010 (3:06 pm)
Okay, it's the backslash which the forums have issues with when you hit edit ... but I'm not editing the above post again because of it. ;)
#7
03/02/2010 (10:31 pm)
Yeah, i did not have slashes, it works now, thank you for the fix!