Of course, nobody is gonna help me or even answer here, but I still want to try.
New layers system. I try to render layer in texture then use this it.
I successfully rendered this texture in onPostRender to screen and still able to use. Great.
But if I set renderTarget for another one layer, it doesn’t work. Doesn’t matter where this layer is.
this.worldRenderTexture = new pc.Texture(device, {
format: pc.PIXELFORMAT_R8_G8_B8_A8,
width: device.width,
height: device.height
});
this.testRenderTexture = new pc.Texture(device, {
format: pc.PIXELFORMAT_R8_G8_B8_A8,
width: device.width,
height: device.height
});
this.worldRenderTarget = new pc.RenderTarget(device, this.worldRenderTexture);
this.testRenderTarget = new pc.RenderTarget(device, this.testRenderTexture);
this.app.scene.layers.getLayerByName("World").renderTarget = this.worldRenderTarget;
// If I comment this line everything is working fine.
this.app.scene.layers.getLayerByName("Test").renderTarget = this.testRenderTarget;
this.app.scene.layers.getLayerByName("World").onPostRender = (cameraIndex) => {
var uColorBuffer = device.scope.resolve('source');
uColorBuffer.setValue(this.worldRenderTexture);
pc.drawQuadWithShader(device, null, this.shaderFinal, null, null, true);
}
This is exactly what I want to achieve! Just render layers in any order and blend them according to depth.
But, for example, I want to pass my rendered World layer into a texture to another one layer, and then render them both to the screen.
So, Unreal gives that. You can render entity into a texture, pass somewhere, render anytime.
Also, new post-effects are extremely cool, but there are some bugs, but then it will be released, I would like to try to something like Unreal’s composer for PlayCanvas.
It renders non-UI layers to an offscreen render target (1/16th resolution of back buffer), then copies that render target to the back buffer, and then renders the UI layer over the top.
For WebGL 2.0, it just does a ‘resolve’ operation which is super fast. For WebGL 1.0, I think it just renders a fullscreen quad, which is also pretty fast.