When applying the bloom effect in the project, I want it to only work for models with a certain layer. Is there a solution where I can do this without using two cameras? I saw a question like this in the forum, but I couldn’t quite understand the solution steps:
I want to apply bloom only to drawn lines from app.drawLine(). Since they can be on their own seperate layer, I thought maybe you could apply the bloom effect only on that specific layer. I tried using 2 cameras as suggested in these posts, but to no avail.
Anyone got this to work and cares to share the code?
X → The layer where I want the Bloom effect to work
Other objects → World Layer
Objects with effect → World Layer + X Layer
AFAIK, the post processing is done on a camera basis as it processes what has been rendered so unfortunately you will need to stack cameras to only apply post processing to specific layers
@mvaligursky Might have other ideas on how this could be done?
Here’s a similar discussion
https://playcanvas.com/project/786157/overview/bloom-effect - simple demonstration of a problem
thanks to tutorials I managed to implement bloom effect on camera. Bloom is affecting only layer named “bloom”. Models in “world” layer is unaffected by bloom effect which is what I want.
But there is also layer “background_UI” which should be unaffected by the bloom effect (camera which renders this layer doesn’t have bloom.js attached), but somehow it still renders layer with bloom effect …
I don’t think you can do this without additional camera / render targets.
Thanks for the quick answers
@yaustar @mvaligursky , I will fix this issue with two cameras.
I tried to change the rendering order of the bloom effect with two cameras. But in all the hierarchies I made, the effect that was supposed to only affect the bloom layer worked on all objects. I couldn’t solve this problem according to the example you gave.I am attaching my sample project here. What solution can you suggest me?
I’ve been doing some tests, but didn’t go to the source code. Tried to play with these parameters:
onPreRender and onPostRender to activate and deactivate the effects
Change the uniforms of the effect directly
Enable/disable the script-effect
I may be wrong, but at this moment I think the next:
The effect apply to one camera is applied in cascade to the next ones.
So if you have 3 cameras and the bloom effect is in the second one, it will affect the third too.
I tried to deactivate the effect enabling/disabling the effect and modifying the uniform, none of them worked.
My guess is that Playcanvas first renders all the cameras and later apply the effects.
Playcanvas renders each layer keeping in mind the depth data and transparency, but you lose all that data when applying the bloom effect and you may overlap the layers in the wrong way.
@yaustar , could you please confirm the bold parts?
I manage partial successes yesterday while testing. I leave here a project I used for that (very dirty because it was for learning).
Well, it was already solved here, as stated above:
In engine, if you enable post effects on a camera, then automatically all previous cameras that render to the same render target (framebuffer in this case) are considered a camera stack and are all switched to rendering to a texture and postprocessed at the end. And the result is copied into your original framebuffer).
You’re hoping that yourCamera-Background gets rendered to framebuffer, and only Camera-Bloom renders to texture and gets postprocessed. Missing bit there is that what happens nex…