Lightweight Pipeline HDR + Postprocessing Bloom with second Camera

Hello,
i use LightWeight Pipeline and Post-Processing Bloom on a scene with 2 cameras. First main camera render the scene objects and second camera GUI only. My problem is, that Bloom does not work, when LightWeight Pipeline HDR is enabled. If I turn off the second (GUI) camera, then Bloom works fine with HDR. Or if i add Post-Processing Layer on second (GUI) Camera, then it works too, but i do not want the Bloom effect on my GUI. With the “standart” Unity Render Pipeline Bloom works fine with HDR and second camera.
Does anyone know how to solve the problem?

With Lightweight the UI is rendered outside of the post loop, so you do not need to use a second camera as the post effects will not affect the UI regardless.
If you wish to have a second camera in the case you are doing something unique/custom you can a achieve this, you just need to make sure your UI camera has neither HDR or MSAA enabled, set the clear flags to ‘Depth Only’ and make sure it is only rendering the UI layer(more importantly is only rendering UI shaders) then you will have the UI render over top of the game camera.

I would personally go with the first option if you don’t need to do any camera space stuff for the UI as with two cameras you are paying for the additional cost of a second camera, which is quite large especially on mobile.

Thanks for reply! I use second camera because i want to have my particle effects in front of UI elements. Maybe not the best solution, but it works.
Bloom + HDR works now very well after the last update with disabled MSAA on the second camera. But the bloom performance has become worse than with standart pipeline.
I tested my Scene with a Redmi Note 3 Pro (Snapdragon 650, Adreno 510) smartphone and got 36 fps with enabled bloom and middle settings in standart pipeline and only 28 fps in lightweight pipeline with lowest settings, one camera and disabled MMSA :frowning:

Hmm that does sounds bad, LWRP in general, with comparable settings should be the same if not much faster, there must be something else going on here.
I would be interested in seeing the profiler timeline between the two to see where the slow down is occurring. Also LWRP is developing at an insane rate, what version are you using as we are constantly making speedups.

I use 2018.1.1f1 version.
I did four tests with and without bloom for both render pipelines.

3517792–281250–2018.1.1f1 with bloom.rar (584 KB)
3517792–281251–2018.1.1f1 lightweight with bloom.rar (627 KB)
3517792–281252–2018.1.1f1 without bloom.rar (621 KB)
3517792–281253–2018.1.1f1 lightweight without bloom.rar (639 KB)

Hey, i tested now again bloom with LWRP in Unity 2018.2 official release.
First of all I would like to say that without bloom the performance of LWRP has improved a lot. I have 48 fps without MSAA, HDR and shadow with LWRP and 44 fps with old renderer by similar settings. But HDR and bloom just killing the performance, from 48 fps to 20 fps :frowning: And the problem is, that bloom looks only with HDR nicely.

Hi, I am using LWRP for Oculus Go, and trying to set 2 cameras. one for rendering a player sitting in the cockpit, and another for the map outside the plane. This is working on regular non LWRP. In the LWRP I can only see 1 camera (the player) rendering.
I’ve tried your suggestions but it didn’t work for me…

1 Like

Hi Andre_Mcgrail, I tried what you suggested but it doesn’t work. The second camera always clear the buffer with Solid Color even when it’s being set on Depth Only. I’m using LWRP 4.9.0 on Unity 2018.3.5f1.

Can I modify the runtime code so that it always draw worldspace UI canvases on top of everything think ? As regular overlay canvases. That would be great and with this, no need for another camera.

EDIT:
I’m not using post processing, I’m just trying to draw a world space canvas on top of the render

1 Like

Exactly, this has been since first release of LWRP for me. I couldn’t get multiple cameras working because they just overlay each other. No info on the internet about this, I was thinking if I am doing something wrong if there are so few questions on this.

https://issuetracker.unity3d.com/issues/black-background-when-using-camera-clear-flag-depth-only-in-lwrp-only - :frowning: finally found something. Well, creating custom SRP for just this feature would be sad.

Custom SRP is the whole point of SRP. I’m willing to modify it so that it behaves how I want. Thanks for sharing the issue, it explains how to do it:

  1. Render the ‘overlay’ first to a render texture of the correct size. Use alpha to set the areas where it should be transparent. You can use the camera as it is now for this.
  2. Render the ‘normal’ game scene as you normally would.
  3. Write a custom post process (Writing Custom Effects · Unity-Technologies/PostProcessing Wiki · GitHub)
  4. Have this post process effect alpha blend your custom overalay at the right point in the post stack.

Alternitively:

  1. Render the ‘normal’ game scene as you normally would.
  2. On your second camera add a custom LW REnderer (https://github.com/Unity-Technologies/ScriptableRenderPipeline/blob/master/com.unity.testing.srp.lightweight/Tests/Scenes/045_CustomLWPipe/CustomLWPipe.cs)
  3. Have this renderer (in the last step), alpha blend the result to the screen instead of just copying.

Sounds great but it’s not that easy when you are beginning with SRPs…

I just opened 4.9.0-preview and this indeed does work with a single camera, and trust me you want to do it with one camera for many reasons, Multi camera support was stripped due to it’s unpredictability, and we didn’t just want to slap on the same features we had in builtin, because that is a very very shaky stack.

And yes creating a custom SRP just to do certain things you normally would with multiple cameras is sad, which is why we are currently working on a much better system, which will let you do the common setups one would with multiple cameras.

This has been talked about in great lengths but I understand the frustration, and I’m gutted we didn’t manage to get something ready before taking the old way away, but the old way was bad, and it was not fast when it came to mobiles. Also the ease of just being able to slap one camera on top of another in builtin is also its greatest weakness, this cause rendering issues out the wazoo.

So there are two things here that caused us to do this one was it was implemented badly and second it also, not necessarily encouraged but suggested using multiple cameras was a good way of doing something that should really be handled with a proper drawing to screen or a custom pass, otherwise you are paying for a load of redundant setup that you already did with the first camera. Historically those were very hard to do, if you wanted to draw a mesh after Unity’s postprocessing, it was hard, if you wanted render something with custom matrices after opaques, it was hard.
SRP made all of this a lot easier, you still have to write a ton of code and know how to use an API which is currently lacking in a lot of example projects and tutorials, and is also not quite out of preview, meaning APIs that can disappear or change drastically till it’s out of preview.
With 19.1 and the release of LWRP out of preview, this also makes SRP Core out of preview and the surrounding API, which also means we have finally begun work on a proper camera stacking system, and a nice pass system, that will let people get 80% of the way with cool custom rendering without writing any code, and if you do write code it also means you can inject your own passes without having to keep doing edits to existing LWRP code.

I’m also working on an examples project with a variety of game rendering effects that make use of either custom passes or multi camera setups so there is a good basis go how they should be setup in LWRP for the best performance across platforms.

Sorry we have been quite quiet with regards to information lately, we have been doing the final push to the finish line and would rather make some consistent and complete how-tos once we are happy with the ground work, otherwise it will all just have to be redone again.

Keep an eye out around GDC, we will have some shiny stuff to show there for LWRP in 19.1.

3 Likes

Yeah, I totally understand. I was just thinking that it would be cool to have SRP that supports this, and people could use it for their specific needs, it would be a bad decision to lose performance over this, so maybe, if it will break things LWRP shouldn’t do that. If having button that says yes is possible then it’s cool, but it probably be even better if it made use of Strategy pattern approach, and that type of additional things could be added to already working SPR.

Main reason I want to use LWRP is Shader Graph. Game is PC but I am still not using HDRP because it doesn’t support it yet.

I would check out a newer version of HDRP :slight_smile: shadergraph has been supported for a while and the last few version also have a HD Lit master node letting you use most of the advanced HDRP shading features in shadergraph.

As for the camera clear flags being limited, we are working hard on the feature now that will make you forget about needing them, we will be showing it at GDC with a LWRP package(and example project) available around that time too.

3 Likes

Thanks for your answer !

Nice, i’m really interested about it.
I noticed there were many examples on git but there isn’t any documentation on it (how to use them, what they do). Any idea on this ?