Search Unity

URP 2D Lights for Isometric Tilemap

Discussion in '2D' started by flippi273, Feb 18, 2020.

  1. flippi273

    flippi273

    Joined:
    Nov 17, 2018
    Posts:
    24
    I'm currently working with an Isometric Tilemap and I wanted to add the new 2019 URP 2D Lighting, and so I did following the Unity Tutorial.

    Overall I am very pleased:
    upload_2020-2-17_20-33-23.png

    But I wanted to improve the shape of the light to make it more isometric. In order to do this I need an ellipse (oval) instead of a circle.

    I tried to make an ellipse using the freeform light, but I quickly noticed that the falloff doesn't keep my 2:1 ratio. What I mean by that is in the isometric style I'm doing, tiles are 2 times wider than they are tall.

    To further illustrate what I mean, we can look at the shape and falloff with a diamond as that's a traditional tile shape for isometric:
    upload_2020-2-17_20-36-42.png

    As you can see, my freeform shape is a 2:1 diamond, but (unless my eyes are deceiving me) the falloff shape is a 1:1 diamond.

    So because of the falloff not keeping the right ratio, the lighting (regardless of actual shape) will not look isometric, as illustrated in this screenshot using the 2:1 diamond freeform shape:
    upload_2020-2-17_20-41-23.png


    As I mentioned originally, I'm super excited with how easy it was to use the new URP and 2D lights. At this point I am wondering if there is something that I missed to enable the right ratio for isometric lighting.

    Thanks for the read and any suggestions!
     
  2. flippi273

    flippi273

    Joined:
    Nov 17, 2018
    Posts:
    24
    I've been focusing on other aspects of my game and of course thinking about this still on the side. Best idea I've gotten is to use a sprite light type and create my own ellipse sprite.

    Has anyone had any other thoughts?
     
  3. Derekloffin

    Derekloffin

    Joined:
    Mar 14, 2018
    Posts:
    322
    Unfortunately, I have only the most limited knowledge of shaders and lighting at the moment, so can't really solve your problem, but I highly suspect your solution will require you to edit the shader. As I recall, you can actually get at the shader code (it isn't black boxed), and since you're looking for a fairly simple mod that is global in effect (ie you're not mixing iso lighting with flat lighting which requires circles) I suspect the edit to the shader should be simply a matter of putting multiple by 2 or div 2 somewhere when it considers the Y coordinate, but I can't say for sure.
     
    OldMage likes this.
  4. flippi273

    flippi273

    Joined:
    Nov 17, 2018
    Posts:
    24
    Thanks for the details! I haven't had a chance to look into this yet since there is plenty of things to still do besides the lighting. When it's time to move back to working on the lighting I'll give this a shot and update the post with my findings.
     
  5. Derekloffin

    Derekloffin

    Joined:
    Mar 14, 2018
    Posts:
    322
    Best of luck. I'm also working in a isometric game, and I'm very soon to be implementing lighting myself, so if you have success I'm definitely interested.
     
  6. flippi273

    flippi273

    Joined:
    Nov 17, 2018
    Posts:
    24
    Just wanted to let you know I've still not had time to move back onto this - it's been moved to a "polish" priority, so I'm not yet sure when I'll get to this.

    If you happen to get to it before me please do share your results as will I.
     
  7. Derekloffin

    Derekloffin

    Joined:
    Mar 14, 2018
    Posts:
    322
    Oh, I will, lighting has been on my 'next thing... honest' list for like 2 months now... damned ramps are kicking my ass. Every time I think I got it, I discover a new bug.
     
    flippi273 likes this.
  8. Oscar2022

    Oscar2022

    Joined:
    Jan 24, 2022
    Posts:
    1
    You can use a sprite of an ellipse that has a gradient on it. Just set the 2d light component as sprite light and mess with the settings a bit. upload_2022-2-20_16-6-49.png upload_2022-2-20_16-8-26.png
     
    MaxwellTan likes this.
  9. flippi273

    flippi273

    Joined:
    Nov 17, 2018
    Posts:
    24
    Very nice! Thanks for sharing!

    Also is that your game? I like the style!