This is dedicated to documentation of the Quake3_Quake1 mod which makes DarkPlaces/Zircon engine capabilities available for Quake 1 single player/coop mapping using the Quake 3 map format. Documentation will be here as an ongoing process.

Post tutorial Report RSS Fence Textures, Glass Textures

An examination of how "fence" textures, transparent textures and alpha transparent entities work using the Quake 3 map format.

Posted by on - Basic Mapping/Technical

Time to examine how "fence" textures work in the Quake 3 map format.

para5

Pictured: Texture "textures/fence/base_chainlink1". This is a shader, it tells the engine and map compiler to only draw the solid parts of the fence. The blue water is a light-emitting liquid with a scrollng water shader.

This texture is a png with transparency. Only the non-transparent parts of the PNG is drawn.

base chainlink

Texture: textures/zz_fence/base_chainlink.png


The following shader specifies to the engine/map compiler how the draw is performed, we open "scripts/dfx_fence.shader" in a texture editor and see this.

The short version is just use this shader for any fence texture.

However, for clarity I heavily commented what the shader is doing step by step. And made an effort to describe what it is doing in way that anyone without any knowledge or experience can read it.

There is no rocket science occurring, but the instructions in this shader are a bit precise.

Most "fence" texture shaders will look much like this (or identical):

textures/fence/base_chainlink1
{
	surfaceparm alphashadow		// use the texture's alpha channel as a mask for casting static shadows in the game world
	surfaceparm trans			// pre-computed visibility should not be blocked by this surface
	cull disable				// both sides of the surface are drawn in the game, there is no front or back -- this is "both sides"

	{ // Texture draw
		map textures/zz_fence/base_chainlink.tga
		rgbGen identity			// use standard identity matrix (think of the identity matrix like "as is")
		depthWrite			// Where the alpha mask is "GE 128" or "greater than or equal to" write to depth buffer. 128 (this means >= 50% alpha)
		alphaFunc GE128			//   and depthWrite means record where the draw passes (the pixels drawn are marked with a 1 or 0)
	}
	{ // Shadow draw
		map $lightmap			// shadow draws are ...
		blendfunc filter			// draw limited to ...
		rgbGen identity
		tcGen lightmap
		depthFunc equal		// ... the parts of the textures that we drew in part 1.
	}
}

The importance of fence texture shaders is obvious for every fence or grate in a map.

fence1

Pictured: grate

fence2

Pictured: Hatch-like grated door that opens up

fence3

Pictured: security fence

Glass (Transparent Textures)

glass11

Now the examination of glass. It is possible to do glass like current Quake 1 engines do by specifying "alpha" "0.4" and making the brush into func_wall entity. That method will work in the Quake 3 map format.

The Quake 3 specific method uses a shader that allows glass windows to be part of the world and light and shadows done by the compiler treat the windows accordingly.

The "Quake 1" entity alpha method is less work.

However, if you want a rotating door with a glass window but the rest is solid metal, you want some of the door to be transparent (the glasss) and some of door to solid (the metal).

The Quake 3 toolset can handle this mixed solid/transparent scenario!

(Another example would be a func_train or func_plat with glass. A future tutorial will be curved func_train paths.)

And the likely there are only a few different kinds of glass you want, so if the glass shader is available it is just painting the brush with that texture shader.

glass black alpha 10
Texture: map textures/zz_liquids/glass_black_alpha_10.png (almost transparent)


The shader looks as follows. It specifies to use the image alpha channel (the transparency) to draw to screen (it "blends" it in).

// barely visible
textures/liquids/glass_black_alpha_10
{
	qer_editorimage textures/zz_liquids/glass_black_alpha_10.tga
	surfaceparm trans

	{
		map textures/zz_liquids/glass_black_alpha_10.tga
		blendFunc blend
	}
	{
		map $lightmap
		rgbGen identity
		tcGen lightmap
		blendfunc filter
	}
}

Notes:

  • Image file extensions specified in the shader text files are ignored. It traditionally says ".tga" because tga was the first widely used "millions of colors" image format and likely Quake 3 only used this file format.
  • Images with alpha channels should use the .png format with Quake3_Quake1 (*).

(*) DarkPlaces tga loader is very strict and literal to specifications and many image editors (even Irfanview) write tga transparency in a way that technically does not conform to specifications and DarkPlaces does not recognize the alpha channel properly.

The Quake 3 map compile tools -- although it started with Quake 3, continually evolved over the years as a number of games used the map format. The tools were worked on continually for a decade and perhaps longer.

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: