Skip to content

Commit

Permalink
WebGPURenderer: Blending revision 1/2 (#26455)
Browse files Browse the repository at this point in the history
* Delete NodeRender.js

* TextureNode: Add .setUpdateMatrix()

* WebGPUPipeline: Add .getBlending()

* cleanup
  • Loading branch information
sunag authored Jul 19, 2023
1 parent 1d2e0ac commit fe2711f
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 425 deletions.
30 changes: 26 additions & 4 deletions examples/jsm/nodes/accessors/TextureNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class TextureNode extends UniformNode {
this.levelNode = levelNode;
this.compareNode = compareNode;

this.updateType = NodeUpdateType.FRAME;
this.updateMatrix = uvNode === null;

this.setUpdateMatrix( this.updateMatrix );

}

Expand All @@ -44,17 +46,29 @@ class TextureNode extends UniformNode {

}

getDefaultUV() {
getDefaultUV( uvNode = null ) {

const texture = this.value;

return uniform( texture.matrix ).mul( vec3( uv( texture.channel ), 1 ) );
if ( uvNode === null ) uvNode = uv( texture.channel );

return uniform( texture.matrix ).mul( vec3( uvNode, 1 ) );

}

setUpdateMatrix( value ) {

this.updateMatrix = value;
this.updateType = value ? NodeUpdateType.FRAME : NodeUpdateType.NONE;

return this;

}

construct( builder ) {

const properties = builder.getNodeProperties( this );
const texture = this.value;

//

Expand All @@ -66,7 +80,15 @@ class TextureNode extends UniformNode {

}

uvNode || ( uvNode = this.getDefaultUV() );
if ( this.updateMatrix ) {

uvNode = this.getDefaultUV( uvNode );

} else if ( ! uvNode ) {

uvNode = uv( texture.channel );

}

//

Expand Down
302 changes: 0 additions & 302 deletions examples/jsm/renderers/common/nodes/NodeRender.js

This file was deleted.

2 changes: 1 addition & 1 deletion examples/jsm/renderers/common/nodes/Nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class Nodes extends DataMap {

}

backgroundNode = texture( background, nodeUV );
backgroundNode = texture( background, nodeUV ).setUpdateMatrix( true );

} else if ( background.isColor !== true ) {

Expand Down
12 changes: 6 additions & 6 deletions examples/jsm/renderers/webgpu/utils/WebGPUConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,17 @@ export const GPUFilterMode = {
export const GPUBlendFactor = {
Zero: 'zero',
One: 'one',
SrcColor: 'src-color',
OneMinusSrcColor: 'one-minus-src-color',
Src: 'src',
OneMinusSrc: 'one-minus-src',
SrcAlpha: 'src-alpha',
OneMinusSrcAlpha: 'one-minus-src-alpha',
DstColor: 'dst-color',
OneMinusDstColor: 'one-minus-dst-color',
Dst: 'dst',
OneMinusDstColor: 'one-minus-dst',
DstAlpha: 'dst-alpha',
OneMinusDstAlpha: 'one-minus-dst-alpha',
SrcAlphaSaturated: 'src-alpha-saturated',
BlendColor: 'blend-color',
OneMinusBlendColor: 'one-minus-blend-color'
Constant: 'constant',
OneMinusConstant: 'one-minus-constant'
};

export const GPUBlendOperation = {
Expand Down
Loading

0 comments on commit fe2711f

Please sign in to comment.