Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Best Way to Achieve "Glowing Eyes" Effect? (2D, Pixel Art)

Discussion in 'General Graphics' started by AlexHntk, Nov 7, 2023.

  1. AlexHntk

    AlexHntk

    Joined:
    May 6, 2015
    Posts:
    59
    Hey, I'm just wondering what the best way would be to achieve the following:

    I have an animated enemy sprite, and I wanted the eyes to be prominent and glowing while the rest of the sprite is standard diffuse.

    My initial thoughts of how I might achieve this:

    Method 1:
    Two point lights, manually script different Vector2 positions to have the lights parent object TransformMove through. Seems easiest in terms of time to setup but probably least performant.

    Method 2:
    Create a separate animation of just the eyes, playing in sync and over-top of the base enemy. This way I can change the shader of the eyes as needed, seems like the best way to go, though some syncing issues may crop up.

    Method :
    Changing the sprites Eyes to a color not used, like hot-hot pink, and using something like the All-In-1-Sprite-Shader to select the color, and replace shader on this new selection - this one, I have no idea if it's possible or sensible, just a thought that occurred to me to think of.

    Any input or insight would be greatly appreciated :)
     
  2. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,575
    Glowing stuff is typically done using emissive materials and bloom post-processing. No need for lights.
     
    arkano22 likes this.
  3. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,841
    To add to kdgalla's answer: if you don't want to use bloom post-processing just for the eyes, a couple quads with additive blending will work wonders. Similar to your point lights idea, minus the cost of actual point lights.
     
    kdgalla likes this.
  4. AlexHntk

    AlexHntk

    Joined:
    May 6, 2015
    Posts:
    59
    This makes sense for a 3D environment, how would this apply to 2D situations?
     
  5. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,841
    It's exactly the same in 2D.

    Bloom is an image post-process, doesn't matter if the scene depicted in the image is 2D, 3D, a video, whatever.
     
  6. AlexHntk

    AlexHntk

    Joined:
    May 6, 2015
    Posts:
    59
    Totally - but how would one "target" the bloom to just the eyes, for example, of an animated sprite? I'd have to assume this is Method 2. Roundabout way to answer the original question! Just looking to see any different implementations that may exist.
     
  7. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,575
    It's impossible to target a specific object with bloom since it is a post-effect. If you want the eyes to be only thing glowing, then you have to adjust the brightness off the emissive color of the eyes and the threshold of the bloom so that the eyes are the only thing above the threshold.
     
    arkano22 likes this.
  8. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,841
    Again, same way you do it in 3D: by giving the sprite's material an emissive channel. In this channel, only the eyes are of a color other than black.

    I don't know if Unity's built-in sprite material has emissive, but if it doesn't creating one that does is pretty simple:

     
    Last edited: Nov 8, 2023
  9. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,575
    You might also consider going with arkano22's first suggestion of using additive blending. There should be a built-in particle shader that does this. You would just have to make the texture yourself.