VERTEXSHADER and FRAGMENTSHADER

Shader blocks are used to hold the GLSL code for the shaders used in an effect

VERTEXSHADER and FRAGMENTSHADER blocks contain the GLSL code for an effect. The code can either be embedded within the PFX file itself or be located elsewhere and referenced with a filename using the FILE keyword.

Table 1. Keywords

Keyword

Description

NAME

A unique identifier for this shader.

FILE

A file name of a text file containing valid GLSL code.

Table 2. Sub-blocks

Block

Description

GLSL_CODE

A block containing plain-text GLSL code.

Example code

[FRAGMENTSHADER] 
	NAME SphereFragmentShader 

	// LOAD GLSL AS CODE
	[GLSL_CODE]
		uniform samplerCube sLightMap;
		uniform lowp  vec3  LightColor;
		varying mediump vec3 ReflectDir;

		void main()
		{
			// Final colour is the modulaion of the base texture with the diffuse colour.
			gl_FragColor = (textureCube(sLightMap, ReflectDir)) * vec4(LightColor, 1.0);
		}
	[/GLSL_CODE]
[/FRAGMENTSHADER]