Unverified Commit cb6c6bc7 authored by aardgoose's avatar aardgoose Committed by GitHub
Browse files

NodeBuilder: remove duplicate code (a TODO item) (#27412)


* remove duplicate  code

* remove imports

* add switch for standard renderer path

* remove unused import

---------
Co-authored-by: default avataraardgoose <angus.sawyer@email.com>
parent 67dfcd8b
Showing with 22 additions and 64 deletions
+22 -64
......@@ -7,7 +7,7 @@ import NodeKeywords from './NodeKeywords.js';
import NodeCache from './NodeCache.js';
import ParameterNode from './ParameterNode.js';
import FunctionNode from '../code/FunctionNode.js';
import { createNodeMaterialFromType } from '../materials/NodeMaterial.js';
import { createNodeMaterialFromType, default as NodeMaterial } from '../materials/NodeMaterial.js';
import { NodeUpdateType, defaultBuildStages, shaderStages } from './constants.js';
import {
......@@ -1089,7 +1089,23 @@ class NodeBuilder {
}
build() {
build( convertMaterial = true ) {
const { object, material } = this;
if ( convertMaterial ) {
if ( material !== null ) {
NodeMaterial.fromMaterial( material ).build( this );
} else {
this.addFlow( 'compute', object );
}
}
// setup() -> stage 1: create possible new nodes and returns an output reference node
// analyze() -> stage 2: analyze nodes to possible optimization and validation
......
import { MathNode, GLSLNodeParser, NodeBuilder, NodeMaterial } from '../../../nodes/Nodes.js';
import { MathNode, GLSLNodeParser, NodeBuilder } from '../../../nodes/Nodes.js';
const glslMethods = {
[ MathNode.ATAN2 ]: 'atan'
......@@ -315,26 +315,6 @@ void main() {
}
build() {
// @TODO: Move this code to super.build()
const { object, material } = this;
if ( material !== null ) {
NodeMaterial.fromMaterial( material ).build( this );
} else {
this.addFlow( 'compute', object );
}
return super.build();
}
}
export default GLSL1NodeBuilder;
......@@ -671,7 +671,7 @@ ${this.shader[ getShaderStageProperty( shaderStage ) ]}
build() {
super.build();
super.build( false );
this._addSnippets();
this._addUniforms();
......
import { MathNode, GLSLNodeParser, NodeBuilder, NodeMaterial } from '../../../nodes/Nodes.js';
import { MathNode, GLSLNodeParser, NodeBuilder } from '../../../nodes/Nodes.js';
import UniformBuffer from '../../common/UniformBuffer.js';
import NodeUniformsGroup from '../../common/nodes/NodeUniformsGroup.js';
......@@ -647,26 +647,6 @@ void main() {
}
build() {
// @TODO: Move this code to super.build()
const { object, material } = this;
if ( material !== null ) {
NodeMaterial.fromMaterial( material ).build( this );
} else {
this.addFlow( 'compute', object );
}
return super.build();
}
}
export default GLSLNodeBuilder;
......@@ -9,7 +9,7 @@ import UniformBuffer from '../../common/UniformBuffer.js';
import StorageBuffer from '../../common/StorageBuffer.js';
import { getVectorLength, getStrideLength } from '../../common/BufferUtils.js';
import { NodeBuilder, CodeNode, NodeMaterial } from '../../../nodes/Nodes.js';
import { NodeBuilder, CodeNode } from '../../../nodes/Nodes.js';
import { getFormat } from '../utils/WebGPUTextureUtils.js';
......@@ -127,24 +127,6 @@ class WGSLNodeBuilder extends NodeBuilder {
}
build() {
const { object, material } = this;
if ( material !== null ) {
NodeMaterial.fromMaterial( material ).build( this );
} else {
this.addFlow( 'compute', object );
}
return super.build();
}
needsColorSpaceToLinear( texture ) {
return texture.isVideoTexture === true && texture.colorSpace !== NoColorSpace;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment