Can not get rendertarget when camera's posteffect is on

Say,I use a rendertarget to draw some layer like this:

worldLayer.renderTarget = myRenderTarget;

Then I can show the captured texture on one of the image:

imageElement.texture= myRenderTarget.colorBuffer;

But when I add some post-effects on camera,the rendertarget is not shown.
Does the post-effects affect all layers on the camera?can I disable post-effects for some specific layers?

also,the example project can be found here:
https://playcanvas.com/project/771915/overview/posteffect-test

I dig into the engine code and find this:

But why?I remenber we can still apply rendertarget to layers in the previous version of engine.

Hi @FBplus,

I think your issue is related to this, check it out:

2 Likes

Also see the recommended way to set up rendering to texture https://developer.playcanvas.com/en/user-manual/graphics/layers/#recommended-setup

You should set up render target on a camera and not on a layer. See examples here as well:
http://playcanvas.github.io/#graphics/render-to-texture.html
http://playcanvas.github.io/#graphics/render-to-cubemap.html

3 Likes

@mvaligursky Thanks so much for your advice :grin:
BTW I wonder if there is a method to replace all the shader before rendering?like unity does here:
https://docs.unity3d.com/Manual/SL-ShaderReplacement.html
So I can easily mark some special meshes to pure white or pure black for posteffect purpose.
If there’s not,how can I achieve this in playcanvas,can you give me some advice?

There isn’t anything super convenient like this at the moment.
Perhaps you could hook up to layer.onPreRender and change materials / shaders in there.

2 Likes