Shader¶
Classic Q3A .shader files - Traditional Quake 3 Arena-style shader definitions that define how textures appear in-game.
Location¶
The convention is to place shaders in either
scriptsOr
fxshaders(for textures used in fx)
Format¶
shader_name
{
// Global shader parameters
parameter value
// Stage 1
{
map texture/path
// Stage-specific parameters
}
// Stage 2 (optional)
{
map textures/my_overlay
// Stage-specific parameters
}
}
shader2_name
{
// ...
}
Common Shader Patterns¶
Some common patterns for shaders for different purposes from the game files
Standard Lit Texture¶
shader_name
{
{
map textures/path/texture
rgbGen exactVertex
nextbundle
map $lightmap
}
}
Transparent Texture¶
texture_name
{
surfaceparm trans
{
map textures/path/texture
blendFunc blend
rgbGen vertex
}
}
Static Water Shader¶
Basic static water with scrolling texture and lightmap:
textures/sfx/stalingradwater
{
qer_editorimage env/watercolor_dn
tessSize 512
q3map_globaltexture
surfaceparm trans
surfaceparm nonsolid
surfaceparm water
surfaceparm nolightmap
surfaceparm noshadow
sort water
{
map textures/sfx/damwater.jpg
tcMod Scroll .05 0
tcMod scale 4 4
rgbGen constlighting ( 0.65 0.68 0.69 )
}
{
map textures/sfx/damwateroverlay.jpg
tcMod scroll -0.01 .01
tcMod scale 2 2
tcMod turb 1.03 0.2 1.03
rgbGen exactVertex
blendFunc add
nextbundle
map textures/sfx/damwateroverlay.jpg
tcMod scroll 0.02 .02
tcMod scale 4 4
tcMod turb 0.01 0.2 0.03
}
}
River/Flowing Water Shader¶
Advanced river water with normal mapping and reflections:
textures/sfx/stalingradwater_pj
{
qer_editorimage textures/sfx/wave_bump
tessSize 256
deformVertexes wave 100 sin 2 2 0 .25
deformVertexes syncNormal 0.25
// For high-end cards (4+ texture units)
{
requires GL_MAX_TEXTURE_UNITS_ARB >= 4
requires GL_ARB_texture_cube_map
requires GL_ARB_texture_env_combine
requires GL_ARB_texture_env_dot3
rgbGen identity
map heightToNormal textures/sfx/wave_bump
tcMod scale .03125 .03125
tcMod scroll .0025 .00125
nextbundle
map heightToNormal textures/sfx/wave_bump
tcMod scale -.03125 -.03125
tcMod scroll .00125 -.0025
texEnvCombine
{
const = ( 0.5 0.5 0.5 0.5 )
rgb = INTERPOLATE_ARB(Cp, Ct, Ac)
}
nextbundle
cubemap $renormalize
tcGen sunHalfAngle
tcMod bumpmapFrame
texEnvCombine
{
rgb = DOT3_RGB_ARB(Cp, Ct)
}
nextbundle
map $whiteimage
texEnvCombine
{
const = ( .32 .36 .4 ) * identityLighting
rgb = MODULATE(Cp, Cc)
}
}
// For mid-range cards (3 texture units)
{
requires GL_MAX_TEXTURE_UNITS_ARB == 3
requires GL_ARB_texture_cube_map
requires GL_ARB_texture_env_combine
requires GL_ARB_texture_env_dot3
rgbGen identity
alphaGen constLighting .37
blendFunc GL_SRC_ALPHA GL_ZERO
depthWrite
map heightToNormal textures/sfx/wave_bump
tcMod scale .03125 .03125
tcMod scroll .00025 .00125
nextbundle
map heightToNormal textures/sfx/wave_bump
tcMod scale -.03125 -.03125
tcMod scroll .00025 -.00125
texEnvCombine
{
const = ( 0.5 0.5 0.5 0.5 )
rgb = INTERPOLATE_ARB(Cp, Ct, Ac)
}
nextbundle
cubemap $renormalize
tcGen sunHalfAngle
tcMod bumpmapFrame
texEnvCombine
{
rgb = DOT3_RGB_ARB(Cp, Ct)
alpha = REPLACE(Af)
}
}
// Base water color for all cards
{
requires GL_MAX_TEXTURE_UNITS_ARB >= 3
requires GL_ARB_texture_cube_map
requires GL_ARB_texture_env_combine
requires GL_ARB_texture_env_dot3
map textures/sfx/stalinriver.jpg
rgbGen identity
alphaGen constLighting .3
blendFunc GL_SRC_ALPHA GL_ONE
tcMod scale .25 .25
tcMod scroll -.0375 .0375
nextbundle
cubemap env/stalingrad
tcgen reflection
alphagen const .25
blendFunc blend
}
}
Sky Shader¶
Basic sky shader with environment mapping¶
textures/sky/chateau
{
qer_editorimage textures/sky/chateau.tga
surfaceparm sky
surfaceparm nolightmap
surfaceparm noimpact
surfaceparm nomarks
skyParms env/chateau 512 -
sunfile chateau
}
Advanced sky with fog and multiple layers¶
textures/sky/test01
{
qer_editorimage textures/sky/topclouds.tga
surfaceparm sky
surfaceparm nolightmap
surfaceparm noimpact
surfaceparm nomarks
surfaceparm nodlight
q3map_globaltexture
q3map_lightsubdivide 512
q3map_sun 1.0 0.8 0.7 100 220 55
skyParms full 200 -
fogvars ( .7 .7 .55 ) .000040
skyfogvars ( .7 .7 .55 ) .00040
{
map textures/skies/newclouds.tga
tcMod scroll -0.00025 -0.00075
tcMod scale 6 6
depthWrite
}
}
Night sky with stars¶
textures/sky/starfield
{
qer_editorimage textures/sky/starfield.tga
surfaceparm sky
surfaceparm nolightmap
surfaceparm noimpact
surfaceparm nomarks
q3map_sun 1.0 0.8 0.7 100 220 55
skyParms env/starfield 512 -
fogvars ( .05 .05 .07 ) .00033
skyfogvars ( .05 .05 .07 ) .00035
}
Fire/Flame Shader¶
Animated fire texture shader¶
gfx/effects/animated/jh_animfire
{
sort additive
{
AnimMap 14
map gfx/effects/animated/jh_animfire1
map gfx/effects/animated/jh_animfire2
map gfx/effects/animated/jh_animfire3
map gfx/effects/animated/jh_animfire4
map gfx/effects/animated/jh_animfire5
map gfx/effects/animated/jh_animfire6
map gfx/effects/animated/jh_animfire7
blendFunc add
rgbGen vertex
tcmod scale -1 1
}
}
Static fire texture with scrolling mask¶
skins/firetexture
{
surfaceparm nonsolid
surfaceparm noshadow
deformVertexes flap s 2 sin 2 2 0 5
{
map skins/firetexture
blendfunc add
rgbGen identityLighting
nextbundle
map textures/sfx/firemask
}
{
map textures/sfx/firescroll
tcmod scroll -1 1.5
blendFunc add
nextbundle
map textures/sfx/firemask
}
}
Smoke Effects¶
Animated smoke column¶
textures/effects/smokecolumn
{
sort seethrough
{
animMap 17
map clamp gfx/effects/animated/smokecolumn1
map clamp gfx/effects/animated/smokecolumn2
map clamp gfx/effects/animated/smokecolumn3
map clamp gfx/effects/animated/smokecolumn4
map clamp gfx/effects/animated/smokecolumn5
map clamp gfx/effects/animated/smokecolumn6
map clamp gfx/effects/animated/smokecolumn7
map clamp gfx/effects/animated/smokecolumn8
map clamp gfx/effects/animated/smokecolumn9
map clamp gfx/effects/animated/smokecolumn10
map clamp gfx/effects/animated/smokecolumn11
map clamp gfx/effects/animated/smokecolumn12
map clamp gfx/effects/animated/smokecolumn13
map clamp gfx/effects/animated/smokecolumn14
map clamp gfx/effects/animated/smokecolumn15
map clamp gfx/effects/animated/smokecolumn16
map clamp gfx/effects/animated/smokecolumn17
blendFunc multiply
rgbGen vertex
}
}
Simple smoke particle¶
gfx/effects/dark_smoke
{
entityMergable
{
map /gfx/effects/dark_smoke
blendfunc blend
rgbGen vertex
}
}
Explosion Effects¶
Explosion smoke plume¶
gfx/effects/explosion/smokeplume1
{
entityMergable
{
map /gfx/effects/explosion/smokeplume1
blendfunc blend
rgbGen vertex
}
}
Impact Effects¶
Flesh impact¶
gfx/impact/flesh_hit1
{
entityMergable
{
map gfx/impact/flesh_hit1
blendfunc blend
rgbGen vertex
}
}
Spark impact (additive)¶
gfx/impact/sparkflash
{
entityMergable
sort additive
{
map gfx/impact/sparkflash
blendFunc GL_ONE GL_ONE
rgbGen vertex
}
}
Metal spark¶
gfx/impact/metal_spark1
{
entityMergable
sort additive
{
map gfx/impact/metal_spark1
blendFunc GL_ONE GL_ONE
rgbGen vertex
}
}
Weapon Effects¶
Muzzle flash¶
gfx/weaponfx/88muzflash1
{
entityMergable
sort additive
cull disable
{
map clamp gfx/weaponfx/88muzflash1
blendFunc GL_ONE GL_ONE
rgbGen vertex
}
}
Weapon trail¶
gfx/weaponfx/88runner
{
sort additive
cull disable
{
map clamp gfx/weaponfx/88runner
blendFunc GL_ONE GL_ONE
rgbGen vertex
}
{
map clamp gfx/weaponfx/88runner
blendFunc GL_ONE GL_ONE
rgbGen vertex
tcMod rotate 30
}
}
Rocket plume¶
gfx/misc/rocketplume
{
{
map /gfx/misc/rocketplume
blendfunc blend
tcMod transform -1 0 0 1 1 0
rgbGen vertex
}
}
Sun and Light Effects¶
Global sun¶
gfx/sun/global
{
nomipmaps
nopicmip
{
map clamp gfx/sun/global
blendFunc add
rgbGen identitylighting
}
}
Sun flare¶
gfx/sun/global_flare
{
nomipmaps
nopicmip
{
map clamp gfx/sun/global_flare
blendFunc gl_src_alpha gl_one
rgbgen vertex
alphaGen vertex
}
}
Moon¶
gfx/sun/moon_full
{
nomipmaps
nopicmip
{
map clamp gfx/sun/moon_full
blendFunc add
rgbGen identitylighting
}
}
Searchlight/Beam Effects¶
Light beam with gradient¶
skins/gradient1
{
surfaceparm nonsolid
surfaceparm noshadow
nopicmip
{
map clamp textures/sfx/gradient1
blendfunc blend
rgbGen identityLighting
rgbGen dot 0 1.5
}
{
map textures/sfx/dustair
tcmod scroll 0 0.1
blendFunc add
}
}
Searchlight beam with autosprite¶
skins/searchlight_beam
{
surfaceparm nonsolid
surfaceparm noshadow
DeformVertexes autosprite2
{
requires GL_ARB_texture_env_add
map clamp skins\searchlight_beam
rgbGen identityLighting
blendfunc add
}
}
Caustic/Underwater Effects¶
Sewer caustics with distortion¶
textures/sfx/sewercaustic
{
qer_editorimage textures/denmark/walls/brick@sewerblue_wall1
nopicmip
// For cards with 2 TMUs
{
requires GL_MAX_TEXTURE_UNITS_ARB == 2
depthwrite
map textures/sfx/sewercaustic.tga
tcMod scroll -0.07 .05
tcMod scale 2 2
tcMod turb 0.11 0.2 0.03
nextbundle
map textures/sfx/sewercaustic.jpg
tcMod scroll 0.05 -0.05
tcMod scale 1 1
tcMod turb 0.10 0.2 0.20
}
{
requires GL_MAX_TEXTURE_UNITS_ARB == 2
depthfunc equal
rgbGen exactVertex
map $lightmap
blendFunc filter
}
// For cards with 3+ TMUs
{
requires GL_MAX_TEXTURE_UNITS_ARB >= 3
depthwrite
map textures/sfx/sewercaustic.tga
tcMod scroll -0.07 .05
tcMod scale 2 2
tcMod turb 0.11 0.2 0.03
nextbundle
map textures/sfx/sewercaustic.jpg
tcMod scroll 0.05 -0.05
tcMod scale 1 1
tcMod turb 0.10 0.2 0.20
nextbundle
map $lightmap
blendFunc filter
}
// Final stage for all cards
{
depthfunc equal
map textures/denmark/walls/brick@sewerblue_wall1.jpg
rgbGen vertex
blendFunc add
nextbundle
map $lightmap
}
}
Sun Rays/God Rays¶
Sun rays effect¶
textures/sfx/sunray_sewer
{
qer_editorimage textures/sfx/sunray_sewer
surfaceparm nonsolid
cull none
nopicmip
{
map textures/sfx/sunray_sewer.jpg
tcMod scroll .05 0
blendFunc GL_ONE GL_ONE
}
{
map textures/sfx/dustmotes_sewer.jpg
tcMod scroll -0.05 .03
tcMod scale 2 4
tcMod turb 0.01 0.2 0.03
blendFunc GL_ONE GL_ONE
}
}
Wake/Water Splash Effects¶
Player wake in water¶
wake
{
{
map clamp textures/sfx/splashalpha.tga
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
rgbGen vertex
tcMod stretch sin 1 0.2 0 0.2
rgbGen wave sin 0.3 0.3 0 0.2
}
}
Animated wake¶
wakeAnim
{
{
map clamp textures/sfx/splashalpha.tga
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
rgbGen vertex
tcMod stretch sin 0 1 0 .25
}
}
Surface Effects (Bubbles, Froth)¶
Surface bubbles¶
gfx/effects/misc/surface_bubble
{
entityMergable
sort additive
{
map gfx/effects/misc/surface_bubble
blendFunc GL_ONE GL_ONE
rgbGen vertex
}
}
Surface froth¶
gfx/effects/misc/surface_froth
{
entityMergable
sort additive
{
map gfx/effects/misc/surface_froth
blendFunc GL_ONE GL_ONE
rgbGen vertex
}
}
Dust and Particle Effects¶
Dust sheet¶
gfx/effects/misc/dustsheet1
{
entityMergable
{
map /gfx/effects/misc/dustsheet1
blendfunc blend
rgbGen vertex
}
}
Snow sheet¶
gfx/effects/misc/snowsheet1
{
entityMergable
{
map /gfx/effects/misc/snowsheet1
blendfunc blend
rgbGen vertex
}
}
Water sheet¶
gfx/effects/misc/watersheet1
{
entityMergable
{
map clamp /gfx/effects/misc/watersheet1
blendfunc blend
rgbGen vertex
}
}
Special Surface Types¶
Cloth/Flag with animation¶
skins/russianboatflag
{
surfaceparm cloth
cull none
deformVertexes flap s 2 sin 2 3 0 5
{
map skins/russianboatflag
rgbGen lightingDiffuse
}
}
Spinning propeller¶
skins/stuka_prop
{
surfaceparm metal
cull none
{
map clamp skins/stuka_prop
tcMod rotate 5000
blendFunc blend
}
}
Metal with environment mapping¶
skins/stalin_statue
{
surfaceparm metal
nomipmaps
nopicmip
{
map textures/sfx/environmap_bronze.tga
tcgen environment
rgbgen lightingdiffuse
}
{
map skins/stalin_statue
blendFunc GL_ONE_MINUS_SRC_ALPHA GL_SRC_ALPHA
rgbgen lightingdiffuse
}
}
Common Utility Shaders¶
No-draw shader (invisible)¶
textures/common/nodraw
{
surfaceparm nodraw
surfaceparm nomarks
surfaceparm playerclip
surfaceparm monsterclip
surfaceparm vehicleclip
surfaceparm trans
}
Water clip (collidable water)¶
textures/common/water_clip
{
qer_editorimage textures/common/water.tga
surfaceparm water
surfaceparm playerclip
surfaceparm monsterclip
surfaceparm nodraw
}
Trigger/clip shaders¶
textures/common/aitrig
{
qer_trans 0.32
surfaceparm nodraw
surfaceparm nomarks
surfaceparm nonsolid
surfaceparm trans
surfaceparm trigger
}
Vehicle clip¶
textures/common/vehicleclip
{
qer_trans 0.3
surfaceparm metal
surfaceparm nodraw
surfaceparm nomarks
surfaceparm nonsolid
surfaceparm vehicleclip
surfaceparm trans
}
Dlight (Dynamic Light) Shader¶
dlightshader
{
nofog
{
map $dlight
rgbGen exactVertex
blendFunc GL_DST_COLOR GL_ONE
texGen lightmap
depthFunc equal
}
}
Shadow Shader¶
markShadow
{
nofog
polygonOffset
{
map textures/sfx/shadow_soft.tga
blendFunc GL_ZERO GL_ONE_MINUS_SRC_COLOR
rgbGen exactVertex
}
}
2D/UI Shaders¶
Console background¶
console
{
{
map $whiteimage
rgbGen constLighting ( 0.15 0.15 0.15 )
}
}
Lagometer (netgraph)¶
lagometer
{
nopicmip
{
map gfx/2d/lag.tga
}
}
View fade (black)¶
viewFadeBlack
{
sort nearest
{
map *white
blendFunc GL_ZERO GL_ONE_MINUS_SRC_ALPHA
rgbGen wave square 0 0 0 0
alphaGen entity
}
}
View blood blend¶
viewBloodBlend1
{
sort nearest
{
map gfx/2d/viewblood1.tga
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
rgbGen identityLighting
alphaGen vertex
}
}
White shader (default)¶
white
{
{
map *white
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
rgbGen vertex
}
}
Terrain with Alpha Blending¶
Alpha-blended terrain (grass, foliage)¶
textures/normandy/ground/trench_base
{
surfaceparm grass
surfaceparm noncolliding
polygonOffset
qer_editorimage textures/normandy/ground/dirt@trench_goundbase.tga
{
map textures/normandy/ground/dirt@trench_goundbase
rgbGen exactVertex
alphagen vertex
blendFunc blend
nextbundle
map $lightmap
blendFunc filter
}
}