Hi there,
I couldn’t solve this problem. At the end, what I did was using this code to capture the color of any pixel in the canvas (by collecting the information of each pixel on the screen using a “render target”).
var rtTexture = new THREE.WebGLRenderTarget(
sizes.width,
sizes.height,
{minFilter: THREE.LinearFilter, magFilter: THREE.NearestFilter, format: THREE.RGBAFormat, type: THREE.FloatType})
function capture()
{
renderer.clear()
renderer.setRenderTarget( rtTexture …
Refer to this thread’s answer.
I can extract the pixel data using readRenderTargetPixels
with the default renderer I’ve set up.
Now I tried to create a new WebGLRenderer with the same configuration as the previous one, Then readRenderTargetPixels
like so.
const renderer = new WebGLRenderer(options);
const read = new Uint8Array(4);
renderer.readRenderTargetPixels(
renderTarget, x, y, 1, 1, read
);
And it doesn’t work, No error but I’ve got no results.
The render target has already been rendered using the original renderer.
What criteria make the readRenderTargetPixels
work in my original renderer?
You can’t access a render target with a different renderer since the internal resource of the render target are not shared. They are internally managed in the first renderer.
1 Like
Super helpful answer as always.
Thanks a ton.
1 Like