Skip to content

Commit

Permalink
ViewportNode revision
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag committed Nov 1, 2023
1 parent 5a25a00 commit 860e28a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
13 changes: 11 additions & 2 deletions examples/jsm/nodes/accessors/TextureNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ class TextureNode extends UniformNode {

generate( builder, output ) {

const { uvNode, levelNode } = builder.getNodeProperties( this );
const properties = builder.getNodeProperties( this );

let { uvNode } = properties;
const { levelNode } = properties;

const compareNode = this.compareNode;
const texture = this.value;
Expand All @@ -128,6 +131,12 @@ class TextureNode extends UniformNode {

}

if ( builder.isFlipY() && ( texture.isFramebufferTexture === true || texture.isDepthTexture === true ) ) {

uvNode = uvNode.setY( uvNode.y.fract().oneMinus() );

}

const textureProperty = super.generate( builder, 'property' );

if ( output === 'sampler' ) {
Expand Down Expand Up @@ -212,7 +221,7 @@ class TextureNode extends UniformNode {
textureNode.levelNode = levelNode;

return context( textureNode, {
getMIPLevelAlgorithmNode: ( textureNode, levelNode ) => levelNode
getMIPLevelAlgorithmNode: ( reqTextureNode, levelNode ) => levelNode
} );

}
Expand Down
13 changes: 5 additions & 8 deletions examples/jsm/nodes/display/ViewportNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ViewportNode extends Node {

getNodeType() {

return this.scope === ViewportNode.COORDINATE || this.scope === ViewportNode.VIEWPORT ? 'vec4' : 'vec2';
return this.scope === ViewportNode.VIEWPORT ? 'vec4' : 'vec2';

}

Expand Down Expand Up @@ -55,7 +55,7 @@ class ViewportNode extends Node {

}

setup( builder ) {
setup( /*builder*/ ) {

const scope = this.scope;

Expand All @@ -73,10 +73,7 @@ class ViewportNode extends Node {

} else {

const coordinateNode = vec2( new ViewportNode( ViewportNode.COORDINATE ) );
const resolutionNode = new ViewportNode( ViewportNode.RESOLUTION );

output = coordinateNode.div( resolutionNode );
output = viewportCoordinate.div( viewportResolution );

let outX = output.x;
let outY = output.y;
Expand All @@ -102,9 +99,9 @@ class ViewportNode extends Node {

// follow webgpu standards

const resolution = viewportResolution.build( builder );
const resolution = builder.getNodeProperties( viewportResolution ).outputNode.build( builder );

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

}

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

getFragCoord() {

return this.getBuiltin( 'position', 'fragCoord', 'vec4<f32>', 'fragment' );
return this.getBuiltin( 'position', 'fragCoord', 'vec4<f32>', 'fragment' ) + '.xy';

}

Expand Down

0 comments on commit 860e28a

Please sign in to comment.