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

Nodes: Fix recursion with environment nodes. (#30277)

* NormalMapNode: Fix recursion with environment nodes.

* move getUV context to setupNormal.

* Revert "NormalMapNode: Fix recursion with environment nodes."

This reverts commit c2a293dcdccc8d63b2d840b1ff0e3269b00435ad.

---------

Co-authored-by: sunag <sunagbrasil@gmail.com>
Michael Herzog 1 год назад
Родитель
Сommit
be84ecf5f9
2 измененных файлов с 8 добавлено и 4 удалено
  1. 2 2
      src/nodes/accessors/MaterialNode.js
  2. 6 2
      src/nodes/accessors/Normal.js

+ 2 - 2
src/nodes/accessors/MaterialNode.js

@@ -540,7 +540,7 @@ export const materialMetalness = /*@__PURE__*/ nodeImmutable( MaterialNode, Mate
  *
  * @type {Node<vec3>}
  */
-export const materialNormal = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.NORMAL ).context( { getUV: null } );
+export const materialNormal = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.NORMAL );
 
 /**
  * TSL object that represents the clearcoat of the current material.
@@ -564,7 +564,7 @@ export const materialClearcoatRoughness = /*@__PURE__*/ nodeImmutable( MaterialN
  *
  * @type {Node<vec3>}
  */
-export const materialClearcoatNormal = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_NORMAL ).context( { getUV: null } );
+export const materialClearcoatNormal = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_NORMAL );
 
 /**
  * TSL object that represents the rotation of the current sprite material.

+ 6 - 2
src/nodes/accessors/Normal.js

@@ -77,7 +77,9 @@ export const normalWorld = /*@__PURE__*/ varying( normalView.transformDirection(
  */
 export const transformedNormalView = /*@__PURE__*/ ( Fn( ( builder ) => {
 
-	return builder.context.setupNormal();
+	// Use getUV context to avoid side effects from nodes overwriting getUV in the context (e.g. EnvironmentNode)
+
+	return builder.context.setupNormal().context( { getUV: null } );
 
 }, 'vec3' ).once() )().mul( faceDirection ).toVar( 'transformedNormalView' );
 
@@ -95,7 +97,9 @@ export const transformedNormalWorld = /*@__PURE__*/ transformedNormalView.transf
  */
 export const transformedClearcoatNormalView = /*@__PURE__*/ ( Fn( ( builder ) => {
 
-	return builder.context.setupClearcoatNormal();
+	// Use getUV context to avoid side effects from nodes overwriting getUV in the context (e.g. EnvironmentNode)
+
+	return builder.context.setupClearcoatNormal().context( { getUV: null } );
 
 }, 'vec3' ).once() )().mul( faceDirection ).toVar( 'transformedClearcoatNormalView' );
 

粤ICP备19079148号