Skip to content

readRenderTargetPixels() works for WebGLRenderTarget but is all 0 for WebGL3DRenderTarget #28501

@hubtub2

Description

@hubtub2

Description

I am using a shader to write to a 3D render target.
To debug the result I am using renderer.readRenderTargetPixels()

The result for WebGLRenderTarget is correct, the result for WebGL3DRenderTarget is all zero.

Reproduction steps

Please check the fiddle:

  1. First run as is and check the output on the console: the buffer contains 0,0,0,255
  2. Now go to line 66 and enable the line with WebGLRenderTarget and disable the line with WebGL3DRenderTarget
  3. The output now is correct: 102, 255, 15, 255

Code

See fiddle for complete example.

//-- 3D or 2D Render target
// brushTarget = new THREE.WebGLRenderTarget(32, 32) 
brushTarget = new THREE.WebGL3DRenderTarget(32, 32, 32)


var layer=0;   // Layer in 3D Texture

renderer.setRenderTarget(brushTarget, layer);
renderer.render( brushScene, brushCamera );    
    
var buffer = new Uint8Array(4); 
renderer.readRenderTargetPixels(brushTarget, 16, 16, 1, 1, buffer, layer)

console.log("Debug read brush", buffer)   // Press F12 to show chrome console

Live example

https://jsfiddle.net/92xa60g4/25/

Screenshots

No response

Version

r164

Device

Desktop

Browser

Chrome

OS

Windows

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions