QuakeWiki
September 30, 2012

Material creation for DP

Quick notes by LordHavoc (in need of cleanup and completion!):

All texture files are optional except for diffuse, a q3 shader allows additional options to be set but is not required for common materials.

Contents

Diffuse Color + Alpha (Opacity)

textures/texturepackname/texturename.tga

Generally should have ambient occlusion baked into the color (in other words, the grooves are dark), but no shading.

NormalMap + Relief Height

textures/texturepackname/texturename_norm.tga

The normalmap is OpenGL-style with green pointing up (often normalmap tools call this “inverted”), matching Doom3/Quake4/etc behavior, but contrary to several other games.

The height channel is black for deep areas and white for being flush with the surface, the height is used only when offsetmapping (r_glsl_offsetmapping) or reliefmapping (r_glsl_offsetmapping_reliefmapping also on) are active.

For best results the height channel should be fairly smooth, no fine bumps, just the overall shape of the material.

Specular Color + Specular Exponent

textures/texturepackname/texturename_gloss.tga

The specular (gloss) color is full color and basically indicates how bright the specular reflection should when a light illuminates this surface, it should be black where you want the surface to look dull and bright where you want a shiny appearance.

For best results, color the gloss according to the material involved, for example plastic or car paint has a white specular color, copper has an orange specular color, gold has a yellow specular color, steel has a very slight blue tint to its otherwise white specular color, aluminum also has a very slight tint.

Generally the specular color should have ambient occlusion baked into the color (just like the diffuse does).

The alpha channel of this texture will multiply the specular exponent (r_shadow_glossexponent), white alpha will be sharp highlights, dark alpha produces very broad highlights very bright highlights, in general sharp highlights indicate metal or hard plastic materials, aluminum has a different specular hardness than steel, etc.

Glow color

textures/texturepackname/texturename_glow.tga

This is the luminous glow of the material, pretty much you want this to be black with color only where a light emitting part of the surface exists (for example a series of red dots for red LED lights).

Be sure not to have any glow color in the diffuse texture as it will not add up properly.

Alpha is unused at this time.

Reflection mask for cubemap environment mapping

texturename_reflect.tga – mask for the reflection, looks similar to gloss texture, basically this is where things will be shiny and what color of reflection (use orange for copper, yellow for gold, a slight blue tinted white color for steel, etc)

In shader: dpreflectcube map/mapname/reflect1

You can produce such a texture with this console command: envmap map/mapname/reflect1 512

Which will produce files such as:
map/mapname/reflect1px.tga map/mapname/reflect1py.tga map/mapname/reflect1pz.tga map/mapname/reflect1nx.tga map/mapname/reflect1ny.tga map/mapname/reflect1nz.tga

map/mapname/reflect1ft.tga map/mapname/reflect1rt.tga map/mapname/reflect1bk.tga map/mapname/reflect1lf.tga map/mapname/reflect1up.tga map/mapname/reflect1dn.tga

The first 6 are a cubemap, the last 6 are a skybox, keep one or the other set of files, you don’t need both.

Material description (.shader) file

In gamedir/scripts the engine will load all files with the extension .shader using a Quake3-compatible shader loader, however not all features will be utilized (for example it only supports one layer shaders, additional layers may be used to activate special behaviors – such as lightmapping – but will not be directly rendered).

The syntax of the Quake3-compatible .shader files is best explained by examples, so there are several here to look at.

Many additional features can be added to any shader with expected results, such as tcmod scroll 1 0 (makes a texture scroll in one direction), deformvertexes autosprite (makes a surface consisting of quads render as billboards facing the view), deformvertexes autosprite2 (makes a surface consisting of rectangular quads – not square – rotate around their long axis to face the view, useful for flame trail sprites and torch flames among other things)…

Lightmapped material

textures/texturepackname/texturename {

 {
   map $lightmap
   rgbGen identity
   tcGen lightmap
 }
 {
   map textures/texturepackname/texturename
   rgbGen identity
   blendFunc GL_DST_COLOR GL_ZERO
 }

}

Transparent additive-blend unlit material

textures/texturepackname/texturename {

 surfaceparm noimpact
 surfaceparm nolightmap
 surfaceparm nomarks
 surfaceparm nonsolid
 surfaceparm nodlight
 surfaceparm trans
 {
   map textures/texturepackname/texturename
   blendfunc add
   rgbgen identity
 }

}

Note: you can omit some of the surfaceparms (keep trans!) when making a model material rather than a map material.

Model material

textures/texturepackname/texturename {

 {
   map textures/texturepackname/texturename
   rgbgen lightingDiffuse
 }

}

Model material that does not cast shadows

textures/texturepackname/texturename {

 dpnoshadow
 {
   map textures/texturepackname/texturename
   rgbgen lightingDiffuse
 }

}

Invisible shadow-casting model material

textures/common/shadowmesh {

 dpshadow

}

Lightmapped material with reflection cubemap and dpmeshcollisions

textures/texturepackname/texturename {

 dpreflectcube textures/texturepackname/reflect1
 dpmeshcollisions
 {
   map $lightmap
   rgbGen identity
   tcGen lightmap
 }
 {
   map textures/texturepackname/texturename
   rgbGen identity
   blendFunc GL_DST_COLOR GL_ZERO
 }

}