Home Reference Source Repository
import SCNShadable from 'jscenekit/js/SceneKit/SCNShadable.js'
public interface | source

SCNShadable

Direct Implemented:

Methods for customizing SceneKit's rendering of geometry and materials using Metal or OpenGL shader programs.

See:

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

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

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 program: SCNProgram source

A program used when rendering the object.

See:

public shaderModifiers: Map<SCNShaderModifierEntryPoint, string> source

A dictionary of GLSL source code snippets for customizing the shader programs provided by SceneKit.

See:

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:

NameTypeAttributeDescription
symbol string

A GLSL uniform variable or attribute name.

block SCNBindingBlock
  • optional
  • default: null
  • nullable: true

A block to be called by SceneKit.

Return:

void

See:

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:

NameTypeAttributeDescription
symbol string

A GLSL uniform variable or attribute name.

block SCNBindingBlock
  • optional
  • default: null
  • nullable: true

A block to be called by SceneKit.

Return:

void

See:

public init(): void source

constructor

Return:

void