Home Unity

Confused about Ignore Layers with Lens Flares

I have a Unity scene for demonstrating in VR how different kinds of window shades will block different amounts of sunlight. This is eventually going to help architects choose shades for their buildings.

Everything's great, except I can't get my Lens Flares to render properly. :(

  • I want the cross-shaped Lens Flare to only appear overtop the window shade (not over the clear glass below it).
  • I want the round-soft-circle Lens Flare to only appear over the clear glass below the shade (not over the window shade above it).

But the Ignore Layers dropdown seems to act erratically. Anyone else have experience or tips for using this?

  1. Window glass = set to Layer "Glass", and box collision added.
  2. Window shade = set to Layer "Shade", and box collision added.
  3. Directional Light "GlassLight" = set to Layer "Glass".
  4. Directional Light "GlassLight" Lens Flare component = set to Ignore Layers "Glass".
  5. Directional Light "ShadeLight" = set to Layer "Shade".
  6. Directional Light "ShadeLight" Lens Flare component = set to Ignore Layers "Shade".

What it's supposed to look like:


Replies

  • Eric Chadwick
    OK got it to work finally.

    • "Ignore Layers" actually seems to mean the opposite... "only render on top of this layer". 
    • The window shade and the window glass each need a collision component.
    • But... the collisions shouldn't overlap. I ended up linking an invisible "glass" collider to the bottom of the shade, so it raises and lowers along with the shade.

    I still wish though that I could mask the flare to only appear actually on the shade mesh, and not bleed over the edge to appear over the glass too. Oh well, close enough.
  • cptSwing
    Offline / Send Message
    cptSwing polycounter lvl 11
    You need collision boxes to decide where the flare shows? That's mad, would never have considered it.
  • Eric Chadwick
    Yeah, help says "Lens Flares are blocked by Colliders. A Collider in-between the Flare GameObject and the Camera will hide the Flare, even if the Collider does not have a Mesh Renderer."

    I guess I should have understood that it doesn't care about which collider is in front of another. If the ray hits one, it stops, period.
Sign In or Register to comment.