Skip to content
19 changes: 17 additions & 2 deletions src/nodes/math/MathNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ class MathNode extends TempNode {
getInputType( builder ) {

const aType = this.aNode.getNodeType( builder );
const bType = this.bNode ? this.bNode.getNodeType( builder ) : null;
const cType = this.cNode ? this.cNode.getNodeType( builder ) : null;
const bType = ( this.bNode && this.bNode.isNode ) ? this.bNode.getNodeType( builder ) : null;
const cType = ( this.cNode && this.cNode.isNode ) ? this.cNode.getNodeType( builder ) : null;

const aLen = builder.isMatrix( aType ) ? 0 : builder.getTypeLength( aType );
const bLen = builder.isMatrix( bType ) ? 0 : builder.getTypeLength( bType );
Expand Down Expand Up @@ -152,6 +152,10 @@ class MathNode extends TempNode {

return builder.changeComponentType( this.aNode.getNodeType( builder ), 'bool' );

} else if ( method === MathNode.BITCAST ) {

return this.bNode;

} else {

return this.getInputType( builder );
Expand Down Expand Up @@ -239,6 +243,17 @@ class MathNode extends TempNode {

return builder.format( '( - ' + a.build( builder, inputType ) + ' )', type, output );


} else if ( method === MathNode.BITCAST ) {

const params = [];

params.push(
a.build( builder, inputType ),
);

return builder.format( `${ builder.getMethod( method ) }<${builder.getType( type )}>( ${params.join( ', ' )} )`, inputType, output );

} else {

const params = [];
Expand Down
3 changes: 1 addition & 2 deletions src/renderers/webgpu/nodes/WGSLNodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ const wgslMethods = {
equals_bvec2: 'tsl_equals_bvec2',
equals_bvec3: 'tsl_equals_bvec3',
equals_bvec4: 'tsl_equals_bvec4',
inversesqrt: 'inverseSqrt',
bitcast: 'bitcast<f32>'
inversesqrt: 'inverseSqrt'
};

// WebGPU issue: does not support pow() with negative base on Windows
Expand Down
Loading