如何实现Terraria / Starbound 2d照明? [英] How to achieve Terraria/Starbound 2d lighting?

查看:114
本文介绍了如何实现Terraria / Starbound 2d照明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从Terraria / Starbound的角度制作2D游戏。我希望照明看起来与此类似:

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

我尝试通过在所有材质上添加材质来获得这种照明我游戏中的精灵,然后给它们一个精灵漫射着色器。然后,在需要照明的地方都设置了点光源。但这有两个问题:1)在最强烈的光线下,它会耗尽精灵的颜色并使它变亮。 2)我注意到FPS大幅下降(而且我只有1点光源!)。

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!).

有什么方法可以实现这样的照明而无需编写自己的照明发动机?我已经搜索了资产商店,我已经搜索了统一性是否可以从这个角度处理2D照明,但是我什么都没找到。

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.

如果我必须写我的自己的照明引擎,对一个刚接触统一并且只有大约8个月经验的人来说,会变得复杂吗?

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?

推荐答案

假设您使用的是瓷砖地图。

Assume you are using tile map.

您需要有一个视野地图,可以通过阅读以下内容来实现: http://www.redblobgames.com/articles/visibility/

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

使用这种贴图,您可以确切地知道每个图块的颜色。现在,只需将颜色混合到地图上每个图块的SpriteRenderer。

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.

有人已经创建了视线插件:
http://forum.unity3d.com/threads/light- of-sight-2d-dynamic-lighting-open-source.295968 /

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

这篇关于如何实现Terraria / Starbound 2d照明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆