Tutorial *104*
Does anyone remember in software quake how when you went underwater the whole screen would warp in a wavey pattern up and down? If you wanted to turn this affect off, you could set the cvar "r_waterwarp to 0".

Well, when GLQuake came around with its transparent water, the water warping was done differently. Now any wall/floor texture that was underwater would warp itself around. The trouble is, that not all the textures would warp the same way so the effect does not look that great if you ask me. Unfortunatly, there was no way to turn it off.... Until now :)

In this tutorial I'll show you how to add r_wateralpha back into GLQuake so you can turn off the underwater texture warping.

Open gl_rmisc.c

Find the R_Init function. In the space above this function, add this line:



cvar_t r_waterwarp = {"r_waterwarp", "0"};

Inside this function, somewhere among all the calls to Cvar_RegisterVariable, add:



Cvar_RegisterVariable (&r_waterwarp);

Now open gl_rsurf.c and find the R_DrawSequentialPoly function. Unfortunaly that's easier said than done because there are two R_DrawSequentialPoly functions. The first one is not used, as it is after an #if 0. The second one is the real function. In the unmodified gl_rsurf.c, this function begins at line 410. The first line in the function after it's variable declartions, is this:



if (! (s->flags & (SURF_DRAWSKY|SURF_DRAWTURB|SURF_UNDERWATER) ) )


Change it to:


if (! (s->flags & (SURF_DRAWSKY|SURF_DRAWTURB|(SURF_UNDERWATER * !(int)!r_waterwarp.value)) ) )


The !(int)! is necessary because we can only multiply SURF_UNDERWATER by 0 or 1, otherwise things could get realy screwy.



 
Not logged in
Sign up
Login:
Passwd: