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

WebGPURenderer: Do not render shadow maps when precompile. (#33924)

Michael Herzog 6 дней назад
Родитель
Сommit
b80b355582
2 измененных файлов с 18 добавлено и 0 удалено
  1. 4 0
      src/nodes/lighting/ShadowNode.js
  2. 14 0
      src/renderers/common/Renderer.js

+ 4 - 0
src/nodes/lighting/ShadowNode.js

@@ -850,6 +850,10 @@ class ShadowNode extends ShadowBaseNode {
 	 */
 	updateBefore( frame ) {
 
+		// do not render shadow maps during precompilation
+
+		if ( frame.renderer._isPreCompiling === true ) return;
+
 		const { shadow } = this;
 
 		let needsUpdate = shadow.needsUpdate || shadow.autoUpdate;

+ 14 - 0
src/renderers/common/Renderer.js

@@ -661,6 +661,16 @@ class Renderer {
 		 */
 		this._compilationPromises = null;
 
+		/**
+		 * Whether the renderer is currently precompiling a render object in
+		 * `compileAsync()`.
+		 *
+		 * @private
+		 * @type {boolean}
+		 * @default false
+		 */
+		this._isPreCompiling = false;
+
 		/**
 		 * When an override material is in use, this property points to the current
 		 * source material during the rendering of a render object.
@@ -1048,10 +1058,12 @@ class Renderer {
 			// Use async node building to yield to main thread
 			await this._nodes.getForRenderAsync( renderObject );
 
+			this._isPreCompiling = true; // note: no awaits are allowed when this flag is true otherwise the state leaks outside of this method
 			this._nodes.updateBefore( renderObject );
 			this._geometries.updateForRender( renderObject );
 			this._nodes.updateForRender( renderObject );
 			this._bindings.updateForRender( renderObject );
+			this._isPreCompiling = false;
 
 			// Wait for pipeline creation
 			const pipelinePromises = [];
@@ -1062,7 +1074,9 @@ class Renderer {
 
 			}
 
+			this._isPreCompiling = true;
 			this._nodes.updateAfter( renderObject );
+			this._isPreCompiling = false;
 
 			// Yield between objects to allow animation frames
 			await yieldToMain();

粤ICP备19079148号