How to achieve Terraria/Starbound 2d lighting?

浪尽此生 提交于 2019-12-08 05:27:10

问题


I am making a 2d game in the perspective of Terraria/Starbound. I want the lighting to look similar to this:

Ive tried to get lighting like this by adding a material on all the sprites in my game and then giving them a sprite diffuse shader. Then I made a point light wherever I needed light. There where two problems with this though: 1) Where the light was most intense, it was draining the color of a sprite and made it lighter. 2) I noticed a big FPS drop (And I only had 1 point light!).

Is there any way of achieving lighting like this without having to write my own lighting engine? Ive search the asset store and Ive searched to see if unity has any way of handing 2D lighting from this angle but I have found nothing.

If I do have to write my own lighting engine, would that be to complex for someone who is relatively new to unity and has only had ~ 8 months experience?


回答1:


Assume you are using tile map.

You need to have a field of view map, which can be achieved by reading this: http://www.redblobgames.com/articles/visibility/

Using such map, you know exactly the color tinting for each tile. Now, just blend the color to the SpriteRenderer of every tile on the map.

Somebody already created a line of sight plugin: http://forum.unity3d.com/threads/light-of-sight-2d-dynamic-lighting-open-source.295968/



来源:https://stackoverflow.com/questions/31736654/how-to-achieve-terraria-starbound-2d-lighting

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!