EFFECT

The EFFECT block is used to describe an individual effect by referencing TEXTURE, TARGET, VERTEXSHADER, and FRAGMENTSHADER blocks

The EFFECT block is the primary block used to describe a PFX. It references other blocks which can contain textures, targets, and shaders, as well as containing a number of application-specific semantics. These semantics can be used by an application to identify the meaning of a given attribute. The meaning of the available keywords and valid sub-blocks are described below.

The available semantics for attributes and uniforms are described in PVRShaman PFX Semantics.

Table 1. Keywords

Keyword

Description

NAME

A text identifier for this effect.

ATTRIBUTE

Specifies GLSL attribute variable.

Format:

ATTRIBUTE varName SEMANTIC

  • varName references a variable as specified in the shader blocks.
  • SEMANTIC references an application-specific semantic.

UNIFORM

Specifies GLSL uniform variable.

Format:

UNIFORM varName SEMANTIC

  • varName references a variable as specified in the shader blocks.
  • SEMANTIC references an application-specific semantic.

TEXTURE

Specifies a texture name which will be bound to the given unit.

Format:

TEXTURE UNIT TextureName

  • UNIT specifies an integer-based texture unit to bind to.
  • TextureName references a TEXTURE block of a given name.

TARGET

Specifies a target which this effect will write to, instead of the default frame buffer. Two types of targets exist, colour targets and depth targets. Only colour target support is required to be compliant with this specification.

Format:

TARGET BUFFERTYPE<UNIT> TargetName

  • BUFFERTYPE can be of type COLOR or, optionally, DEPTH.
  • UNIT is an integer based value defining the buffer unit. Only 0 is required to be compliant with this specification.
  • TargetName references a TARGET block of a given name.

VERTEXSHADER

References a VERTEXSHADER block of a given name.

FRAGMENTSHADER

References a FRAGMENTSHADER block of a given name.

Table 2. Sub-blocks

Block

Description

ANNOTATION

A block containing plain-text which will be copied as-is into a text buffer, readable by the application.

Example code

[EFFECT]
	NAME ExampleEffect

	ATTRIBUTE       inVertex	POSITION
	ATTRIBUTE	inNormal	NORMAL
	ATTRIBUTE	inTexCoord     UV
	
	UNIFORM MVPMatrix WORLDVIEWPROJECTION
	UNIFORM LightPosition LIGHTPOSWORLD
	UNIFORM LightColor LIGHTCOLOR
      
       TEXTURE 0 exampleTexture

       TARGET COLOR<0> exampleTarget

	VERTEXSHADER exampleVertexShader
	FRAGMENTSHADER exampleFragmentShader
[/EFFECT]