Skip to content

Commit

Permalink
WebGPURenderer: fix rendering to depth textures with multiple color a…
Browse files Browse the repository at this point in the history
…ttachments (MRT - WGSL) (#28523)

* handle mrt with depth

* rename builder method

---------

Co-authored-by: aardgoose <angus.sawyer@email.com>
  • Loading branch information
aardgoose and aardgoose committed May 30, 2024
1 parent f52b71b commit 71f8579
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
6 changes: 1 addition & 5 deletions examples/jsm/nodes/core/OutputStructNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ class OutputStructNode extends Node {

generate( builder, output ) {

const nodeVar = builder.getVarFromNode( this );
nodeVar.isOutputStructVar = true;

const propertyName = builder.getPropertyName( nodeVar );

const propertyName = builder.getOutputStructName();
const members = this.members;

const structPrefix = propertyName !== '' ? propertyName + '.' : '';
Expand Down
10 changes: 6 additions & 4 deletions examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,16 @@ class GLSLNodeBuilder extends NodeBuilder {

getPropertyName( node, shaderStage ) {

if ( node.isOutputStructVar ) return '';

return super.getPropertyName( node, shaderStage );

}

getOutputStructName() {

return '';

}

buildFunctionCode( shaderNode ) {

const layout = shaderNode.layout;
Expand Down Expand Up @@ -277,8 +281,6 @@ ${ flowData.code }

for ( const variable of vars ) {

if ( variable.isOutputStructVar ) continue;

snippets.push( `${ this.getVar( variable.type, variable.name ) };` );

}
Expand Down
12 changes: 12 additions & 0 deletions examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,12 @@ class WGSLNodeBuilder extends NodeBuilder {

}

getOutputStructName() {

return 'output';

}

_getUniformGroupCount( shaderStage ) {

return Object.keys( this.uniforms[ shaderStage ] ).length;
Expand Down Expand Up @@ -659,6 +665,10 @@ ${ flowData.code }

}

const builtins = this.getBuiltins( 'output' );

if ( builtins ) snippets.push( builtins );

return snippets.join( ',\n' );

}
Expand All @@ -679,6 +689,8 @@ ${ flowData.code }

snippets.push( snippet );

snippets.push( `\nvar<private> output : ${ name };\n\n`);

}

return snippets.join( '\n\n' );
Expand Down

0 comments on commit 71f8579

Please sign in to comment.