Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

URP flares don't work with Shuriken Light module

Discussion in '2021.2 Beta' started by michalpiatek, Oct 4, 2021.

  1. michalpiatek

    michalpiatek

    Joined:
    Feb 26, 2021
    Posts:
    81
    New lens flares seems to not be working when attached to a light which is used by the built-in Shuriken particle system. Lights are definitely being rendered and have lens flare component attached but the lens flare effect is not being rendered at all. Is this a planned feature?
     
    Last edited: Oct 11, 2021
  2. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    Hi @michalpiatek_uw,

    Thanks for flagging, this might be a bug. We'll have a look.
     
    michalpiatek likes this.
  3. michalpiatek

    michalpiatek

    Joined:
    Feb 26, 2021
    Posts:
    81
    Just to clarify, those are repo steps
    1. Create a Lens Flare asset so it has some visuals
    2. Create a light, attach Lens Flare component to it and use your lens flare definition
    3. Create a particle system (shuriken)
    4. Make the light with lens flare component a child of the particle system and disable the entire light game object (this is a common and totally expected workflow)
    5. Now, in the particle system Lights module, assign the light you created as the light used by the particle system
    7. Set the Ratio param in the Lights module to 1
    8. Notice that lights will work as expected (they will cast light) but lens flares will not work.

    Obviously this is on a project with URP and Lens Flares added to the rendering pipeline definition.
    particle_system_and_lens_flares.jpg
     
    LeonhardP likes this.
  4. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    Unfortunately weren't able to reproduce this and there's a need for some clarifications to your provided reproduction steps. Could you please submit a bug report with a reproduction project attached and share the issue ID here so we can follow up?
     
  5. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    Re: step 4. The preferred workflow is to assign a light prefab from the project folder, not something that is instantiated already.

    (This is totally unrelated to the lens flare query, just a random FYI) :)
     
  6. michalpiatek

    michalpiatek

    Joined:
    Feb 26, 2021
    Posts:
    81
    Huh, I've been keeping a disabled light game object in the hierarchy of my effects for years now. Good to know I can just plug in a prefab :D

    I made a bug report, case 1375662
     
    LeonhardP and richardkettlewell like this.
  7. michalpiatek

    michalpiatek

    Joined:
    Feb 26, 2021
    Posts:
    81
    The ticket has just been closed as won't fix due to limitations of the implementation.
    Does it mean it might be added at a later date or it's just not feasible and won't be looked at? Cheers!
     
  8. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    I think it's not going to be feasible ever (I passed that note to QA).

    Internally, both the old (BiRP) and new (URP) lens flares rely on Components being added to GameObjects.

    However, particle lights don't use a full GameObject/Component per light. Instead, they inject lightweight internal light objects into the renderer at the right moment in the rendering pipeline. This is to avoid having the performance overhead of a full GameObject per light, if you have lots of them. It seems this approach comes with downsides though, as you've just found.

    As a workaround, I would suggest 2 things:

    1. For BiRP, maintain your own list of GameObjects, set their positions using ParticleSystem.GetParticles, and add LensFlare components to those GameObjects.

    2. For URP, I'm advised by the URP team that you can call LensFlareCommonSRP.Instance.AddData and LensFlareCommonSRP.Instance.RemoveData when flares are created/destroyed. You could perhaps call those yourself for each particle, although admittedly it can be hard to robustly detect when particles are created/destroyed. We never did add a good event system for the Particle System.... but perhaps option 1 also works for URP (maintain your own GameObject pool)
     
    michalpiatek and LeonhardP like this.
  9. michalpiatek

    michalpiatek

    Joined:
    Feb 26, 2021
    Posts:
    81
    Makes sense. It would indeed be much easier to work around this with an event system but I can probably make something that works in the context of my project without it. I will only ever need one to two flares loosely synced with the particle system and that should be easy enough to simulate in Edit mode.

    Thanks for the explanation.
     
    richardkettlewell likes this.