Lens Flares (SRP) occlusion work in reversed order in builds.

I have an issue with Lens Flare (URP).
This what I am getting in WebGL:
8660739--1166196--flares_urp_browser.gif

And this is the same scene rendering properly in Editor:
8660739--1166202--flares_urp_editor.gif

Is this a bug or does anybody know some fix?
It happens in a range of Unity versions.
I have tested this and got the same results in Unity 2022.1.0f and 2022.2.0f.

Please file a bug report in a project with the issue (in Help → Report a bug)

Yes, I did.

Does anyone is also experiencing this?

I wrote to cancel the report bug.
This is not a bug, but a result of using a MirrorFlipCamera from here:

  • which uses GL.invertCulling
    With GL.invertCulling set to true, the flares work as expected.
    The issue is that the code in MirrorFlipCamera doesn’t switch GL.invertCulling back, I don’t know why.

OnPre and OnPostRender events are for use with built in, and do not work with URP afaik. Use Begin and EndCameraRendering instead.

Than

Thanks, anyway I was using the second version of the script, from answer by geo_.

Finally I wrote a flip camera render feature, basing on this article:
https://docs.unity3d.com/Packages/c…renderer-features/how-to-fullscreen-blit.html
-and all the problems have gone.


Update:
Only the problems with reflection probe has gone.
The lens flare seems to be unaffected by GL.invertCulling setting and still renders defectively in webgl.

Hello guys,

This is happening to me at the moment. I am using URP Unity 2021.3.14f1. Any solution yet?

Regards,
Carlos

Unfortunately not.
I have reported a bug, submitting this unitypackage with a sample scene, where it happens.
But they say they can’t reproduce it.
https://unity3d.atlassian.net/servicedesk/customer/portal/2/IN-25988

I have just changed the thread title, because it happens not only in WebGL, but also for other build targets.
The same happens in Android, when I tested it on Samsung Galaxy S8.

Maybe Editor is the only place, where the lens flare occlusion works as expected.

Possibly they would succeed to reproduce your case if you send it to the bug report.

8851132–1206883–LensFlareShowroom.unitypackage (623 KB)

Can anyone get the Lens Flare (URP) occlusion to work properly (outside Editor) in any scene for any build target in Unity 202x.xx?

Well I would say that this is pretty sad, that this issue has been there for such a long time and Unity hasn’t fix it. It is such an important bug when you think about modern games, where lens flares is a given! I love Unity Engine and I have been working with it since the very first version came out, but if there is something that I noticed always is the unfinished features plaguing the engine. I would venture to say that most new features always come unfinished/half done/buggy and it usually takes a second sit when it comes to fixing it, to more new unfinished features.

It is just a shame, that it is difficult to trust that it will be ok to go into production using the many features of Unity. I again I love the engine for its simplicity and speed, so I am not an enemy of either Unity or the wonderful team behind it, but more like again the planning or decision to bring new features that are usually buggy, unfinished, or not tested thoroughly.

I hope someone from the team read this and realize that this essential bug was found since December last year and after all who would want to play a game with lights without lens flares eh?

I agree.
Lens Flares were present since early versions of Unity3d.
I remember using them in Unity 3.xx.
After SRP has appeared, they were not supported in LWRP and then in URP at all for a quite long time.
Now it looks that they are supported, but are not finished completely.
Take a look at Universal RP samples after importing them to Unity using Package manager.
Just take a sunflare scene from it. Play the scene in Unity Editor and then in Android or WebGL or (probably) any other built target.
The below .gif image comes from Editor. This is the sunflare scene; I have only changed the LensFlare occlusion radius from 15 to 0 in order to highlight the effect.
8853277--1207447--movie_001.gif

The next image comes from Android build, deployed to Samsung Galaxy S8. You can see the LensFlare occlusion does not work and also the LensFlare screen position is mirrored relative to middle horizontal screen axis.
8853277--1207453--az_recorder_2.gif

Check the issue tracker and if not findable make a bug report

I made in December, but it is not solved yet.

Recently they said, they can’t reproduce it, but I hope they will look again.

Then make a new report. This one is private so probably won’t be looked at

I don’t know the bug reports workflow well.
This bug has IN REVIEW status, but I could not find it in issue tracker.
I made a fresh bug report, but I didn’t know how to make it public, and I fear it will stay as private again.

I hope they wouldn’t ban me for spamming the bug reporting portal:).

Ahhh sorry, if it’s still on jira it’s private untill confirmed. Then it’s just waiting

I cannot explain my feelings after I encountered such problem with so basic functionality for modern engines!
Lens Flare SRP just dont work!
There is at least TWO bugs!
If you enable Allow Offscreen along with Occlusion - it will make lens flare to be visible near the screen edges even through walls! I was pretty dissapointed with this bug so I just disabled Allow Offscreen and everything was looking right in the editor… but not in the android build. In the android build Lens Flare SRP are visible through walls even with occlusion enabled.

Two critical bugs for year(or more?) in something that should just work!
I just hate this entire company, how long we will suffer from such incompetence?
So much of half-working or non-working at all features that should be pretty basic for any modern engine. So much of issues :rage::rage::rage:

If you hate it this much, why still use it?
Getting mad gets no one nowhere. Best thing to do is to report issues and try to get people to vote on them if they are public.
Or if you feel like other engines do this better, use those

Thanks for advice, this is really so helpful for peoples like me. We stuck here because of our commercial work projects. You better ask why I cannot enjoy it, instead of pushing away anyone who suffer from its services when its not so simple to leave.