Blocks

A PFX file is composed of several different types of blocks

This section outlines the structure of the various blocks which make up a PFX.

Each block contains a number of keywords which define the properties of that block. These keywords can be set to different valid values. This section will explain all of the available keywords and their potential associated values.

Blocks can also contain sub-blocks which contains extra information. These sub-blocks will be explained in detail when examining the relevant block.

An example of part of a PFX file is shown below:
// Comments can be used in PFX files as a handy way to describe the purpose of each of the blocks.
// This is a standard PFX header block.
// Click the text of any block to find out more.
[HEADER]	
	VERSION		00.00.00.00	
	DESCRIPTION TestPFXFile: Demonstrating what a PFX file looks like. 	
	COPYRIGHT	Imagination Technologies Ltd.	
[/HEADER]

// This is an effect block. It describes the entire effect with references to other types of blocks.
// Multiple effects can be embedded in a single PFX file.
[EFFECT]
	NAME exampleEffect

	ATTRIBUTE       inVertex	POSITION
	ATTRIBUTE	inNormal	NORMAL
	
	UNIFORM MVPMatrix WORLDVIEWPROJECTION
	UNIFORM LightColor LIGHTCOLOR
	UNIFORM sLightMap TEXTURE0
	TEXTURE 0 cat
	TARGET COLOR<0> exampleTarget

	VERTEXSHADER SphereVertexShader
	FRAGMENTSHADER SphereFragmentShader
[/EFFECT]

// This is a texture block which describes a particular texture that is going to used in the effect.
[TEXTURE]
       // Keyword               // Value
	NAME			cat
	PATH			cat_texture.pvr
	MINIFICATION	      LINEAR
	MAGNIFICATION	     LINEAR
	MIPMAP		     NEAREST
	WRAP_S		     CLAMP
	WRAP_T		     CLAMP
[/TEXTURE]

// This is a target block which specifies a surface to which an EFFECT block can render. 
[TARGET]
       NAME             exampleTarget
       MINIFICATION     LINEAR
       MAGNIFICATION    LINEAR
	MIPMAP   	 NONE
	RESOLUTION       128 128
	WRAP_S	    REPEAT
	WRAP_T	    REPEAT
       SURFACETYPE      RGBA8888
[/TARGET]

// These are two simple shader blocks with GLSL code for a simple textured sphere.
[VERTEXSHADER]
	NAME 		SphereVertexShader

	// LOAD GLSL AS CODE
	[GLSL_CODE]
		attribute highp   vec3  inVertex;
		attribute mediump vec3  inNormal;
		uniform highp   mat4  MVPMatrix;
		varying mediump vec3   ReflectDir;

		void main()
		{
			// Transform position
			gl_Position = MVPMatrix * vec4(inVertex, 1.0);

			// Pass the inverse of the normal (to map into the cubamap)
			ReflectDir = -inNormal;
		}
	[/GLSL_CODE]
[/VERTEXSHADER]

[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]