Unity Lighting - Lighting overview 照明概述

Lighting overview

照明概述

In order to calculate the shading of a 3D object, Unity needs to know the intensity, direction and color of the light that falls on it.

为了计算3D物体的阴影,Unity需要知道落在它上面的光的强度,方向和颜色。

These properties are provided by Light objects in the scene. Different types of light emit their assigned color in different ways; some lights may diminish with distance from the source, and have different rules about the angle of light received from the source. The different types of light source available in Unity are detailed in Types of light.

这些属性由场景中的Light对象提供。不同类型的光以不同的方式发出其指定的颜色;有些灯可能会随距离光源的距离而减少,并且对从光源接收到的光的角度有不同的规则。 Unity中提供的不同类型的光源详见光源类型。

Unity can calculate complex, advanced lighting effects in various different ways, each suited to different use cases.

Unity可以以各种不同的方式计算复杂的高级照明效果,每种方法都适合不同的使用情况。

Choosing a lighting technique

选择照明技术

Broadly speaking, lighting in Unity can be considered as either ‘realtime’ or ‘precomputed’ in some way and both techniques can be used in combination to create immersive scene lighting.

一般来说,Unity中的灯光可以被认为是“实时”或“预先计算”的,并且两种技术都可以结合使用来创建逼真的场景照明。

In this section we will give a brief overview of what opportunities the different techniques offer, their relative advantages and individual performance characteristics.

在本节中,我们将简要概述不同技术提供的机会,其相对优势和个人性能特征。

Realtime lighting

实时照明

By default, lights in Unity - directional, spot and point, are realtime. This means that they contribute direct light to the scene and update every frame. As lights and GameObjects are moved within the scene, lighting will be updated immediately. This can be observed in both the scene and game views.

默认情况下,Unity中的灯光 - 方向,光点和点是实时的。这意味着他们为场景提供直接照明并更新每一帧。当灯光和GameObjects在场景内移动时,照明将立即更新。这可以在场景和游戏视图中观察到。

Realtime LightsThe effect of realtime light alone. Note that shadows are completely black as there is no bounced light. Only surfaces falling within the cone of the Spotlight are affected.

实时灯单独实时光的效果。请注意,阴影是完全黑色的,因为没有反射光。只有聚光灯锥体内的表面受到影响。

Realtime lighting is the most basic way of lighting objects within the scene and is useful for illuminating characters or other movable geometry.

实时照明是在场景内对物体进行照明的最基本方式,对于照亮角色或其他可移动几何图形非常有用。

Unfortunately, the light rays from Unity’s realtime lights do not bounce when they are used by themselves. In order to create more realistic scenes using techniques such as global illumination we need to enable Unity’s precomputed lighting solutions.

很遗憾的是,来自Unity实时灯的光线在被自己使用时不会反弹。为了使用全局照明等技术创建更逼真的场景,我们需要启用Unity的预计算照明解决方案。

Baked lightmaps

烘焙光照贴图

Unity can calculate complex static lighting effects (using a technique called global illumination, or GI) and store them in a reference texture map called a lightmap. This calculation process is referred to as baking.

Unity可以计算复杂的静态光照效果(使用称为全局照明或GI的技术),并将它们存储在名为光照贴图的参考纹理贴图中。这个计算过程被称为烘焙。

When baking a lightmap, the effects of light sources on static objects in the scene are calculated and the results are written to textures which are overlaid on top of scene geometry to create the effect of lighting.

烘焙光照贴图时,会计算场景中静态对象的光源效果,并将结果写入覆盖在场景几何图形之上的纹理以创建照明效果。

Left: A simple lightmapped scene. Right: The lightmap texture generated by Unity. Note how both shadow and light information is captured.
左:简单的光照贴图场景。 右图:由Unity生成的光照贴图纹理。请注意如何捕获阴影和光照信息。

These lightmaps can include both the direct light which strikes a surface and also the indirect light that bounces from other objects or surfaces within the scene. This lighting texture can be used together with surface information like color (albedo) and relief (normals) by the Shader associated with an object’s material.

这些光照贴图既可以包含撞击表面的直射光,也可以包含场景内其他物体或表面反射的间接光。这种照明纹理可以与表面信息一起使用,例如与物体材质关联的着色器的颜色(反照率)和浮雕(法线)。

With baked lighting, these lightmaps cannot change during gameplay and so are referred to as ‘static’. Realtime lights can be overlaid and used additively on top of a lightmapped scene but cannot interactively change the lightmaps themselves.

随着烘焙照明,这些光照贴图在游戏过程中不能改变,因此被称为“静态”。实时灯可以重叠并在光照贴图场景上叠加使用,但不能交互式更改光照贴图本身。

With this approach, we trade the ability to move our lights at gameplay for a potential increase in performance, suiting less powerful hardware such as mobile platforms.

通过这种方法,我们可以在游戏中交换灯光,以提高性能,适合移动平台等功能较弱的硬件。

See the Lighting window reference and Using precomputed lighting for more information.

Precomputed realtime global illumination

预先计算的实时全局照明

Whilst static lightmaps are unable to react to changes in lighting conditions within the scene, precomputed realtime GI does offer us a technique for updating complex scene lighting interactively.

虽然静态光照贴图无法对场景内照明条件的变化作出反应,但预先计算的实时GI确实为我们提供了一种交互式更新复杂场景照明的技术。

With this approach it is possible to create lit environments featuring rich global illumination with bounced light which responds, in realtime, to lighting changes. A good example of this would be a time of day system - where the position and color of the light source changes over time. With traditional baked lighting, this is not possible.

通过这种方法,可以创建具有丰富全局照明的照明环境,并带有反射光,实时响应照明变化。一个很好的例子就是一天的时间系统 - 光源的位置和颜色随着时间而变化。用传统的烘烤照明,这是不可能的。

A simple example of time of day using Precomputed Realtime GI.
使用预先计算的实时GI的时间的简单示例。

In order to deliver these effects at playable framerates, we need to shift some of the lengthy number-crunching from being a realtime process to one which is precomputed.

为了以可播放的帧速率传递这些效果,我们需要将一些冗长的数字从实时过程转移到预先计算的过程。

Precomputing shifts the burden of calculating complex light behaviour from something that happens during gameplay, to something which can be calculated when time is no longer so critical. We refer to this as an ‘offline’ process.

预先计算将计算复杂光照行为的负担从游戏过程中发生的事情转移到可以在时间不再那么关键时计算出来的事情上。我们称之为“离线”过程。

For further information, please see the lighting and rendering tutorial.

欲了解更多信息,请参阅照明和渲染教程。

Benefits and costs

好处和成本

Although it is possible to simultaneously use Baked GI lighting and Precomputed Realtime GI, be wary that the performance cost of rendering both systems simultaneously is exactly the sum of them both. Not only do we have to store both sets of lightmaps in video memory, but we also pay the processing cost of decoding both in shaders.\

虽然可以同时使用烘焙GI照明和预计算实时GI,但要小心同时渲染两个系统的性能成本恰好是它们的总和。我们不仅需要将两组光照贴图存储在视频内存中,还要支付在着色器中解码的处理成本。

The cases in which you may wish to choose one lighting method over another depend on the nature of your project and the performance capabilities of your intended hardware. For example, on mobile where video memory and processing power is more limited, it is likely that a Baked GI lighting approach would be more performant. On standalone computers with dedicated graphics hardware, or recent games consoles, it is quite possible to use Precomputed Realtime GI or even to use both systems simultaneously.

您可能希望选择一种照明方法而不是另一种照明方法的情况取决于项目的性质以及预期硬件的性能。例如,在视频内存和处理能力更加有限的移动设备上,烘焙GI照明方法可能更具性能。在具有专用图形硬件的独立计算机或最近的游戏控制台上,可以使用预计算实时GI,甚至可以同时使用这两种系统。

The decision on which approach to take will have to be evaluated based on the nature of your particular project and desired target platform. Remember that when targeting a range of different hardware, that often it is the least performant which will determine which approach is needed.

必须根据您的特定项目的性质和期望的目标平台来评估采取哪种方法。请记住,当瞄准一系列不同的硬件时,通常这是决定哪种方法是需要的性能最差的。

See also: Light Troubleshooting and Performance

来源: https://docs.unity3d.com/560/Documentation/Manual/LightingInUnity.html

原文地址:https://www.cnblogs.com/CloudLiu/p/9890000.html

时间: 2024-08-01 23:19:44

Unity Lighting - Lighting overview 照明概述的相关文章

翻译5 Unity Advanced Lighting

使用多个光源渲染支持多光源类型使用光照信息计算顶点光照了解球谐函数 上部分介绍了Unity的基本单个光源,现在学习多个光源参与渲染物体,使用Unity5.6.6f2 1 Include Files 为了给Shader增加支持多个光源,我们需要增加更多Pass通道.但是这些Pass最终包含了几乎完全相似的代码,为了避免代码的重复性,我们可以通过把着色器代码移动到一个CG文件,然后在Shader代码中引用该文件 在文件目录中手动创建一个MyLighting.cginc文件,再把FirstLighti

UVA 11400 Lighting System Design 照明系统设计

首先是一个贪心,一种灯泡要么全都换,要么全都不换. 先排序,定义状态d[i]为前面i种灯泡的最小花费,状态转移就是从d[j],j<i,加上 i前面的j+1到i-1种灯泡换成i的花费. 下标排序玩脱了... #include<bits/stdc++.h> using namespace std; const int maxn = 1e3+3; int V[maxn], K[maxn], C[maxn], L[maxn]; int d[maxn],r[maxn],s[maxn]; bool

Unity游戏框架搭建 (一) 概述

??为了重构手头的一款项目,翻出来当时未接触Unity时候收藏的视频<Unity项目架构设计与开发管理>,对于我这种初学者来说全是干货.简单的总结了一下,以后慢慢提炼. 关于Unity的架构有如下几种常用的方式. 1.EmptyGO: ??在Hierarchy上创建一个空的GameObject,然后挂上所有与GameObject无关的逻辑控制的脚本.使用GameObject.Find()访问对象数据. 缺点:逻辑代码散落在各处,不适合大型项目. 2.Simple GameManager: ??

【VR】Leap Motion 官网文档 Unity插件概述

前言: Leap Motion的官网文档已经有不少的热心网友参与了翻译,但没有覆盖官网文档的全部. 为迎合Unity VR的热潮与大家的学习需要,本博客将推出针对Unity方向的官方文档翻译系列. 本篇主要对Leap Motion的Unity插件及坐标系系统进行简述. 英文原文网址:https://developer.leapmotion.com/documentation/unity/unity/Unity_Overview.html 译文首发&持续更新:http://blog.csdn.ne

GHOST CMS -上下文概述 Context Overview

Context Overview上下文概述 Each page in a Ghost theme belongs to a context, which determines which template is used, what data will be available and what content is output by the {{body_class}} helper. Ghost主题中的每个页面都属于一个上下文,它决定使用哪个模板.哪些数据可用以及{{body_class}

Unity编辑器——01主菜单

学习笔记适合新手,如有错误请指正.?号处也请各位指点下,谢谢. File 文件:创建/打开/保存场景.创建/打开/保存工程.发布游戏 Edit 编辑:撤销.重做.剪切.复制.粘贴.运行.暂停.工程设置等 Asset 资产:创建导入资源 gameObject 游戏对象:创建各类游戏对象 Component 组件:为游戏对象添加各类组件 Mobile Input 手机输入:如果激活的话,运行场景时,可以用Unity Remote app远程移动终端替代鼠标键盘进行控制 Window 窗口:各类窗口

Unity 5 中的全局光照技术详解 (转载)

原文链接 本文整理自Unity全球官方网站,原文:UNITY 5 - LIGHTING AND RENDERING (文章较长,请耐心阅读)简介全局光照,简称GI,是一个用来模拟光的互动和反弹等复杂行为的算法,要精确的仿真全局光照非常有挑战性,付出的代价也高,正因为如此,现代游戏会先一定程度的预先处理这些计算,而非游戏执行时实时运算. 同一场景里:没有照明(左),只有直接光源(中),和有间接光源的全局光照(右)的表现,注意颜色如何在不同的表面进行光的"反弹",产生更真实的结果. 在本文

Unity 5 中的全局光照技术详解(建议收藏)

2015-07-01 10:43 编辑: cocopeng 分类:游戏开发 来源:Unity全球官方网站 1 47108 Unity 5全局光照技术 招聘信息: 资深软件研发工程师 嵌入式软件工程师 cocos2d-x休闲游戏开发 产品经理 Cocos2d-x游戏客户端开发 Java工程师 Cocos2d-x js高级开发工程师 Mac开发 应用开发工程师(iOS) 技术合伙人-后端工程师 高级iOS开发工程师 本文整理自Unity全球官方网站,原文:UNITY 5 - LIGHTING AND

Unity 摄像机组件

今天看一下unity3d里面的摄像机是怎么调用和操作的. 打开unity3d新建一个工程.在我们打开工程的时候unity3d会主动添加一个Main Camera,在Hierartchy视图中.点击Main Camera在Inspector中出现Main Camera的组件信息.如图 在camera组件中可以对是相机的一些属性进行调节. Clera Flags:清除标记.下拉菜单一共有4个选项. Skybox:天空盒,背景显示天空盒.如果该相机没有添加天空和则显示背景颜色.Solid Color: