Skip to content

Commit fe2711f

Browse files
authored
WebGPURenderer: Blending revision 1/2 (mrdoob#26455)
* Delete NodeRender.js * TextureNode: Add .setUpdateMatrix() * WebGPUPipeline: Add .getBlending() * cleanup
1 parent 1d2e0ac commit fe2711f

File tree

5 files changed

+106
-425
lines changed

5 files changed

+106
-425
lines changed

examples/jsm/nodes/accessors/TextureNode.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ class TextureNode extends UniformNode {
2020
this.levelNode = levelNode;
2121
this.compareNode = compareNode;
2222

23-
this.updateType = NodeUpdateType.FRAME;
23+
this.updateMatrix = uvNode === null;
24+
25+
this.setUpdateMatrix( this.updateMatrix );
2426

2527
}
2628

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

4547
}
4648

47-
getDefaultUV() {
49+
getDefaultUV( uvNode = null ) {
4850

4951
const texture = this.value;
5052

51-
return uniform( texture.matrix ).mul( vec3( uv( texture.channel ), 1 ) );
53+
if ( uvNode === null ) uvNode = uv( texture.channel );
54+
55+
return uniform( texture.matrix ).mul( vec3( uvNode, 1 ) );
56+
57+
}
58+
59+
setUpdateMatrix( value ) {
60+
61+
this.updateMatrix = value;
62+
this.updateType = value ? NodeUpdateType.FRAME : NodeUpdateType.NONE;
63+
64+
return this;
5265

5366
}
5467

5568
construct( builder ) {
5669

5770
const properties = builder.getNodeProperties( this );
71+
const texture = this.value;
5872

5973
//
6074

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

6781
}
6882

69-
uvNode || ( uvNode = this.getDefaultUV() );
83+
if ( this.updateMatrix ) {
84+
85+
uvNode = this.getDefaultUV( uvNode );
86+
87+
} else if ( ! uvNode ) {
88+
89+
uvNode = uv( texture.channel );
90+
91+
}
7092

7193
//
7294

examples/jsm/renderers/common/nodes/NodeRender.js

Lines changed: 0 additions & 302 deletions
This file was deleted.

examples/jsm/renderers/common/nodes/Nodes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class Nodes extends DataMap {
165165

166166
}
167167

168-
backgroundNode = texture( background, nodeUV );
168+
backgroundNode = texture( background, nodeUV ).setUpdateMatrix( true );
169169

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

examples/jsm/renderers/webgpu/utils/WebGPUConstants.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,17 @@ export const GPUFilterMode = {
222222
export const GPUBlendFactor = {
223223
Zero: 'zero',
224224
One: 'one',
225-
SrcColor: 'src-color',
226-
OneMinusSrcColor: 'one-minus-src-color',
225+
Src: 'src',
226+
OneMinusSrc: 'one-minus-src',
227227
SrcAlpha: 'src-alpha',
228228
OneMinusSrcAlpha: 'one-minus-src-alpha',
229-
DstColor: 'dst-color',
230-
OneMinusDstColor: 'one-minus-dst-color',
229+
Dst: 'dst',
230+
OneMinusDstColor: 'one-minus-dst',
231231
DstAlpha: 'dst-alpha',
232232
OneMinusDstAlpha: 'one-minus-dst-alpha',
233233
SrcAlphaSaturated: 'src-alpha-saturated',
234-
BlendColor: 'blend-color',
235-
OneMinusBlendColor: 'one-minus-blend-color'
234+
Constant: 'constant',
235+
OneMinusConstant: 'one-minus-constant'
236236
};
237237

238238
export const GPUBlendOperation = {

0 commit comments

Comments
 (0)