Is there a public API or recommend way to get a camera's colorBuffer?

I know we can create a new camera and bind a renderTexture on it so we can get what that camera is rendering,or add a posteffect on the camera and use camera.postEffects._sourceTarget.colorBuffer.
But is there a better way or recommend method to achieve this?

So what are you trying to do with the colorBuffer?
There’s a way to get it for something like this:


Hi,@mvaligursky ,thanks so much for your reply :smiley:

I am trying to make a bloom effect only on specific objects according your advice here:

So I have to capture the camera’s colorbuffer before the bloom objects is rendered. I’ve managed to achieve that effect but wonder if there is any better solution?
I’ve tried to use texture_grabPass to replace camera.postEffects._sourceTarget.colorBuffer,but I can not capture anything,Is there any pre setup need to be done?

The test project can be found here:

1 Like

the key to grab pass is that you need to have a shader that uses texture_grabPass uniform … we detect the shader needs grab pass texture, and before the object is rendered, we grab the backbuffer and copy it to texture.

So I guess to use this, the first postprocessing shader that needs to use backbuffer needs to have this uniform.


I’ve added that uniform to the shader defination but it seems I still can not get the right colorbuffer.I used an Image to show the texture,as you can see on the top left of the screen,the texture caputured is pure black.


use camera.postEffects._sourceTarget.colorBuffer:

use texture_grabPass:

At what time in the frame do you use that grab texture? Is anything in the framebuffer at that point?
I’d suggest to use debug engine (tick debug when launching in the editor), and capture the frame in SpectorJS … you can see when the grab pass runs and what is in target and similar. That could give you a help with the debugging of this.

1 Like