Proper use of water shaders?

Discussion for Level editing, modeling, programming, or any of the other technical aspects of Quake
Post Reply
AEon
Posts: 1816
Joined: Sun Apr 20, 2003 7:00 am

Proper use of water shaders?

Post by AEon »

This is probably quite known, but I never really looked into it since I normally never use water.

When you use a id water shader on a complete brush and place its edges "in the geometry" to avoid edge and floor "overlap" effects, I noted that the geometry deformations are seen on all the water brush edges (r_showtris), thus wasting resources. I then just turned the top texture "water" and the other faces nodraw. That keeps the surface working, it still "looks" like water, but has lost the water properties (e.g. splashing sound).

What is the proper way to place water shaders?

(My guess is that the "first" random face is picked, it's nodraw and thus the water properties are lost?)
jal_
Posts: 223
Joined: Mon Mar 24, 2008 4:13 pm

Re: Proper use of water shaders?

Post by jal_ »

I think your guess is right. I have a nodrawwater shader for this purpose.
AEon
Posts: 1816
Joined: Sun Apr 20, 2003 7:00 am

Re: Proper use of water shaders?

Post by AEon »

Could you copy/paste that nodrawwater shader here?

It probably looks like this?
  • textures/common/nodrawwater
    {
    qer_editorimage textures/common/nodraw.tga
    surfaceparm nodraw
    surfaceparm nolightmap
    surfaceparm nonsolid
    surfaceparm trans
    surfaceparm nomarks
    surfaceparm water
    }
Tabun
Posts: 76
Joined: Fri Aug 07, 2009 4:26 pm

Re: Proper use of water shaders?

Post by Tabun »

I will make no claims to have done this "right," but I used a trick to control the water surface better in tabq1dm5:
  • I wrote a shader for water effects, that has no stages, but just creates an invisible water brush (with fog). This has "q3map_noTJunc" and "q3map_noClip" added to avoid unnecessary addition of polygons (dunno if you really need both).
    - I placed various mesh patches to fill the surface area for the rooms, so the whole water surface is covered with a visible layer. Then I wrote a shader for that, which gave me all the control I needed for lightmap and making both sides of the shader different.
That really helped me get the effects I wanted. It will probably be considered a hack by most, but what the heck.
[size=85][url=http://www.tabun.nl]www.tabun.nl[/url][/size]
obsidian
Posts: 10970
Joined: Mon Feb 04, 2002 8:00 am

Re: Proper use of water shaders?

Post by obsidian »

The problem with water and no draw is that they are placed on the same brush and as far as the entire properties of the brush is concerned, Q3Map2 has no idea which shader to take priority over the other, so it chooses one at random and uses that. Sometimes, you'll find that you recompile and it works, other times, it won't.

To take some of the silly randomness out of the equation, you can use a modified watercaulk shader.

Code: Select all

// Obsidian: 2 usages for watercaulk depending on water brush complexity
// SIMPLE WATER BRUSHES - use watercaulk on faces between water brushes
// COMPLEX WATER BRUSHES - overlap complex water brushes with watercaulk.
//		Water shader should be nodraw, nonsolid, trans, *sans-water*
textures/common/watercaulk
{
	qer_trans 0.5
	surfaceparm nodraw
  	surfaceparm nonsolid
  	surfaceparm trans
  	surfaceparm water
}
Also, editor image here

Note that there are two methods of using this, on relatively simple water surfaces (just a few brushes) texture the top of the water with your water shader and the rest with watercaulk. On complex water surfaces, create a new water surface shader (nodraw, nonsolid, trans, NO surfaceparm water) applied to the top face of the visible water surface with nodraw on all other faces and overlap the entire swim-able area with one or more watercaulk volumes.

Edited for clarity
[size=85][url=http://gtkradiant.com]GtkRadiant[/url] | [url=http://q3map2.robotrenegade.com]Q3Map2[/url] | [url=http://q3map2.robotrenegade.com/docs/shader_manual/]Shader Manual[/url][/size]
AEon
Posts: 1816
Joined: Sun Apr 20, 2003 7:00 am

Re: Proper use of water shaders?

Post by AEon »

obsidian wrote:The problem with water and no draw is that they are placed on the same brush and as far as the entire properties of the brush is concerned, Q3Map2 has no idea which shader to take priority over the other, so it chooses one at random and uses that. Sometimes, you'll find that you recompile and it works, other times, it won't.
I seem to remember we had this discussion on the topic of glass in AEneon... I had been wondering why the weapon clipping would work on some glass faces and not on others (at random). I ended up always placing weapclip right over all the glass brushes.

Will give your watercaulk a spin... though in my case these are all trivial 1-brush water areas on rectangular floor areas.
AEon
Posts: 1816
Joined: Sun Apr 20, 2003 7:00 am

Re: Proper use of water shaders?

Post by AEon »

Hmm... using id's clear_calm1 water shaders and your watercaulk, this *totally* messes up everything. Not only are the brush edges still drawn, the shader is treated like caulk you look right through the map floor (at full bright).

What is going on here?

Update: Solution... simply put the water shaders on all brush faces (in my simple 1-brush fills up everything case), then *ensure* that you drag the water brush faces (other than the top surface face obviously) into solid geometry (or void), and bingo all "useless" side faces are gone and it works. Edges in detail geometry are *not* removed!
rgoer
Posts: 798
Joined: Sun Aug 17, 2003 7:00 am

Re: Proper use of water shaders?

Post by rgoer »

does clear_calm1 have surfaceparm water?

if so, that would be why it doesn't work in conjunction with watercaulk
rgoer
Posts: 798
Joined: Sun Aug 17, 2003 7:00 am

Re: Proper use of water shaders?

Post by rgoer »

honestly doing what Obsidian described, separating the "media volume" (hey it is a brush inside the bounds of which one may swim) functionality of water from the visual surface quality, that is really the best course of action

watercaulk brush to define the media volume, then just create a patch or something and apply a shader to it to create the visuals for the water surface itself
AEon
Posts: 1816
Joined: Sun Apr 20, 2003 7:00 am

Re: Proper use of water shaders?

Post by AEon »

It does... I must have misread the application of watercaulk. I though you only need to change the water shader, i.e. remove the surfaceparm water if you are using watercaulk in the second case. Seems I was wrong.
Tabun
Posts: 76
Joined: Fri Aug 07, 2009 4:26 pm

Re: Proper use of water shaders?

Post by Tabun »

I'm kind of lost now. Are you guys talking about what I suggested or what obsidian suggested? Obsidian's method is bound to be the way to go, seeing as he's the shader guru. I just thought up a hack that seemed to work well enough for what I needed.
[size=85][url=http://www.tabun.nl]www.tabun.nl[/url][/size]
jal_
Posts: 223
Joined: Mon Mar 24, 2008 4:13 pm

Re: Proper use of water shaders?

Post by jal_ »

AEon wrote:Could you copy/paste that nodrawwater shader here?
It's just nodraw with surfaceparm water added.
User avatar
seremtan
Posts: 36013
Joined: Wed Nov 19, 2003 8:00 am

Re: Proper use of water shaders?

Post by seremtan »

ydnar had a water caulk shader that worked great (as a substitute for nodrawing all the non-surface sides). damned if i can find it though :(
obsidian
Posts: 10970
Joined: Mon Feb 04, 2002 8:00 am

Re: Proper use of water shaders?

Post by obsidian »

ydnar's water caulk shader is the same as the one I have above.
[size=85][url=http://gtkradiant.com]GtkRadiant[/url] | [url=http://q3map2.robotrenegade.com]Q3Map2[/url] | [url=http://q3map2.robotrenegade.com/docs/shader_manual/]Shader Manual[/url][/size]
Post Reply