Browse Source

WebGPUBackend: Add support for `setStencilReference()`. (#30470)

* WebGPUBackend: Add support for `setStencilReference()`.

* WebGPUBackend: Cache `stencilRef`.
Michael Herzog 11 months ago
parent
commit
f883c9984b
1 changed files with 10 additions and 1 deletions
  1. 10 1
      src/renderers/webgpu/WebGPUBackend.js

+ 10 - 1
src/renderers/webgpu/WebGPUBackend.js

@@ -1080,7 +1080,7 @@ class WebGPUBackend extends Backend {
 	 */
 	draw( renderObject, info ) {
 
-		const { object, context, pipeline } = renderObject;
+		const { object, material, context, pipeline } = renderObject;
 		const bindings = renderObject.getBindings();
 		const renderContextData = this.get( context );
 		const pipelineGPU = this.get( pipeline ).pipeline;
@@ -1189,6 +1189,15 @@ class WebGPUBackend extends Backend {
 
 		}
 
+		// stencil
+
+		if ( context.stencil === true && material.stencilWrite === true && renderContextData.currentStencilRef !== material.stencilRef ) {
+
+			passEncoderGPU.setStencilReference( material.stencilRef );
+			renderContextData.currentStencilRef = material.stencilRef;
+
+		}
+
 		// draw
 
 		const draw = () => {

粤ICP备19079148号