Can i disable lens flares for a specific camera?

I am using new lens flare system for URP, but i have 2 different cameras with different fov's, one for game rendering and other for weapon (i cant use overlay because i am using deffered shading), and both cameras render lens flares, and the results are really weird and unrealistic.

lens flare with enabled camera with weapon

lens flare with disabled camera with weapon


same issue here. im also using mixed fov and camera stacking to stop weapon clipping but this shish happens. the reason the lens flare is out of place is that the weapon camera is the one rendering the lens flare but because it has a different fov from your main cam the lens flare gets out of place. even though lens flares count as post processing effects u can disable them on specific cameras using volume layers on your cam and culling masks. the camera with post processing will be the one rendering it and you might say then enable post processing on the base camera but if you do that camera stacking breaks and your weapon wont receive post processing effects. i think unity should make it so we can choose what camera the lens flare appears on. but then there will be another problem of the lens flare appearing through your weapons because its in a separate camera

1 Like

Same issue, currently the only solution I have found is to disable post processing on the cameras that should not display lens flare.

Another potential solution is to place a giant cube to hide the light source. It can be a child of the light source. Disable shadow casting, and place it on a layer only visible by the camera that shouldn't render the light flare.

Found the solution! Just toggle the lens flare using render pipeline events

namespace CameraUtils
  public class LensFlareController : MonoBehaviour
    [SerializeField] Camera targetCamera;

    void OnCameraEnd(ScriptableRenderContext _, Camera currentCamera)
      if (targetCamera == null || currentCamera == targetCamera) reqLensFlare.enabled = false;

    void OnCameraStart(ScriptableRenderContext _, Camera currentCamera)
      if (targetCamera == null || currentCamera == targetCamera) reqLensFlare.enabled = true;

    void Awake()
      RenderPipelineManager.beginCameraRendering += OnCameraStart;
      RenderPipelineManager.endCameraRendering += OnCameraEnd;
    void OnDestroy()
      RenderPipelineManager.beginCameraRendering -= OnCameraStart;
      RenderPipelineManager.endCameraRendering -= OnCameraEnd;