Sfoglia il codice sorgente

WebGPURenderer: Allow specifying texture index for MRT in `readRenderTargetPixelsAsync()`. (#28197)

* Update Renderer.js

The readRenderTargetAsync function accepts a renderTarget, but so far has no option to choose between the different textures of a renderTarget if it has more than just one texture. That's why I added an index = 0 so that everyone who has used the function so far has no disadvantages because the first texture is always selected by default.

* Update Renderer.js

Clean up.

---------

Co-authored-by: Michael Herzog <[email protected]>
Spiri0 1 anno fa
parent
commit
5493cfa86c
1 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  1. 2 2
      examples/jsm/renderers/common/Renderer.js

+ 2 - 2
examples/jsm/renderers/common/Renderer.js

@@ -1086,9 +1086,9 @@ class Renderer {
 	}
 	}
 
 
 
 
-	readRenderTargetPixelsAsync( renderTarget, x, y, width, height ) {
+	readRenderTargetPixelsAsync( renderTarget, x, y, width, height, index = 0 ) {
 
 
-		return this.backend.copyTextureToBuffer( renderTarget.texture, x, y, width, height );
+		return this.backend.copyTextureToBuffer( renderTarget.textures[ index ], x, y, width, height );
 
 
 	}
 	}