GLSL Uniform

 
 
 

Category: Realtime > OpenGL

Shader Family: RealTime

Output: Realtime

The uniform qualifier is used to declare global variables whose values are the same across the entire primitive being processed.

Each uniform qualified variable you declare in your code needs a GLSL Uniform node connected in the render tree. The GLSL Uniform shader defines a single uniform parameter to be used by the GLSL Shader shader. When the GLSL Program shader is called, it will retrieve the list of uniforms defined and pass them to the vertex or fragment shader.

Sampler types (for example, sampler2D) declared as uniforms cannot use the GLSL Uniform node, instead they should be connected in the render tree using OGL Texture nodes.

For general information about working with this shader, see Setting Up a Unified GLSL Program [Realtime Shaders].

Uniform

Uniform Source

Custom: This is a custom variable declared in your shader code.

ICE Attribute: This is an ICE attribute available on your mesh or point cloud.

Variable

Enter the name of the variable as you defined it in your shader code.

Uniform Type

Specify the data type for the variable. Each data type displays the necessary controls for you to enter values.

Float: A single floating-point number.

Vector2: Vector of two floating-point numbers.

Vector3: Vector of three floating-point numbers.

Vector4: Vector of four floating-point numbers.

Color: Displays a color slider where you can specify values for the Red, Green, Blue and Alpha channels.

Matrix4x4: 4 x 4 matrix of floating-point numbers. You can access a matrix as an array of column vectors - that is, if transform is a mat4, transform[2] is a the third column of transform. The resulting type of transform[2] is vec4. Column 0 is the first column.

Attribute

When Uniform Source is set to ICE Attribute, you can select the ICE attribute whose value you want to specify from the attribute (second) drop-down list. All ICE attributes are displayed by default, but you can filter the ICE attributes by those available on the mesh or the point cloud by selecting a filter from the (first) filter selection drop-down list.

Note: ICE attributes must be initialized in your ICE tree in order for them to be available in the attribute drop-down list. See Getting and Setting Data in ICE Trees [ICE Fundamentals].