Capítulo 416 de 859
This class represents a native shader function. It can be used to implement certain aspects of a node material with native shader code. There are two predefined TSL functions for easier usage.
wgslFn: Creates a WGSL function node.glslFn: Creates a GLSL function node.A basic example with one include looks like so:
const desaturateWGSLFn = wgslFn( `
fn desaturate( color:vec3<f32> ) -> vec3<f32> {
let lum = vec3<f32>( 0.299, 0.587, 0.114 );
return vec3<f32>( dot( lum, color ) );
}`
);
const someWGSLFn = wgslFn( `
fn someFn( color:vec3<f32> ) -> vec3<f32> {
return desaturate( color );
}
`, [ desaturateWGSLFn ] );
material.colorNode = someWGSLFn( { color: texture( map ) } );
Constructor
| Signature |
|---|
| `new FunctionNode( code : string, includes : Array.<Node>, language : 'js' |
Methods
| Method | Description |
|---|---|
.generateNodeType( builder : NodeBuilder ) : string | Returns the type of this function node. |
.getInputs( builder : NodeBuilder ) : Array.<NodeFunctionInput> | Returns the inputs of this function node. |
.getMemberType( builder : NodeBuilder, name : string ) : string | Returns the type of a member of this function node. |
.getNodeFunction( builder : NodeBuilder ) : NodeFunction | Returns the node function for this function node. |