diff --git a/src/materials/nodes/NodeMaterial.js b/src/materials/nodes/NodeMaterial.js index 3dab50b4e7e820..c2af24320265e8 100644 --- a/src/materials/nodes/NodeMaterial.js +++ b/src/materials/nodes/NodeMaterial.js @@ -535,9 +535,9 @@ class NodeMaterial extends Material { builder.addStack(); - const mvp = subBuild( this.setupVertex( builder ), 'VERTEX' ); + const mvp = this.setupVertex( builder ); - const vertexNode = this.vertexNode || mvp; + const vertexNode = subBuild( this.vertexNode || mvp, 'VERTEX' ); builder.context.clipSpace = vertexNode; diff --git a/src/nodes/accessors/Position.js b/src/nodes/accessors/Position.js index d15176e91321eb..d791ab9ad305c1 100644 --- a/src/nodes/accessors/Position.js +++ b/src/nodes/accessors/Position.js @@ -67,7 +67,7 @@ export const positionWorld = /*@__PURE__*/ ( Fn( ( builder ) => { return modelWorldMatrix.mul( positionLocal ).xyz.toVarying( builder.getSubBuildProperty( 'v_positionWorld' ) ); -}, 'vec3' ).once( [ 'POSITION' ] ) )(); +}, 'vec3' ).once( [ 'POSITION', 'VERTEX' ] ) )(); /** * TSL object that represents the position world direction of the current rendered object. @@ -103,7 +103,7 @@ export const positionView = /*@__PURE__*/ ( Fn( ( builder ) => { return builder.context.setupPositionView().toVarying( 'v_positionView' ); -}, 'vec3' ).once( [ 'POSITION' ] ) )(); +}, 'vec3' ).once( [ 'POSITION', 'VERTEX' ] ) )(); /** * TSL object that represents the position view direction of the current rendered object. diff --git a/src/nodes/core/VaryingNode.js b/src/nodes/core/VaryingNode.js index c1728a543dbe55..662644fd597b6d 100644 --- a/src/nodes/core/VaryingNode.js +++ b/src/nodes/core/VaryingNode.js @@ -36,7 +36,7 @@ class VaryingNode extends Node { * * @type {Node} */ - this.node = node; + this.node = subBuild( node, 'VERTEX' ); /** * The name of the varying in the shader. If no name is defined,