Waterfog ?

Discuss programming topics for the various GPL'd game engine sources.
Post Reply
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Waterfog ?

Post by Cobalt »

Just tried DP's pretty water...not bad. Thing is, R_water is only 1 or 0, there is no inbetween values that would give semi-transparency, unless you turn it off and do the r_wateralpha thing. Also, there is no one else except one person who tried real underwaterfog, at least on this site via a search for "waterfog" in another engine, but it seems to be in an old thread years ago.

Would real waterfog be hard to do? Also, and perhaps I ask for a lot, but fog that goes by the actual color of the texture, not just the default texture inside the map for the given liquid body, but in the event you use external textures, such as tga etc...?
Seven
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: Waterfog ?

Post by Seven »

Hello Cobalt,

"DP pretty water" includes/is a shader that replaces the water texture, so your in-game options for "water transparency" will not work anymore, as you mentioned.
To adjust the water transparency of DP pretty water you have to either edit the replacement water texture´s alpha value, or edit the shader itself.
The shader makes use of DP´s dp_water shader keyword. Modify its alpha value to adjust the water to your personal likings.

Regarding water fog:
No, waterfog is already available for DarkPlaces. Dresk added it via csqc in his kleshik mod.
Kleshik is open source, so you can copy/paste his waterfog into your source if you want.
Nahuel did it already in a custom HUD csqc mod. He also added several other things from kleshik like an animated mapname display at map start.

Kind regards,
Seven
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Waterfog ?

Post by Spike »

hacking fog when you're underwater isn't really the same thing. it doesn't do underwater fogging when you're out of the water already, and stuff outside the water being foggy simply because you're inside is pretty silly. that said, you should generally not be able to see outside the water very well anyway...
and its all made more complex by water above air, and really confused atmospheric pressure... because water that makes sense is for games that make sense, and we'll have none of that here!
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: Waterfog ?

Post by Cobalt »

Hi Seven:

Thanks for that information, I will have to play around with the pretty water textures some more. Yes, as Spike mentions, Dresk is merely using the "fog" cvar when your player is underwater to simulate waterfog. If you are chase_active 1 , and you break the surface, you can see this more clearly , as the entire map is actually fogged up proportionately. It does have its shortcomings in that regard....but because its client side only and using a stuffcmd more or less its kind of undesirable for multiplayer purposes...at least for mine that it.

I was I guess more curious about permanently fogging liquid content...perhaps other map types like q3bsp etc have a way to accomplish this? Otherwise it would make a nice feature for the engine to fog liquid bodies , perhaps based on the kind of texture the engine has loaded for that area of liquid.

The other alternative is using the "bf" command also via stuffcmd, but to me there seems more possibilities if done engine side.
leileilol
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: Waterfog ?

Post by leileilol »

Fog volumes in Q3BSP aren't that versatile, it's no UnrealEngine1 for sure. Big fog cube or no fog at all. Furthermore this fog volume sometimes breaks if it's too big and blends fog on models outside it looking really ugly at times.
i should not be here
Knightmare
Posts: 63
Joined: Thu Feb 09, 2012 1:55 am

Re: Waterfog ?

Post by Knightmare »

Daikatana does underwater fog when the player's viewpoint is in water (based on leaf contents).

I can't post the code here, but it uses a linear fog mode that starts at 32 and ends at 1024.
For fog color, it uses surface color, which is a lump that DK adds to its BSP format, so you'll need to use average texture color.

You'd need to use the leaf of the player's viewpoint, get that leaf's firstleafbrush, then get the firstbrushside for that brush, and you'll have the surface whose texture you need to get an average color for (maybe write a CM_FirstLeafBrushSurface() function for this). I assume that there would be an image_t pointer to the actual texture rendered somewhere. You'd need to add an average color field to the image_t struct and calculate it when each texture is loaded.
Post Reply