Instance Methods | Properties | List of all members
<CC3ShaderMatcher> Protocol Reference

#import <CC3ShaderMatcher.h>

Inheritance diagram for <CC3ShaderMatcher>:
Inheritance graph

Instance Methods

(CC3ShaderProgram *) - programForMeshNode:
(CC3ShaderProgram *) - pureColorProgramMatching:
- Instance Methods inherited from <CC3Object>
(id) - asWeakReference
(NSString *) - fullDescription
(id) - resolveWeakReference


id< CC3ShaderSemanticsDelegatesemanticDelegate

Detailed Description

CC3ShaderMatcher describes the behaviour required to match nodes and materials to an appropriate GL program for rendering a particular node.

Under OpenGL ES 2, every drawable mesh node requires a CC3ShaderProgram to be rendered. Typically, the application will deliberately assign a specific GL program to each material, through the shaderProgram or shaderContext properties of the material, and in some cases, this may be defined during model loading from resources.

When a model is created or loaded without a specific CC3ShaderProgram assigned, the material will retrieve an appropriate default shader from the shader cache. The shader cache maintains an instance of an implementation of this protocol and delegates to it to match the model to a suitable GL program.

Method Documentation

- (CC3ShaderProgram*) programForMeshNode: (CC3MeshNode *)  aMeshNode

Returns the shader program to use to draw the specified mesh node.

Returns a shader program selected from the characteristics of the mesh node and its material.

The returned program will be compiled and linked, and will have a semantics delegate assigned in the semanticDelegate property.

The implementation is responsible for determining how to match the specified mesh node to an appropriate GL program, and each implementation may have a different matching methodology.

Implementations are responsible for compiling, linking, and assigning a semantics delegate to the program.

- (CC3ShaderProgram*) pureColorProgramMatching: (CC3ShaderProgram *)  shaderProgram

Returns a shader program that matches the specified shader program, but renders the mesh in a single, solid color, instead of taking into consideration lighting, textures, etc.

The returned shaderProgram will be used for rendering the mesh node during paint-based node picking, or can be used for simply rendering the mesh while ignoring lighting, material and textures.

Implementation should ensure that the vertices will be rendered in the same position as the specified shader program. Typical implementations will return a shader program that uses the same vertex shader as the specified shader program, but has a fragment shader that renders in a single color.

Property Documentation

- (id<CC3ShaderSemanticsDelegate>) semanticDelegate

The semantic delegate that will be attached to any program created by this matcher.

The initial value of this property is an instance of CC3ShaderSemanticsByVarName that has been populated with default semantics by the populateWithDefaultVariableNameMappings method.

The documentation for this protocol was generated from the following file: