名派照明连接天猫精灵

Sprites in Daedalus make use of Unity’s lighting system to appear with 3D-like properties.

Daedalus中的Sprite利用Unity的照明系统显示具有类似3D的属性。

Since Unity treats Sprites as flat 3D surfaces, it can do this by applying a shader in the sprite’s material that accepts a normal map, and using that normal map to calculate how light should be applied. But what does that all mean, and what how does one actually do it? I’m first going to talk about the technical details, but if you’re already familiar you can skip the next section on making normals.You can also find a link to the shader I’m using at the start of the final section.

由于Unity将Sprite视作平面3D曲面,因此可以通过在接受标准图的Sprite材质中应用着色器,然后使用该法线图来计算应如何应用光,来实现此目的。 但是,这一切意味着什么,一个人实际上是怎么做的呢? 我将首先讨论技术细节,但是如果您已经很熟悉,则可以跳过下一节中的制作法线。您也可以在最后一节的开头找到我正在使用的着色器的链接。

法线和法线贴图 (Normals and Normal Maps)

The protagonist Rix, in her glorious 3-D view.
主角里克斯(Rix),以她灿烂的3D视角。

First, let’s talk about what a normal map is and what it’s used for. 3D surfaces have a surface normal, that is, the direction perpendicular to the plane of the surface. In Unity2D, that plane is almost always the X-Y plane (green and red arrows), making the normal vector purely in the Z direction.

首先,让我们讨论一下法线贴图是什么以及它的用途。 3D表面具有表面法线,即垂直于表面平面的方向。 在Unity2D中,该平面几乎始终是XY平面(绿色和红色箭头),从而使法向矢量完全在Z方向上。

When people first started rendering 3D environments and assets, their computers couldn’t afford to render many different surfaces. Early 3D games are famous for having an extremely blocky aesthetic. One way to get around this is a shader that uses vertex information to estimate lighting and interpolate it.

人们最初开始渲染3D环境和资产时,他们的计算机负担不起渲染许多不同的表面。 早期的3D游戏以极高的美观性而闻名。 解决此问题的一种方法是使用顶点信息来估计照明并对其进行插值的着色器。

Gouraud shading, from Wikipedia
Gouraud底纹,来自维基百科

It works by using the normals of the vertices rather than the surfaces, and interpolating between them to estimate the lighting at each pixel.

它通过使用顶点的法线而不是表面的法线并在它们之间进行插值来估计每个像素处的光照来工作。

This is fine for procedural or pattern based deviations, but not arbitrary ones.
这对于基于过程或模式的偏差很好,但不适用于任意偏差。

However, for a much finer grade control we can use a special shader with a normal map. A normal map is a texture that describes modifications to a surface’s normal.

但是,为了更好地控制坡度,我们可以使用带有法线贴图的特殊着色器。 法线贴图是描述对表面法线的修改的纹理。

Left: 3D shapes. Center: Normal map based off those shapes. Right: flat surface shaded with the normal map (from wikipedia)
左:3D形状。 中心:基于这些形状的法线贴图。 右:用法线贴图阴影的平坦表面(来自维基百科)

Psychadelic! But what’s up with those colors exactly? And why is it all so purple?

Psychadelic! 但是这些颜色到底是怎么回事? 为何一切都这么紫色?

As you may have figured out, the normal map is mapping color to different normals. Since color is represented as a 3 part vector of Red, Green, and Blue, it makes sense to map these colors to their respective directions of X, Y, and Z (you can even see this mapping in the Unity3D view picture above).

您可能已经知道,法线贴图会将颜色映射到不同的法线。 由于颜色表示为红色,绿色和蓝色的三部分向量,因此将这些颜色映射到它们各自的X,Y和Z方向是有意义的(您甚至可以在上面的Unity3D视图图片中看到此映射)。

Let’s take a look at the different color values to see what’s going on. There are a few things interesting about these values. First, the center of the sphere and the background color are the same. Second, the blue value ranges from 50% to 100%, but the red and green use the whole spectrum. Why?

让我们看一下不同的颜色值,看看发生了什么。 这些值有一些有趣的事情。 首先,球心和背景色相同。 其次,蓝色值的范围从50%到100%,但是红色和绿色使用整个光谱。 为什么?

Color values of the sphere normal map
球面法线贴图的颜色值

The mapping of 0 through 255 of a color value is mapped to the -1 to +1: a value of 128 is mapped to 0. This means that a normal vector of (0,0,1) will map to (128, 128, 255), which happens to be the background color. Remember how the normal of the 2D surface was entirely in the Z direction? That means that a light ray shining into the surface normal will be reflected back along the surface normal. A color that’s 50%R, 100%G, 50%B will face up (positive Y); a color that’s 75%R, 25%G will face to the bottom right; 0%R, 50%G will face to the right, and so on.

颜色值从0到255的映射映射到-1到+1:将值128映射到0。这意味着法向矢量(0,0,1)将映射到(128,128 255),恰好是背景色。 还记得2D表面的法线如何完全在Z方向上吗? 这意味着,照射到表面法线的光线将沿着表面法线反射回去。 颜色为50%R,100%G,50%B的颜色会面朝上(正Y); 右下角为75%R,25%G的颜色; 0%R,50%G将朝右,依此类推。

Left: In game view. Center: Unmodified sprite. Right: Normal map
左:在游戏视图中。 中心:未修改的精灵。 右:法线贴图

In this example, there is a light in the center of the console. Rix is lit up on her chest, her chin, and the bright pink part of her hair. Given this, we would expect the normal map to have a color on her chest that looks like the right of the sphere example, a color on her chin that looks like the bottom-right of the sphere example, and a color on her pink hair highlight that resembles the top-right of the sphere example. Not only does this all check out, but other body parts like her elbow are colors that face away. Nice!

在此示例中,控制台中央有一个灯。 Rix的胸部,下巴和头发的亮粉红色部分都亮了起来。 鉴于此,我们希望法线贴图的胸部上的颜色看起来像球形实例的右侧,下巴上的颜色看起来像球形实例的右下角,粉红色的头发上的颜色突出显示,类似于球形示例的右上角。 不仅可以检查所有这些,而且其他身体部位(例如她的肘部)的颜色也会面朝远方。 真好!

创建法线贴图 (Creating a Normal Map)

There are 3 ways I’ve explored of making a normal map: using an external tool, drawing a height map by hand, and drawing a normal map by hand.

我探索了三种制作法线贴图的方法:使用外部工具,手动绘制高度图和手动绘制法线贴图。

For the first, I’m going to plug a tool I think is phenomenal, SpriteDLight.

首先,我将插入一个我认为非常出色的工具SpriteDLight 。

Autogenerated normals by Sprite DLight
Sprite DLight自动生成的法线

This app can take in a sprite sheet, gives you a few options as to how sharp and deep the bumps are, and spits out a normal map sheet that can even be previewed within the program! It takes into account differences edge differences between different colors and the transparency, and is excellent for characters.

这个应用程序可以放入一个精灵表,为您提供一些关于凹凸的深度和深度的选项,并吐出一个普通的地图表,甚至可以在程序中预览它! 它考虑了不同颜色和透明度之间的边缘差异,非常适合字符。

Since sprite sheets are a bit of a different animal, I tried two ways of making normals for them: converting from height hand painted height maps, and pure hand painted normals.Let’s take a look at a section of the ship’s sprite sheet to see what we’re giving normals to:

由于精灵板有点不同,我尝试了两种制作法线的方法:从高度手绘的高度图转换为纯手绘法线,让我们看一看船上精灵板的一部分以了解什么我们给法线:

A section of the ship tilemap.
船舶图块的一部分。

In a height map, the brightness of a color corresponds inversely with its depth: darker colors are deeper. They don’t have to be grayscale, but the system I believe only looks at a colors brightness regardless. They work best when the sprite sheet contains no unnatural logical transitions: when you put tiles next to each other that are of different heights and would NOT be next to each other in games, you can get some problems.

在高度图中,颜色的亮度与其深度成反比:深色越深。 它们不必一定是灰度的,但是我相信系统无论如何都只会看到颜色的亮度。 当Sprite表中不包含不自然的逻辑过渡时,它们的工作效果最佳:当您将高度不同且彼此不相邻的图块彼此相邻放置时,可能会遇到一些问题。

A height map
高度图

As you can see, the map is not entirely filled out because I soon realized the process would not work well on my particular sprite sheet, and that it might be hard to make sheets that meet the requirements listed above. After trying this out, I instead began to hand paint normals, using a palette of 17 colors, and this worked out much better for me:

如您所见,地图并未完全填写,因为我很快意识到该过程无法在我的特定Sprite工作表上很好地工作,并且很难制作满足上述要求的工作表。 经过尝试之后,我开始使用17种颜色的调色板来手工绘制法线,这对我来说要好得多:

Hand painted normals
手绘法线

This is the approach that I would generally recommend for people: it doesn’t take a lot of understanding to make work, and one can paint with fairly broad and non-detailed strokes to get a good result.

这是我通常向人们推荐的方法:进行工作不需要太多的理解,并且可以使用相当宽泛且不详细的笔触进行绘画以获得良好的效果。

在Unity中使用法线贴图 (Use a Normal Map in Unity)

The current normal map shader I’m using , which I hope to find the original source for soon, uses a bump map argument, “Normalmap”, to shade both sides of a Sprite (for users that flip sprites by multiplying the X scale by -1).

我正在使用的当前法线贴图着色器(希望尽快找到原始源)使用凹凸贴图参数“ Normalmap”来对Sprite的两侧进行着色 (对于将X比例乘以-1)。

When one creates a new Sprite via the Create menu, Unity populates it with a few default options, including the “Sprites-Default” Material which uses the “Sprites/Default” shader.

当通过“创建”菜单创建新的Sprite时,Unity会用一些默认选项填充它,包括使用“ Sprites / Default”着色器的“ Sprites-Default”材质。

Further information can be found at Unity’s rather nice documentation page on normal maps. To sum up, you’ll need a material with a shader that uses a normal map, attach that to your sprite object, and supply your custom normal map in the normal map argument. Pop a few lights into your scene and viola, dynamic lighting!

可以在Unity的法线贴图文档页面上找到更多信息。 综上所述,您需要一种材质球,该材质球使用法线贴图,将其附加到您的Sprite对象上,并在法线贴图参数中提供自定义法线贴图。 将几盏灯射入场景,中提琴和动态照明!

Parts of the environment with normal maps applied.
应用了法线贴图的环境部分。

If you liked this, consider giving me a follow on Twitter! I can be found @thedeivore and I post updates to this and other projects as often as I can.Thanks for reading!

如果您喜欢这个,请考虑在Twitter上关注我! 可以在@thedeivore上找到我,并且我会尽可能频繁地发布此项目和其他项目的更新。感谢阅读!

翻译自: https://medium.com/swlh/dynamic-sprite-lighting-in-unity-1fa6de78b3b8

名派照明连接天猫精灵


http://www.taodudu.cc/news/show-6843565.html

相关文章:

  • google浏览器的简单使用方法
  • BTC源码分析 脚本(一)
  • TokenGazer | BTC 8月8日数据分析
  • 自定义BTC找零地址
  • 使用 java 根据 insight-api 获取 BTC一些基本信息
  • BTC 安装和使用笔记
  • Ubuntu系统下BTC服务安装
  • BTC-实现
  • BTC transaction rawtx 解析
  • C语言 UTC与BTC的时间换算
  • 双网卡访问外网和学校内网
  • 用自己的电脑搭建服务器并让外网访问。
  • 内网穿透(mac,window,linux通用)1分钟实现外网访问电脑本地服务器
  • 内网穿透,使本机电脑能够被外网访问
  • 关于win10、win11电脑同时使用有线、无线访问内网和外网的配置方法
  • 【内网穿透】外网访问内网电脑方案
  • ChatGPT想干掉开发人员,做梦去吧
  • java ee框架学那个_Java EE三在主流框架是什么?_学小易找答案
  • 你必须理解的三大软件原则2_KISS
  • 必须理解的三大软件原则(2):KISS
  • 若干年来在CSDN回答问题的汇总(主要是excel,也有word)
  • tkinter绘制组件(12)——表格
  • canvas绘制表格数据
  • Unity 动态绘制表格 表格分页
  • Excel 绘制表格 详解!
  • latex 表格绘制
  • 用unity读取excel中的数据并绘制表格
  • 如何使用matplotlib绘制表格-plt.table()
  • Python为输出的数据绘制表格
  • canvas——绘制表格

名派照明连接天猫精灵_统一的动态精灵照明相关推荐

  1. 微博粉丝精灵_腾讯与精灵宝可梦公司宣布合作开发新游戏

    [环球网科技 记者 樊俊卿]上周,腾讯游戏通过官方微博发布消息称,腾讯游戏天美工作室群将与精灵宝可梦公司(The Pokémon Company)合作研发新款游戏.而精灵宝可梦公司官方微博转发了这条消 ...

  2. NodeMCU连接天猫精灵第二集——开发环境、运行条件、工作代码(基于Blinker点灯科技)

    NodeMCU连接天猫精灵第一集--硬件构架(基于Blinker点灯科技) 根据上面说的硬件部分已经搭建完成了,所以现在说一下软件开发,首先要有一个共识,NodeMCU是可以用Arduino IDE开 ...

  3. 人称小HomeKit的智汀,如何连接天猫精灵音箱?

    如何连接天猫精灵 1.在智汀家庭云APP内完成产品联网配置 根据APP内引导完成设备联网配置 2.配置天猫精灵 (如果您已经配置好了天猫精灵,您可以跳过这一步) ① 下载并安装天猫精灵APP. ② 注 ...

  4. 【TB-02 Kit 蓝牙Mesh连接天猫精灵】 --AT固件适配任意设备(风扇空调饮水机)

    摘要 这篇文章主要介绍了如何使用天猫精灵AT固件对接天猫精灵音箱,包括如何烧录三元组,解析串口数据,上报状态,解除绑定,与手机通信等等.硬件主要基于安信可TB-02 Kit开发板,采用的是泰凌微(Te ...

  5. TB-02_Kit 开发板连接天猫精灵

    TB-02_Kit 开发板简介 Tb-02_Kit是安信可设计的一款蓝牙开发板,支持二次开发,串口烧录.除了基础蓝牙功能外,还支持BLE Mesh,可连接天猫精灵. 安信可串口烧录工具 TBXX_Fl ...

  6. 连接手表_FERACE手表新玩法:连接天猫精灵

    天猫精灵! "懒鬼!该动动啦" FERACE手表只是适用于"抛开手机去运动"? 那怎么能成? 我们和大家一起不断探索新的玩法! FERACE飞锐思 连接天猫精灵 ...

  7. stm8/stm32如何通过ESP8266连接天猫精灵和小爱同学,实现(AT指令)语音助手控制硬件设备

    stm8/stm32如何通过ESP8266连接天猫精灵和小爱同学,实现(AT指令)语音助手控制硬件设备 博主还是菜鸟,只是这段时间DIY弄了这些东西,让同样喜欢动手的朋友有个参考,我这个开发超级简单, ...

  8. python动画精灵_【python游戏编程之旅】第六篇---pygame中的Sprite(精灵)模块和加载动画...

    本系列博客介绍以python+pygame库进行小游戏的开发.有写的不对之处还望各位海涵. 直到现在我们已经学了很多pygame基础知识了,从这篇博客开始我们将会学习pygame中高级部分,更多和精灵 ...

  9. 微信回调 java_详解APP微信支付(java后台_统一下单和回调)

    1.微信配置信息 global.properties 2.方法wxpay用于生成预支付订单信息 方法notifyWeiXinPay用于微信支付成功后的回调, 注意: 在手机端使用微信支付成功后,微信服 ...

最新文章

  1. LeetCode简单题之至少是其他数字两倍的最大数
  2. 金山android 杀毒软件,金山手机卫士
  3. OTA整包的制作流程(未完)
  4. python客户端和服务端通信
  5. golang如何生成随机数
  6. 曾火爆一时的五笔输入法,为什么彻底衰落了?
  7. paip.2013年技术趋势以及热点 v2.0 cae
  8. google_glog 安装和测试
  9. mysql基础-数据库连接、创建、删除、选择等基本操作详解(一)
  10. 云计算发展和容器息息相关丨阿里云、腾讯云争相抢镜【软件网每日新闻播报│第10-25期】
  11. Android开发中自定义表情并发送出去之经典的发送表情
  12. Coding and Paper Letter(八十七)
  13. 产品经理技术脑:URL
  14. 华科图书情报专硕考研复试与读研
  15. 【docker】Mac下oracle10g下载安装
  16. 程序员,你还没有软技能吗?难怪你不幸福
  17. Typora写作上传图失败怎么解决,利用图床教你解决问题
  18. git 分支操作总结
  19. 洛谷P5069 [Ynoi2015]纵使日薄西山(树状数组,set)
  20. 看过大佬们发的朋友圈之后,我相信:明天会更好,明年定会春暖花开

热门文章

  1. 学习笔记二:OSS上传视频截帧
  2. 数字字母特殊符号java_java正则匹配6-20位字母、数字、特殊符号最少满足其中两种...
  3. PostgreSQL:四. 数据表的基本操作
  4. 如何电涌保护器可以帮助笔记本电脑
  5. 阿里巴巴开源技术汇总:115个软件(三)
  6. html css变成赛博朋克风格按钮
  7. JAVA热启动插件Jrebel
  8. ES6新数据类型Symbol
  9. Java ArrayList 实现去重
  10. 大象高端营销:装饰公司积分制导入,让你的业绩翻番