Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

2D

Discussion in '2D' started by SolidusSnake, Mar 30, 2015.

  1. SolidusSnake

    SolidusSnake

    Joined:
    Mar 30, 2015
    Posts:
    2
    1
     
    Last edited: Aug 10, 2017
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    There are several different ways to accomplish this.
    This information is available in this forum and in other areas of the web. Just have to look.
     
  3. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    The problem is, with pixel data, you start out with black and you want to render colored objects, which normally would all be lit, but then you only want certain parts to be lit. So usually you have to draw the shadows.

    But there are more advanced ways. E.g. with a render texture and separate camera, draw the `light` first, then feed that texture back into a shader used to draw the objects, and with the proper uv coords etc you can blend the two by multiplying their pixel values.
     
  4. Jonathan-Watkins

    Jonathan-Watkins

    Joined:
    Mar 10, 2015
    Posts:
    125
  5. hasen

    hasen

    Joined:
    Apr 1, 2015
    Posts:
    29
    That asset seems to do the opposite, it shines shadows.
     
  6. Jonathan-Watkins

    Jonathan-Watkins

    Joined:
    Mar 10, 2015
    Posts:
    125
    What I'd do is fake it by drawing the light rays in Inkscape, (I added a simple gradient so that it appears to fade out)

    Sorta like this -
    rgradray.png

    Import it into Unity as a Sprite,

    And Set the Alpha to like 100.

    The Results look similar to the images above (I put this scene together real quick to show what it would look like) lightrayfakescene.PNG

    Of course if you put extra minutes of work in the drawing it would look much better, but this is just to show how easy it is to achieve the effect you want without any coding...

    BTW could you pls tell me what games the last two images you attached came from?
     
    theANMATOR2b likes this.