Browse Source

Fix: WebGL viewport / scissors not working correctly with PostProcessing in WebGPURenderer (#32883)

Tobias 3 weeks ago
parent
commit
9d40465f25
1 changed files with 30 additions and 2 deletions
  1. 30 2
      src/renderers/webgl-fallback/WebGLBackend.js

+ 30 - 2
src/renderers/webgl-fallback/WebGLBackend.js

@@ -446,9 +446,12 @@ class WebGLBackend extends Backend {
 
 		if ( renderContext.scissor ) {
 
-			const { x, y, width, height } = renderContext.scissorValue;
+			this.updateScissor( renderContext );
 
-			state.scissor( x, renderContext.height - height - y, width, height );
+		} else {
+
+			const { width, height } = this.getDrawingBufferSize();
+			state.scissor( 0, 0, width, height );
 
 		}
 
@@ -545,6 +548,17 @@ class WebGLBackend extends Backend {
 
 			}
 
+			if ( previousContext.scissor ) {
+
+				this.updateScissor( previousContext );
+
+			} else {
+
+				const { width, height } = this.getDrawingBufferSize();
+				state.scissor( 0, 0, width, height );
+
+			}
+
 		}
 
 		this.prepareTimestampBuffer( TimestampQuery.RENDER, this.getTimestampUID( renderContext ) );
@@ -646,6 +660,20 @@ class WebGLBackend extends Backend {
 
 	}
 
+	/**
+	 * Updates the scissor with the values from the given render context.
+	 *
+	 * @param {RenderContext} renderContext - The render context.
+	 */
+	updateScissor( renderContext ) {
+
+		const { state } = this;
+		const { x, y, width, height } = renderContext.scissorValue;
+
+		state.scissor( x, renderContext.height - height - y, width, height );
+
+	}
+
 	/**
 	 * Defines the scissor test.
 	 *

粤ICP备19079148号