Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Starbound / Terraria Style Lighting

Discussion in '2D' started by BlueSin, May 10, 2015.

  1. BlueSin

    BlueSin

    Joined:
    Apr 26, 2013
    Posts:
    137
    So I am currently developing a 2D sandbox game similar to Terraria and Starbound. I would like to set up the lighting for the game at this point similar to that of the games mentioned above. I have never done lighting before so I am curious if there are any guides or methods or anything out there that anybody might suggest.

    Here is what we have right now:



    Lighting used is just a simple directional light. We are looking for something more like this:



    As you can see in the second screen shot (Starbound), the light does not penetrate all the way through the terrain. Almost like a fog of war type of effect going on there, except instead of showing previously explored areas it only shows illuminated areas. I am curious how this effect might be achieved, any and all help is appreciated!

    P.S. - We are currently using a mesh based system for loading chunks of blocks near the player. Block data is saved to map file in the form of a multi-dimensional array of ushorts (for blockID) that makes up the walls and fronts.
     
  2. kuchaku

    kuchaku

    Joined:
    Oct 14, 2014
    Posts:
    37
    Currently I have had some degree of success with

    1. Using a flood fill algorithm similar to the one in the last post here:

    http://www.java-gaming.org/index.php?topic=26363.0

    2. Using draw SetpPixels32 to create a trilinear texture map and layering it over.

    However, I have had significantly difficulty in finding a way to only layer this shadow over the foreground elements and not the sky/background elements with any efficiency. You can check out my currently slow pixel shader discard method here:

    http://forum.unity3d.com/threads/ca...f-a-cameras-background-is-transparent.321090/

    I'm still going to work on another method when I get the time, but if someone knows a more efficient method, I'd appreciate this, myself.