How can I clear and render specific layer only?

Hi guys. I have a complex scene which has lots of meshes to render, most of these meshes are in world layer. I need to render a video texture, it should clear and re-render the scene every frame. so I can’t set app.renderNextFrame = false to stop the rendering function.

I want to improve the rendering performance, avoid re-rendering the world layer meshes, and move the video texture to another layer, so that I can keep the last frame of world layer(in WorldRenderTarget), and render the video texture(in UIRenderTarget) only, and combine the two render target in the end.

This is my thought, but I don’t know how to implement it. Can anyone give me ideas? Thanks.

1 Like

Hi @swh,

First of all to disable a layer so it doesn’t render you can use the enabled property:

For what you are looking for a great starting point is the following example project, it renders a layer to render target to grab a screen grab. You can change the last bit to combine two render targets on a canvas:


But the demo you post above is about capturing screenshot by canvas.toDataURL:joy:

Yes, that’s the part to take out, it contains a lot of useful code on how to render a certain layer and do something with the output like what you ask.

Sorry I am not aware of any ready solution for what you ask.

Here’s an example of rendering one or more layers to a render texture which may help


Thanks for your example above. I found an interesting issue in the example. It set render target for world layer and skybox layer, the renderer should render results into render targets. But I can not find any code about rendering render targets to screen … Does the renderer render them to screen automatically ?

The example above renders the layers to a render texture. The render texture is applied to a UI element that is full screen which you can see on line 92:

1 Like