CC3PFXShaderSemantics Class Reference
Inherits from | CC3ShaderSemanticsByVarName : CC3ShaderSemanticsBase : NSObject |
Declared in | CC3PFXResource.h CC3PFXResource.mm |
Overview
CC3PFXShaderSemantics provides a mapping from the PFX semantic names declared in a PFX effect within a PFX effects file, and the standard semantics from the CC3Semantic enumeration.
GLSL shader code loaded from a PFX effect can mix custom semantics defined within the PFX effect with standard default semantics defined by the semantic delegate associated with the program matcher. If a GLSL variable cannot be configured based on a semantic definition for its name within the PFX effect, configuration of the variable is delegated to the standard semantic delegate at CC3ShaderProgram.shaderMatcher.semanticDelegate. It is even possible to load shaders that use only standard semantic naming, without having to define any semantics within the PFX effect.
This is an abstract implementation. Subclasses can override the semanticForPFXSemanticName: method for simple name-based mapping, or can override the resolveSemanticForVariableConfiguration: for more complex mapping.
Tasks
Other Methods
-
– populateWithVariableNameMappingsFromPFXEffect:
-
– resolveSemanticForVariableConfiguration:
-
– semanticForPFXSemanticName:
Other Methods
Instance Methods
configureVariable:
Overridden to allow default naming semantics to be combined with PFX-defined semantics.
- (BOOL)configureVariable:(CC3GLSLVariable *)variable
Declared In
CC3PFXResource.mm
populateWithVariableNameMappingsFromPFXEffect:
Populates this instance with the mappings between variable names and semantics defined in the specified PFX effect. In the process of doing so, the semantic of each variable is resolved from the PFX semantic name of the variable configuration.
- (void)populateWithVariableNameMappingsFromPFXEffect:(CC3PFXEffect *)pfxEffect
Discussion
For each variable configuration in the variables property of the specified PFX effect, this method invokes the resolveSemanticForVariableConfiguration: and addVariableConfiguration: methods to resolve the variable configuration and add it to this semantic mapping.
This method is invoked automatically during the parsing of the PFX file.
Declared In
CC3PFXResource.h
resolveSemanticForVariableConfiguration:
If the semantic property of the specified variable configuration has not already been set, it is set by resolving it from the PFX semantic name of the specified variable configuration.
- (BOOL)resolveSemanticForVariableConfiguration:(CC3PFXGLSLVariableConfiguration *)pfxVarConfig
Discussion
Returns whether the semantic has been resolved. Subclasses that override this method can first invoke this superclass implementation, and then use the return value to resolve any custom semantics.
The default behaviour is to invoke the semanticForPFXSemanticName: method with the value of the pfxSemanticName property of the specified variable configuration, and if it returns a valid semantic value, the semantic value is set in the specified variable configuration and this method returns YES. If the semanticForPFXSemanticName: method returns kCC3SemanticNone, the semantic of the specified variable configuration is not set, and this method returns NO.
Declared In
CC3PFXResource.h
semanticForPFXSemanticName:
Returns the semantic value corresponding the the specified PFX semantic name, or returns kCC3SemanticNone if the semantic could not be determined from the PFX semantic name.
- (GLenum)semanticForPFXSemanticName:(NSString *)semanticName
Discussion
This implementation does nothing and simply returns kCC3SemanticNone. Subclasses will override.
Declared In
CC3PFXResource.h