|
The following example is a Phong Shader with the special compiler commands. Directly after
the sample shader is an explaination of what each line does. If you want further information on
what Q3 Shaders are and how they work, then please have a look at the online
Q3 shader manual.
(01) //========================================================
(02) // myrock.shader
(03) //========================================================
(04) textures/myrock/wall01
(05) {
(06) q3map_nonplanar
(07) q3map_shadeangle 60
(08) qer_editorimage textures/myrock/wall01_phong.tga
(09) {
(10) map $lightmap
(11) rgbGen identity
(12) }
(13) {
(14) map textures/myrock/wall01.tga
(15) blendFunc filter
(16) }
(17) }
- Lines 1-3 : are just comments which can be ignored for the moment.
- Line 4 : is the name of the shader and is applied to all brushwork surfaces
which use this shader. Always use the full path when referring to shaders in the editor.
- Line 5,17 : The Q3 shader language is very strict on layout. The curly brackets are
used to specify where a section starts and finish and needs to be used in pairs. If you use an
open curly bracket to start something, then a closed curly bracket will be required to finish it.
- Line 6 : lets the compiler know that its OK to merge triangles that don't lie
in the same plane. (ie not at the same angle to each other) The default settings for the compiler
is to not merge triangles in different planes. Once the triangles are merged together the
shadows can be cast correctly across the edges.
- Line 7 : specifies the triangle edge angle at which the light will be diffused.
ie. The larger the specified value the more smooth all the triangles will appear as it
affects more edges. (Brushwork is always broken down into triangles by the compiler)
- Line 8 : is the image used to represent this shader in the editor. (2d, 3d and texture
preview panel) It is not used by the engine and often contains useful information for the
Level Designer only.
- Line 9-12 : is the light stage of the shader. If not specified the shader will not
have any light information (shadows) drawn.
- Line 13-16 : is the base texture used on the brushwork. Should always specify TGA
file format in Shaders regardless if the file exists or not. If the engine cannot find a TGA file it
will search for a JPG version instead.
|
|