2D Tile Based Lighting
Members - Reputation: 753
Posted 03 November 2012 - 11:02 PM
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.
Crossbones+ - Reputation: 3188
Posted 04 November 2012 - 08:52 AM
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)
Members - Reputation: 131
Posted 04 November 2012 - 10:35 AM
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!
Crossbones+ - Reputation: 3457
Posted 05 November 2012 - 04:48 PM
I have experimented with a lighting system and I would suggest you at least take a look at it:
(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.
---(Old Blog, still has good info): 2dGameMaking
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)