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

LightShadow: Introduce `biasNode`. (#32811)

Michael Herzog 1 месяц назад
Родитель
Сommit
e29ac8e8f4
2 измененных файлов с 13 добавлено и 1 удалено
  1. 12 0
      src/lights/LightShadow.js
  2. 1 1
      src/nodes/lighting/ShadowNode.js

+ 12 - 0
src/lights/LightShadow.js

@@ -52,6 +52,16 @@ class LightShadow {
 		 */
 		 */
 		this.bias = 0;
 		this.bias = 0;
 
 
+		/**
+		 * A node version of `bias`. Only supported with `WebGPURenderer`.
+		 *
+		 * If a bias node is defined, `bias` has no effect.
+		 *
+		 * @type {?Node<float>}
+		 * @default null
+		 */
+		this.biasNode = null;
+
 		/**
 		/**
 		 * Defines how much the position used to query the shadow map is offset along
 		 * Defines how much the position used to query the shadow map is offset along
 		 * the object normal. The default is `0`. Increasing this value can be used to
 		 * the object normal. The default is `0`. Increasing this value can be used to
@@ -292,6 +302,8 @@ class LightShadow {
 
 
 		this.mapSize.copy( source.mapSize );
 		this.mapSize.copy( source.mapSize );
 
 
+		this.biasNode = source.biasNode;
+
 		return this;
 		return this;
 
 
 	}
 	}

+ 1 - 1
src/nodes/lighting/ShadowNode.js

@@ -341,7 +341,7 @@ class ShadowNode extends ShadowBaseNode {
 		const { shadow } = this;
 		const { shadow } = this;
 		const { renderer } = builder;
 		const { renderer } = builder;
 
 
-		const bias = reference( 'bias', 'float', shadow ).setGroup( renderGroup );
+		const bias = shadow.biasNode || reference( 'bias', 'float', shadow ).setGroup( renderGroup );
 
 
 		let shadowCoord = shadowPosition;
 		let shadowCoord = shadowPosition;
 		let coordZ;
 		let coordZ;

粤ICP备19079148号