Do custom render pass, then fetch the result back

Hey everyone!

I need to render a texture to screen space, provide a camera transform to project a second texture onto it like a decal, then get the result back to disk.

Has anyone done any of these steps before? The first thing I’ve been stuck on for a while is providing camera transform matrices to a post-process shader. Is this possible, like in a normal material? If it’s not already available, how do you get it in there?

Edit: it turns out the projection matrix part was easy.

It might just be my weak googling but I haven’t come across a way to get a render target texture data back out of the GPU. Is this possible?

BaseTexture provides a way to read back pixel : BaseTexture | Babylon.js Documentation

As RenderTarget inherits from this class, I suppose it’s possible to read back texels from a renderTarget.

Can you confirm @Evgeni_Popov ?

Indeed, simply use readPixel of the RTT to get the pixel data.

1 Like