Skip to content

Commit

Permalink
WGSLNodeBuilder: XOR
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag committed Dec 2, 2023
1 parent f08d012 commit fd57e8d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const supports = {
instance: true
};

const wgslFnOpLib = {
'^^': 'threejs_xor'
};

const wgslTypeLib = {
float: 'f32',
int: 'i32',
Expand Down Expand Up @@ -69,6 +73,13 @@ const wgslMethods = {
};

const wgslPolyfill = {
threejs_xor: new CodeNode( `
fn threejs_xor( a : bool, b : bool ) -> bool {
return ( a || b ) && !( a && b );
}
` ),
lessThanEqual: new CodeNode( `
fn threejs_lessThanEqual( a : vec3<f32>, b : vec3<f32> ) -> vec3<bool> {
Expand Down Expand Up @@ -312,6 +323,22 @@ class WGSLNodeBuilder extends NodeBuilder {

}

getFunctionOperator( op ) {

const fnOp = wgslFnOpLib[ op ];

if ( fnOp !== undefined ) {

this._include( fnOp );

return fnOp;

}

return null;

}

getUniformFromNode( node, type, shaderStage, name = null ) {

const uniformNode = super.getUniformFromNode( node, type, shaderStage, name );
Expand Down

0 comments on commit fd57e8d

Please sign in to comment.