Game Development Community

Fog color problems on the Mac

by Miguel Angel Friginal · in Torque Game Engine · 06/06/2004 (7:34 am) · 13 replies

I have a problem whenever I change the color of the fog on a Mac. As it is by default it works fine cause it is set (at least in the FPS Starter Pack) to a light grey. If I change it to any non grey color (like blue) it looks fine til it reaches the fogDistance, and from then to visibleDistance it shows as another color (red) whenever it intersects the terrain (not the water, for example). I suppose some endian issue is going on here, but I can't find where in the code this can be. Any idea where I should look?

#1
06/07/2004 (11:56 am)
This is probably something we should fix... I will mention it to Josh for his next round of mac bug fixes.
#2
06/07/2004 (12:30 pm)
Man... so much Mac work to do... no time to do it.

Thanks for pointing this out Angel. I will take a look ASAP.
#3
06/07/2004 (12:47 pm)
Well, finally I have found where the problem was. The issue is with the ColorI::getRGBEndian function in color.h. It is called from SceneGraph::buildFogTexture around line 259. The function is like...

inline U32 ColorI::getRGBEndian() const
{
// this used to be RGBPack for PC, but someone changed if bc of haze errors?
return(getBGRPack());
}

...and should be something like...

inline U32 ColorI::getRGBEndian() const
{
// this used to be RGBPack for PC, but someone changed if bc of haze errors?
#if defined(TORQUE_OS_MAC)
return(getRGBPack());
#else
return(getBGRPack());
#endif
}

Probably this function would be better with other name, like getBGREndian, but well... like that now it works as expected on the Mac.
#4
06/07/2004 (1:13 pm)
This issue also affects vertex lighting on mac. I fought that this weekend only to discover the vertex indexes were also skewed due to endian issues. I haven't had time to resolve the issue, but I thought I'd point it out.

-John
#5
06/07/2004 (2:38 pm)
Thanks guys :) I don't know exactly when I'll get to this. Hopefully w/in a week. If someone fixes it before me, more power to ya! You can email me or Tim w/ the fix and we will get it rocking. Otherwise, I'll get to it as soon as time allows.
#6
06/07/2004 (3:55 pm)
Davis was working on this in TZ. I don't know if he ever found the solution, though.
#7
06/08/2004 (6:31 am)
John, can you explain in more detail the problem with the vertex lightning? I would like to help with that. It seems Josh already has enough work to do so maybe we can help him track this bug.
#8
06/08/2004 (6:54 am)
Sure thing. Last weekend I noticed that vertex lighting wasn't working properly. After tracking down the endian issue in ColorI I added a fix that should have worked (the RGBA to ABGR swap), however the lighting was still severely messed up. I continued trying a number of different swap combinations before I realized that the colors were actually on the wrong vertices.

I didn't have the time to look into it further; however I do know that the interior's verts are in the correct order because the dts lighting is working correctly, so that should narrow it down to the code in Interior::render...VC... (I think there are 2 of these, one with fog coords and one without) that retrieve the color values (specifically how the list is indexed?).

If I get the chance I'll look at it again to see if I can help.

Hope this help!

-John
#9
06/18/2004 (2:29 pm)
Ok... I'm not sure if this helps narrow down the issue or not, but I recently noticed that enabling fog coords really breaks TGE on Mac. It appears to be the same indexing issues as with the vertex lighting.

Here's a snapshot of a clean 1.2.2 with fog coords enabled:

www.synapsegaming.com/content/linkedimages/TGE-bug1.jpg
I would appreciate someone else verifying this (just in case). You can enable fog coords by changing '$pref::OpenGL::disableEXTFogCoord' to "0" in client/prefs.cs.

Thanks!

-John
#10
06/19/2004 (12:34 am)
Yep, I have verified it against the latest HEAD and I get exactly the same result than on your screenshot. Running on a G4 with Panther, and GeForce 2 MX
#11
06/19/2004 (11:05 am)
Have you tried dumping the fog texture?
#12
06/20/2004 (11:56 pm)
This is why I've started using the bugs forum. I tried submitting this stuff as resources, code snippets, posts on the mac forums, before. But I guess noone noticed :)

posted back in Oct last year, heh:
www.garagegames.com/mg/forums/result.thread.php?qt=13790
It'd be cool if we could start getting these fixes into CVS, so ppl can start benefiting from them.

I have no idea what the deal is with the fog coord ext thing.
My machine does not get the same symptoms as in bobtheCbuilder's screenshot. Rather, the interiors just remain completely unfogged until they pass out of the visible distance range.
#13
08/26/2004 (6:11 am)
Hey Paul, I'm taking a look at this now. From the thread you link, and threads referred to from there, it seems there is some disagreement about the potential fix here.

Do you have an update at all on where this issue stands? Feel free to email me if you prefer. Thanks.