Просмотр исходного кода

NodeBuilder: Fix update nodes sequence (#32991)

sunag 1 неделя назад
Родитель
Сommit
13624b0d86

+ 11 - 2
examples/jsm/tsl/display/GaussianBlurNode.js

@@ -1,5 +1,5 @@
 import { RenderTarget, Vector2, NodeMaterial, RendererUtils, QuadMesh, TempNode, NodeUpdateType } from 'three/webgpu';
-import { nodeObject, Fn, float, uv, uniform, convertToTexture, vec2, vec4, passTexture, premultiplyAlpha, unpremultiplyAlpha } from 'three/tsl';
+import { Fn, float, uv, uniform, convertToTexture, vec2, vec4, passTexture, premultiplyAlpha, unpremultiplyAlpha } from 'three/tsl';
 
 const _quadMesh = /*@__PURE__*/ new QuadMesh();
 
@@ -124,6 +124,15 @@ class GaussianBlurNode extends TempNode {
 		 */
 		this.premultipliedAlpha = options.premultipliedAlpha || false;
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @default true
+		 * @readonly
+		 */
+		this.isGaussianBlurNode = true;
+
 	}
 
 	/**
@@ -358,7 +367,7 @@ export default GaussianBlurNode;
  * @param {number} [options.resolutionScale=1] - The resolution of the effect. 0.5 means half the resolution of the texture node.
  * @returns {GaussianBlurNode}
  */
-export const gaussianBlur = ( node, directionNode, sigma, options = {} ) => nodeObject( new GaussianBlurNode( convertToTexture( node ), directionNode, sigma, options ) );
+export const gaussianBlur = ( node, directionNode, sigma, options = {} ) => new GaussianBlurNode( convertToTexture( node ), directionNode, sigma, options );
 
 /**
  * TSL function for creating a gaussian blur node for post processing with enabled premultiplied alpha.

+ 3 - 3
examples/jsm/tsl/display/PixelationPassNode.js

@@ -80,13 +80,13 @@ class PixelationNode extends TempNode {
 		this._resolution = uniform( new Vector4() );
 
 		/**
-		 * The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node updates
+		 * The `updateType` is set to `NodeUpdateType.FRAME` since the node updates
 		 * its internal uniforms once per frame in `updateBefore()`.
 		 *
 		 * @type {string}
 		 * @default 'frame'
 		 */
-		this.updateBeforeType = NodeUpdateType.FRAME;
+		this.updateType = NodeUpdateType.FRAME;
 
 	}
 
@@ -95,7 +95,7 @@ class PixelationNode extends TempNode {
 	 *
 	 * @param {NodeFrame} frame - The current node frame.
 	 */
-	updateBefore() {
+	update() {
 
 		const map = this.textureNode.value;
 

BIN
examples/screenshots/webgpu_backdrop_water.jpg


BIN
examples/screenshots/webgpu_skinning_instancing.jpg


BIN
examples/screenshots/webgpu_volume_lighting.jpg


BIN
examples/screenshots/webgpu_volume_lighting_rectarea.jpg


BIN
examples/screenshots/webgpu_volume_lighting_traa.jpg


+ 4 - 2
src/nodes/core/Node.js

@@ -786,7 +786,6 @@ class Node extends EventDispatcher {
 
 		//
 
-		builder.addNode( this );
 		builder.addChain( this );
 
 		/* Build stages expected results:
@@ -800,6 +799,8 @@ class Node extends EventDispatcher {
 
 		if ( buildStage === 'setup' ) {
 
+			builder.addNode( this );
+
 			this.updateReference( builder );
 
 			const properties = builder.getNodeProperties( this );
@@ -836,6 +837,8 @@ class Node extends EventDispatcher {
 
 				}
 
+				builder.addSequentialNode( this );
+
 			}
 
 			result = properties.outputNode;
@@ -905,7 +908,6 @@ class Node extends EventDispatcher {
 		}
 
 		builder.removeChain( this );
-		builder.addSequentialNode( this );
 
 		return result;
 

+ 13 - 3
src/nodes/core/NodeBuilder.js

@@ -139,7 +139,10 @@ class NodeBuilder {
 		this.nodes = [];
 
 		/**
-		 * A list of all sequential nodes.
+		 * A list of all nodes the builder is processing in sequential order.
+		 *
+		 * This is used to determine the update order of nodes, which is important for
+		 * {@link NodeUpdateType#UPDATE_BEFORE} and {@link NodeUpdateType#UPDATE_AFTER}.
 		 *
 		 * @type {Array<Node>}
 		 */
@@ -786,9 +789,16 @@ class NodeBuilder {
 	 */
 	addSequentialNode( node ) {
 
-		if ( this.sequentialNodes.includes( node ) === false ) {
+		const updateBeforeType = node.getUpdateBeforeType();
+		const updateAfterType = node.getUpdateAfterType();
+
+		if ( updateBeforeType !== NodeUpdateType.NONE || updateAfterType !== NodeUpdateType.NONE ) {
+
+			if ( this.sequentialNodes.includes( node ) === false ) {
 
-			this.sequentialNodes.push( node );
+				this.sequentialNodes.push( node );
+
+			}
 
 		}
 

+ 20 - 1
src/nodes/display/PassNode.js

@@ -44,13 +44,23 @@ class PassTextureNode extends TextureNode {
 		 */
 		this.passNode = passNode;
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @default true
+		 * @readonly
+		 */
+		this.isPassTextureNode = true;
+
 		this.setUpdateMatrix( false );
 
 	}
 
 	setup( builder ) {
 
-		this.passNode.build( builder );
+		const properties = builder.getNodeProperties( this );
+		properties.passNode = this.passNode;
 
 		return super.setup( builder );
 
@@ -107,6 +117,15 @@ class PassMultipleTextureNode extends PassTextureNode {
 		 */
 		this.previousTexture = previousTexture;
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @default true
+		 * @readonly
+		 */
+		this.isPassMultipleTextureNode = true;
+
 	}
 
 	/**

+ 0 - 7
test/e2e/puppeteer.js

@@ -8,8 +8,6 @@ const server = createServer();
 const exceptionList = [
 
 	// Take too long
-	'webgpu_parallax_uv', 				// 11 min
-	'webgpu_cubemap_adjustments', 		// 9 min
 	'webgl_loader_lwo', 				// 8 min
 	'webgpu_cubemap_mix', 				// 2 min
 	'webgl_loader_texture_ultrahdr', 	// 1 min
@@ -31,14 +29,9 @@ const exceptionList = [
 	'webgpu_portal',
 	'webgpu_postprocessing_ao',
 	'webgpu_postprocessing_dof',
-	'webgpu_postprocessing_godrays',
 	'webgpu_postprocessing_ssgi',
 	'webgpu_postprocessing_sss',
 	'webgpu_postprocessing_traa',
-	'webgpu_reflection',
-	'webgpu_test_memory',
-	'webgpu_texturegrad',
-	'webgpu_tsl_vfx_flames',
 	'webgpu_volume_lighting_traa',
 
 	// Need more time to render

粤ICP备19079148号