GtkRadiant/Shader Syntax

From Wikibooks, open books for an open world
< GtkRadiant
Jump to: navigation, search
« Shaders
What Shaders can do »

Shader Syntax


A shader file consists of a series of surface attribute and rendering instructions formatted within braces: { and }. It uses a syntax similar to the C programming language. All shaders and shader examples in this book will be commented, with the comments being the stuff behind the //. Since this is commented out by the engine as well, you may just leave it if you copy and paste the shader. Below you can see a simple example of syntax and format for a single process, including the Q3Map2 keywords and Surface Parameters, which follow the first bracket and a single bracketed stage:

 textures/liquids/lava-example //Shader Name
 { //Opens the main shader stage
 	deformVertexes wave sin 0 3 0 0.1 //General Shader Keywords
 	q3map_tessSize 64 //Q3Map2 Specific Shader Keywords
 	surfaceparm lava //Q3Map2 Specific Surface Parameter Shader Keywords
 	qer_editorimage textures/common/lava.tga //Editor Specific Shader Keywords
     { //Opens a substage
 	map textures/common/lava.tga //Stage Specific Shader Keywords
     } //Closes the substage
 } //Closes the main stage

Shaders need to be referenced by the map editor, compiler (Q3Map2) and game engine - each of which uses a different part of the shader. In the above example shader, the different sections are listed on the right.