Mapping manual/Shaders

< Mapping manual

370pages on
this wiki

What are shaders Edit

Shaders are short text scripts which define the properties of a surface as it appears and functions in a world environment (in this case, the game world).[1] In Quake III these shaders are unrelated to programmable shaders found on GPUs or the directx shaders. QIII shaders aren't really a shading language used in modern games, but it has some opengl fixed functions to perform some basic operations such as alpha blends, alpha transparencies, scrolls or lightmaps.

A shader file consists of a series of surface attribute and rendering instructions formatted within braces: { and }.[2] It uses a syntax similar to the C programming language.

Limitations and common usages Edit

With shaders it's possible to:[3]

  • Make surfaces/volumes behave in certain ways ingame (water, lava, nonsolid, etc..)
  • Blend multiple textures together in various ways
  • Create surface sprites (useful for grass etc.)
  • Create blended terrain
  • Create scrolling, rotating textures.
  • Make textures glow ingame
  • Provide lighting to your map (light-emitting shaders)
  • Combinations of the above

It's important to note that, since these shaders here have no programmable functions, every texture property or parameter is fixed, static. QIII doesn't support dynamic shaders that affect / are affected by the world around, no realtime reliefs, no realtime shadow casting, no per pixel specularity / reflectivity or refractivity / bumps, etc. At best multiple pre-rendered textures could form an animated shader to simulate some dynamic effect.

Shader filenaming and conventions Edit

By convention, the documents which contain these scripts usually have the same name as the texture set which contains the textures being modified. Several specific script documents have also been created to handle special cases, like liquids, sky and special effects.

The full route to mark a specific texture with properties is textures/folder/name.

To better order your textures it's a good idea to sort them in a subfolder of the textures folder. Note that in radiant, textures are listed in groups of folders per shader file, no two levels deep subfolders. This name doesn't need to match the texture's filename.

Basic syntax Edit

Shaders need to be referenced by the map editor, compiler (Q3Map2) and game engine. Each of them uses a different part of the shader. This is a basic shader example:[4]

	deformVertexes wave sin 0 3 0 0.1
	q3map_tessSize 64
	surfaceparm lava
	qer_editorimage textures/common/lava.tga
		map textures/common/lava.tga
  • Line 1 is the shader name.
  • Line 3 is a General shader keyword. This keyword affects all the stages of this shader. It's the equivalent of Global Variables in programming languages.
  • Line 4 is a compiler-specific keyword. These keywords tell the the behaviour of a shader to the compiler.
  • Line 5 is a compiler-specific surface parameter keyword. These keywords tell the behaviour of a surface of the shader to the compiler.
  • Line 6 is an editor-specific keyword. These keywords tell the behaviour of a shader to the map editor.
  • Line 8 is a Stage-specific keyword. It affects only the stage it's placed on. It's the equivalent of Local Variables in programming languages.

Keywords Edit


Notes Edit

  1. Wikibooks' Shaders
  2. Wikibooks' Shader Syntax
  3. Wikibooks' What Shaders Can Do
  4. Q3MAP2 Shader Manual by Obsidian and ydnar

External links Edit

<< Previous (Creating dynamic features) Mapping manual (Terrains and liquids) Next >>

OpenArena's Mapping manual
Prologue /// Pre-mapping stage - Map gameplay /// Choosing an editor /// Your first map
Brush manipulation - 2D/3D clipping /// Curve manipulation /// Textures /// Introduction to Entities
Lighting - Advanced lighting /// Weapon/Item placement /// Triggers and movers - Dynamic features
Shaders /// Terrains and liquids /// Mapmodels /// Sounds /// Gametype support
Optimization and Troubleshooting - Hint brushes - Bot play - Troubleshooting
Final touches /// Compilation & packaging
Glossary of terms - Advanced features - Modelling a map - Editor differences - Default assets (Textures/Models/Sounds) - GPL

Around Wikia's network

Random Wiki