//
and goes to the end of the line. Anything withing a comment is ignored. Note that all names and identifiers are case-sensitive. You may also check the glfx grammar.
A variable is identified by its name, which may consit of characters, digits (not at the begining) and _
. Variables may have following types:
float
- floating point value (e.g. "123", "-3.4", "1e-2") vec2
- 2-dimensional vector (e.g "(1, 2)") vec3
- 3-dimensional vector (e.g "(1, 2, 3)") vec4
- 4-dimensional vector (e.g "(1, 2, 3, 4)") texture1d
- 1-dimensional texture texture2d
- 1-dimensional texture texture3d
- 1-dimensional texture texturecube
- cube map texture vertex_shader
- GLSL vertex shader fragment_shader
- GLSL fragment shader program
- GLSL program
You may specify param
before the definition of a variable. This causes the variable to be accessible through effect programming interface (it is called effect parameter then). Note that param
modifier is currently not allowed on vertex_shader
, fragment_shader
and program
types.
You may specify a variables value: explicitly (for float
, vec2
, vec3
, vec4
) or by calling one of the following functions:
texture1d load_texture1d(string fileName)
load a texture from file texture2d load_texture2d(string fileName)
load a texture from file texture3d load_texture3d(string fileName)
load a texture from file texturecube load_texturecube(string fileName)
load a texture from file vertex_shader load_vertex_shader(string fileName)
load and compile vertex shader from file vertex_shader compile_vertex_shader(string shaderSource)
compile vertex shader from string fragment_shader load_fragment_shader(string fileName)
load and compile fragment shader from file fragment_shader compile_fragment_shader(string shaderSource)
compile fragment shader from string program link_program(list progElements)
links a program. The list
is a ,
separated list of the following elements: load_vertex_shader
, compile_vertex_shader
, load_fragment_shader
, compile_fragment_shader
functions bind_uniform(variable, string uniformName)
binds program uniform with the given variable
bind_attribute(int attrbId, string attribName)
binds vertex attribute with the attribute name in program bind_sampler(int samplerNum, string samplerName)
binds texture unit samplerNum
with program sampler
A ;
is required at the end of each definition.
Examples of variable definition:
texture2d texBrick = load_texture2d("brick.jpg"); param float time = 0; vec3 v = (2, 3.5, 1); param vec4 lightDir; fragment_shader fs3 = load_fragment_shader("test.frag"); program prog3 = link_program(vs3, fs3, bind_uniform(time, "time"));
A technique is identified with its name, which has to obey the same rules as a variable. A technique consists of one or more render passes. Each pass is a collection of render states, which may either have explicit value, or reference a variable. Check the glfx render states reference for more information. Referencing a variable has the following form <varName>
.
Examples of techniques:
technique Tec0 { pass { FrontPolygonMode = LINE; BackPolygonMode = LINE; CullFace = NONE; } }
technique Tec3 { pass { Program = <prog3>; } }