Game Development Community

dev|Pro Game Development Curriculum

Fix Disappearing Water Fog

by Edward F. Maurina III · 06/23/2003 (1:30 pm) · 9 comments

Until water gets upgraded to allow multiple overlapping blocks, you may run into the case where at certain viewing angles the water fog will 'turn-off'. This can be considered annoying at best, and really bad for your game at worst. Fortunately, the fix is simple. Also, it will apply to later generations of water where blocks can be placed above or below each-other.

Before you do this however, you must be working from the HEAD version of the engine, or you must apply patch 3555 yourself. I'll tag instructions for this very simple patch onto the end of this how-to.

Fix
The steps for fixing this problem are simple:
0. Place your water as you normally do.
1. Scale the Z dimension such that the lowest point of your water block is well below the lowest terrain point under your water block. This will require a little work to get your water level back where it was. (I suggest using the mouse for scaling to avoid the 'snap-back' you get when accidentally hitting apply in the inspector after moving water.)

Thats it!

Patch 3555
You need to have this code applied or you will run into an odd phenomenon where the player behaves as if it is in water when parallel to the block. This actually always happened prior to this patch, but scaling Z somehow made it worse.

In file: torque/engine/terrain/waterBlock.cc
change (around line 347):
if(!mRemoveWetEdges)
    {
       mObjBox.min.set(-1e4, -1e4, 0);
       mObjBox.max.set( 1e4,  1e4, 1);
    }
to:
mObjBox.min.set( 0, 0, 0);
	mObjBox.max.set( 1, 1, 1);

#1
06/23/2003 (1:32 pm)
I believe this fix was check into CVS last week, but this is a useful change to apply if your using an ealier branch of the engine.
#2
06/23/2003 (5:50 pm)
I don't see it on the cvs change log Tim.
#3
06/23/2003 (6:39 pm)
Never mind, it's there :)
#4
06/23/2003 (9:59 pm)
Tim/Xavier,

Yeah. I just mentioned the patch because if folks have branched, they'll need to fix that bit of code for this how-to-fix to work properly.

-Ed
#5
06/29/2003 (9:30 am)
@Ed: I don't think this works perfectly.... Let's talk about it a bit on IRC
#6
07/03/2003 (11:48 am)
@eXoDuS - Just saw your comment. Catch you next time on the IRC.

-Ed
#7
04/06/2005 (9:49 am)
I have this change implemented, but I still get the water fog "vanishing" at certain angles - usually near to a free edge of a water block (map edge)
#8
07/14/2005 (5:04 am)
same for me.
#9
08/02/2007 (9:14 am)
I've found by putting in

position ="-1024 -1024 0";

in the water block of the .mis file

seems to fix water misteriously dissapearing