Skip to content

Commit

Permalink
revision
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag committed Oct 20, 2023
1 parent 0048fd0 commit 076f124
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
18 changes: 14 additions & 4 deletions examples/jsm/nodes/display/ViewportNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ class ViewportNode extends Node {
let outX = output.x;
let outY = output.y;

if ( /top/i.test( scope ) && builder.isFlipY() ) outY = outY.oneMinus();
else if ( /bottom/i.test( scope ) && builder.isFlipY() === false ) outY = outY.oneMinus();

if ( /bottom/i.test( scope ) ) outY = outY.oneMinus();
if ( /right/i.test( scope ) ) outX = outX.oneMinus();

output = vec2( outX, outY );
Expand All @@ -98,7 +96,19 @@ class ViewportNode extends Node {

if ( this.scope === ViewportNode.COORDINATE ) {

return builder.getFragCoord();
let coord = builder.getFragCoord();

if ( builder.isFlipY() ) {

// follow webgpu standards

const resolution = viewportResolution.build( builder );

coord = `${ builder.getType( 'vec2' ) }( ${ coord }.x, ${ resolution}.y - ${ coord }.y )`;

}

return coord;

}

Expand Down
1 change: 0 additions & 1 deletion examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,6 @@ ${ flowData.code }

this.vertexShader = this._getWGSLVertexCode( shadersData.vertex );
this.fragmentShader = this._getWGSLFragmentCode( shadersData.fragment );
console.log( this.fragmentShader );

} else {

Expand Down

0 comments on commit 076f124

Please sign in to comment.