-
Notifications
You must be signed in to change notification settings - Fork 30
GenerateShader
Every shader in the game, from particles to halograms to water, all use something called a Shader Template
. This template serves as a foundation for the shader to define what constants that shader has. Each shader type has a different number of options available to that shader type, for example a terrain template typically has 6 options to choose from, while a general shader has between 10 and 11 options to choose from.
For this example we'll be looking at a generic shader type shader. The shader template we'll be looking at for demonstration purposes will be shaders\shader_templates\_3_2_0_1_1_2_0_0_0_1_0.rmt2
. Each number in the template name refers to a method defined in the associated render method definition(rmdf) tag, and the numbers' position is the actual shader option. Let's break this down real quick.
All information gathered from shaders\shader.rmdf
Render Method | Shader Option | Shader Type |
---|---|---|
Albedo | 3 | two_change_color |
Bump_Mapping | 2 | detail |
Alpha_Test | 0 | none |
Specular_Mask | 1 | specular_mask_from_diffuse |
Material_Model | 1 | cook_torrance |
Environment_Mapping | 2 | dynamic |
Self_Illumination | 0 | off |
Blend_Mode | 0 | opaque |
Parallax | 0 | off |
Misc | 1 | first_person_sometimes |
Distortion | 0 | off |
The first number in the template name, 3, is the shader type two_change_color
for the render method Albedo
, this means that the shader is expecting a change color texture constant with two color regions defined, by red and green channels specifically.
The second, 2, is the detail
shader type for the Bump_Mapping
render method. In this instance, the shader is given a bump_detail
texture constant which is a bump map meant to be tiled across the surface of the shader.
The third, 0, is the Alpha_Test
render method. Alpha_Test
is used to control the actual transparency of the shader, and in this instance the shader option is set to 0, which is opaque.
The fourth, 1, is the Specular_Mask
render method. This is used for defining the specularity of the shader, and option 1 specular_mask_from_diffuse
means the shader is grabbing the specularity from the alpha channel of the diffuse bitmap.
The fifth, 1, is the Material_Model
render method. This is used to determine the specific material type of the shader, in this instance using Cook_Torrance
which gives the shader standard specular constants in addition to a material_texture
texture constant which controls different facets of the shader.
The sixth, 2, is the Environment_Mapping
render method. This is used exclusively for cubemaps, to reflect the given cubemap in highly reflective parts of the shader. Dynamic
is a blend of the current maps' cubemap with the shaders set cubemap.
The seventh, 0, is the Self_Illumination
render method, which is used to map our luminous areas of the shader via texture constant. In this case, it is set to 0 so there is no illumination on this tag.
The eigth, 0, is the Blend_Mode
render method
Each of these has a variety of options to choose from, and the best way to figure out what you want to use is by browsing the render method definition (rmdf) and deciding which shader types best suit your needs for each render method option.
Every shader uses what are called constants, there are texture constants, real constants, boolean constants, and integer constants.
Texture constants are all the bitmap (bitm) references required by the shader to function.
Real constants are all the arguments that control different facets of the shader