Bad Apple  Bad AppleBad Apple
 Maps Drivel
----------

Completed maps

The Junkyard

Tutorials

 

 

 

 

 

q3map2

simland

Bad Apple

Liquids in Quake 3 Arena

Okay, so what's to know about liquids? Actually, a little more than you might think. At its most basic a volume of liquid is a single brush that has a liquid shader applied to it. You build a hole, and put a big brush in it with a liquid shader on it. Job done? Well, that depends.

Red lines show the edge of the pool and the room its in, the blue lines show the edge of the water brush.

What if we have an room with an L-shaped pool along two walls, with a set of steps that descends into the floor in the opposite corner. If we simply placed a rectangular brush that filled the full extents of the pool, it would extend into the stairwell. Well, we could just hack a corner off the water brush with the clipper tool, however it can be a bad idea to have large areas of overlapping brushes in your level because it can cause a variety undesirable side effects. For example, the compiler will not necessarily cut the brush surfaces neatly to fit inside the bounds of your pool, creating a large amount of overdraw from the non-visible water surface inside the bank. If its shader has a surfacelight value, it may produce weird lighting spots on any brushwork that it passes through (this effect is very common and noticeable with brightly coloured liquids like lava).


See the horrible split edge liquid! Gah! I am inside a brush when I take this. I enjoy cheese.

So, we could use two rectangular brushes to fill our L-shaped pool. Unfortunately, if you build a liquid volume from more than one brush you will get unusual effects at the edges of the brushes where the surface effects do not match up.


Apply a non-drawing shader to the problem surfaces

Fortunately you can cure this problem - where you have two touching surfaces on liquid brushes, you can apply a non-drawing shader. (For those who don't know how to apply a shader to just one face of a brush - use Ctrl+Shift+LeftMouse to select the individual face you want then apply a shader by clicking in the texture browser as normal. Use Ctrl+Shift+Alt+LeftMouse to select multiple faces) You could try common/nodraw, but you then run the risk of the compiler applying the surfaceparms of nodraw to the whole brush in which case the brush will not act as water, so it's better to use a custom non-drawing shader with the same surface properties as your water. When the map is compiled you should find that the join between the two brushes is not visible. An example of a custom nodraw_water shader follows. You can change the surfaceparm water to surfaceparm slime or surfaceparm lava for those liquids.


// Non-drawing water surface shader
textures/[yourmapname]/nodraw_water
{
	qer_editorimage textures/common/nodraw.tga
	qer_trans 0.3
	surfaceparm nodraw
	surfaceparm nomarks
	surfaceparm nonsolid
	surfaceparm trans
	surfaceparm water
}

Remember that name of custom shader file you use needs to have its name in the shaderlist.txt file for q3map2 to be able to see it!

More gotchas

The lava brush in this picture was placed flush with the surrounding floor. I know it makes the poor thing suffer but it is so you can see how wrong it is.

Most of the liquid shaders in Quake 3 use the deform_vertexes wave parameter to produce the nice rippling effect you see on their surfaces in the game. This means that their surfaces will bend and contort out of line with the flat surface that you align the brush to in the editor. Generally speaking, you need to have the brush surface at least 8 units below the edge of whatever is containing the liquid, otherwise the top surface will lap over the edge so that you can see inside the brush. However a distance of more than 16 units is not advisable, otherwise bots will not be able to get out of the pool.

Finally a word on transparent liquids and transparent surfaces in general. If you have a transparent surface, anything you look at through it is obviously taking a lot more rendering time than anything else on the screen, because it is having its surfaces rendered in the normal way and then it's being re-rendered as you would see it through the transparent surface. You may want to keep this in mind, and try to avoid putting overly complex architecture and multi-stage shaders underwater.


Copyright 2001-2011 Tom Waters - goriki@hotmail.com

Bad Apple is not intended for readers under 18 years of age, goats, emus, flukes, capybara, users of CSG subtract, or people who like the name Gary.