News Design Artwork Photos Articles
Creative Commons All use of my digital work is covered by this Creative Commons Deed.
Please do not use any of my work for commercial purposes, thank you.
 Phong Shading Previous Page Next Page
Process Phong Shading is a compiler only feature which is enabled via special shader commands. In order to have certain brushwork use Phong Shading the relevant surfaces must use a shader.

A Phong shader should contain special commands for the compiler and also point to the correct texture which will be used on the brushwork surfaces. The shader is stored in a shader file located in the 'scripts' directory. All shader files are stored in a plain text format and can be edited by any text editor.

The compiler checks each brush surface in the map for shaders. If the compiler finds the relevant special compiler commands inside of a shader then Phong Shading is enabled on the brush surface edges.
 Phong Shader    
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
03
04
05
06
07
08
09
10
11
12
13
14
textures/myrock/wall01 { q3map_nonplanar q3map_shadeangle 60 qer_editorimage textures/myrock/wall01_phong.tga { map $lightmap rgbGen identity } { map textures/myrock/wall01.tga blendFunc filter } }

Line 3 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 4 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 5 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.

 Where do all the bits go?    
Everything has to go in a certain place in order for Phong Shading to work correctly. Here is a quick list of things you need to create and where to put them:

The organic texture needs to be put into the textures directory and stored in a sub-directory with a unique name. Often the sub-directory is named after the map it is being used in so that it does not conflict with anyone else's work.

ie. textures \ myrockmap \ myrock.tga

The Phong shader needs to be created and stored in the scripts directory. Take the example shader listed above and change lines 4, 8 and 14 to point to the texture above. Save the shader in a shader file and name it after the map in which it will be used. (Like the sub-directory for the texture)

The file must have the correct extension of '.shader' so that it is recognised by the compiler and engine as a valid shader file.

ie. scripts \ myrockmap.shader

Every scripts directory has a text file which contains a list of all the other shader files used by the game. This file is usually called 'shaderlist.txt'. Open this file up and add the name of your new shader file to the list. Save the changes back to the original file.

The file 'shaderlist.txt' is unique to your game / editor setup and does not need to be distributed with your final work.
Prev Page Next Page
Mememe
Articles 
Level Design -
GameDev Advice -
Creating Terrain -
Terrain Blending -
Rockwall Corridors -
Rockwall Detail -
2 Point Clipping -
Phong Shading -
3D Puzzle Scripting -
Triggerable Shaders -
RTCW Scripting -
Scripted Doors -
Basic Lift -
Advanced Lift -
Cooking -
Apple Crumble -
This site has been cobbled together by Simon O'Callaghan
Contact Information: Simon O'Callaghan
All content is Copyright © 2000-2024
Hosted by ApisNetwork