SCNShadable
Direct Implemented:
Indirect Implemented:
Methods for customizing SceneKit's rendering of geometry and materials using Metal or OpenGL shader programs.
Member Summary
Public Members | ||
public |
A program used when rendering the object. |
|
public |
A dictionary of GLSL source code snippets for customizing the shader programs provided by SceneKit. |
Method Summary
Public Methods | ||
public |
handleBindingOfSymbolHandler(symbol: string, block: SCNBindingBlock): void Use this method to associate a block with a SceneKit object (geometry or material) to handle setup of an attribute or uniform variable in a custom SCNProgram shader associated with that object. |
|
public |
handleUnbindingOfSymbolHandler(symbol: string, block: SCNBindingBlock): void Use this method to associate a block with a SceneKit object (geometry or material) to handle cleanup related to an attribute or uniform variable in a custom SCNProgram shader associated with that object. |
|
public |
init(): void constructor |
Public Members
public shaderModifiers: Map<SCNShaderModifierEntryPoint, string> source
A dictionary of GLSL source code snippets for customizing the shader programs provided by SceneKit.
Public Methods
public handleBindingOfSymbolHandler(symbol: string, block: SCNBindingBlock): void source
Use this method to associate a block with a SceneKit object (geometry or material) to handle setup of an attribute or uniform variable in a custom SCNProgram shader associated with that object. SceneKit calls your block before rendering the object. In the block, you can execute any OpenGL commands or other code necessary for preparing your custom shader. For example, the following block updates the time uniform variable in a custom fragment shader for producing animated effects:CFTimeInterval startTime = CFAbsoluteTimeGetCurrent(); [myNode.geometry.firstMaterial handleBindingOfSymbol:@"time" usingBlock: ^(unsigned int programID, unsigned int location, SCNNode renderedNode, SCNRenderer renderer) { glUniform1f(location, CFAbsoluteTimeGetCurrent() - startTime); }]; This method is for OpenGL shader programs only. To bind custom variable data for Metal shader programs, use the handleBinding(ofBufferNamed:frequency:handler:) method.CFTimeInterval startTime = CFAbsoluteTimeGetCurrent(); [myNode.geometry.firstMaterial handleBindingOfSymbol:@"time" usingBlock: ^(unsigned int programID, unsigned int location, SCNNode renderedNode, SCNRenderer renderer) { glUniform1f(location, CFAbsoluteTimeGetCurrent() - startTime); }];
Params:
Name | Type | Attribute | Description |
symbol | string | A GLSL uniform variable or attribute name. |
|
block | SCNBindingBlock |
|
A block to be called by SceneKit. |
Return:
void |
public handleUnbindingOfSymbolHandler(symbol: string, block: SCNBindingBlock): void source
Use this method to associate a block with a SceneKit object (geometry or material) to handle cleanup related to an attribute or uniform variable in a custom SCNProgram shader associated with that object. SceneKit will call your block after rendering the object. In the block, you can execute any OpenGL commands or other code necessary for post-rendering tasks.This method is for OpenGL shader programs only. To bind custom variable data for Metal shader programs, use the handleBinding(ofBufferNamed:frequency:handler:) method.
Params:
Name | Type | Attribute | Description |
symbol | string | A GLSL uniform variable or attribute name. |
|
block | SCNBindingBlock |
|
A block to be called by SceneKit. |
Return:
void |