Jump to content

  • Log In with Google      Sign In   
  • Create Account

2D Tile Based Lighting


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Xanather   Members   -  Reputation: 712

Like
0Likes
Like

Posted 03 November 2012 - 11:02 PM

How would one go about creating a 2d tile based lighting, just like the one in terraria?

Terraria's lighting seems to have more than just one lighting algorithm. Or maybe its custom made? I have no idea. Ive been searching on the internet for a day now looking on how implement such lighting. I just cant get my head around it, the light actually looks for places to travel though, it seems like, in order to light up a cave/tunnel, even if the character is not in field of view of this cave (i.e. cave is around a corner).

If anyone could give me great resources, links, websites, or actually explain what is happening (it doesn't need to be in C#), that would be extremely appreciated as I am starting to get frustrated about this subject. I have implemented line of sight lightning, but most of the time it looks horrible.

Thanks, Xanather.

Sponsor:

#2 Waterlimon   Crossbones+   -  Reputation: 2637

Like
0Likes
Like

Posted 04 November 2012 - 08:52 AM

It probably uses the same method as minecraft uses for torches. The light basically floods the tiles from the source tile, weakening on every jump. Kind of like how you figure out the costs of paths when doing A* pathfinding.

there might also be a separate way to add sunlight (in mc it lights all tiles visible to sky i believe, and treats each such tile and all the air tiles as light sources) and maybe some "real time" GPU side lighting to make it look better (where the tile-spreading lighting would be an approximation for lightness of spaces and the GPU rendered fancy lighting would make it look good if youre lets say carrying a torch)

o3o


#3 dEgle   Members   -  Reputation: 131

Like
0Likes
Like

Posted 04 November 2012 - 10:35 AM

You can also make multiple "light" blocks inside one tile. Light block can have 3 bytes for color and a byte for light level.
To make it faster recalculate only if there are moving lights (like torch in hand).

If you use GPU to render fancy lights then you don't need much light blocks. Only for spawning mobs for example...

Be creative and you can make your own lighting engine, even more fancy than terraria has!

#4 Xanather   Members   -  Reputation: 712

Like
0Likes
Like

Posted 04 November 2012 - 08:22 PM

Ok thanks for the replies, re-digit probably did the same (made up his own).

#5 BeerNutts   Crossbones+   -  Reputation: 2999

Like
0Likes
Like

Posted 05 November 2012 - 04:48 PM

Hi Xanther,

I have experimented with a lighting system and I would suggest you at least take a look at it:
Journal entry
(This is for C++, so if you're using something else, it's probably not valid)

For that particular game, it didn't have to worry about caves and shadows, but the lighting engine does have that capability. Check the links in the journal for more information.

Good luck!
My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS