This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
Version Control
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
统一的Unigine着色器语言 UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

阴影

UNIGINE provides realtime and precomputed shadows from light sources. UNIGINE提供光源的实时阴影和预先计算的阴影。

Shadows are cast using a commonly used technique called Shadow Mapping: a depth texture (or a cubemap for omni lights) is grabbed from the position of the light source and used to define lit and shaded areas.阴影是使用称为 Shadow Mapping 的常用技术投射的:从光源的位置抓取深度纹理(或用于全向灯光的立方体贴图),并用于定义明暗区域

World light sources use an advanced shadow mapping technique called Parallel-Split Shadow Mapping to handle shadows at large distances. The shadow settings are available per each world light source.世界光源使用一种称为 Parallel-Split阴影映射的高级阴影映射技术来处理远距离阴影。每个世界光源都可以使用阴影设置

To enable shadow casting from a light source, check the Enabled option in its Shadow Settings:要启用从光源投射阴影,请在其Enabled option in its Shadow Settings:

All light sources can be either in Dynamic or Static mode according to which it is decided if shadow maps are computed in real time or saved in an asset once, thus significantly reducing the number of polygons rendered each frame.所有光源都可以处于 Dynamic或Static 模式,根据该模式可以确定是实时计算阴影贴图还是将其保存在资源中一次,因此大大减少了每帧渲染的多边形数量。

Each surface has the shadows-related Rendering Parameters. For a surface to cast shadows, it should have the Cast Proj and Omni Shadows and Cast World Shadows options enabled, the same options are available per material.每个表面都有与阴影相关的渲染参数。要使表面投射阴影,应该启用 Cast Proj和Omni Shadows Cast World Shadows 选项,每个 same options

The Shadow Mode parameter is set per surface

The surface's Shadow Mode is responsible for the type of shadows cast by the surface:表面的阴影模式负责表面投射的阴影类型:

  • Static. The surface casts both types of shadows: cached (from static lights) and dynamic (from dynamic lights). 静态。曲面会投射两种类型的阴影:缓存的阴影(来自静态光源)和动态的阴影(来自 dynamic 光源)。
  • Dynamic. The surface casts shadow only if lit by a dynamic light or a static light with Mixed shadow mode. No shadows baked. 动态。仅当在 Mixed 阴影模式下由动态光照或静态光照亮时,曲面才会投射阴影。没有阴影。

You can control shadow-related interactions between surfaces/materials and light sources by using the Shadow Mask.您可以使用阴影蒙版控制表面/材质与光源之间与阴影相关的交互。

See Also
也可以看看#

Dynamic Shadows
动态阴影#

Dynamic or realtime shadows are useful in changing scenes: when a light source or objects lit by it move. In this case all affected geometry is rendered into shadow buffer one more time, which might affect the performance.动态或实时阴影在更改场景时很有用:当光源或由其照明的对象移动时。在这种情况下,所有受影响的几何体将再次渲染到阴影缓冲区中,这可能会影响性能。

注意
You can estimate the number of polygons rendered into shadows by using the Triangles Shadows counter of the Performance Profiler.您可以使用Performance ProfilerTriangles Shadows计数器.

To make a light source provide dynamic shadows, set the Mode to Dynamic and adjust the Shadow Settings.要使光源提供动态阴影,请将 模式 设置为动态并调整阴影设置

Cached Shadows
缓存的阴影#

Mostly, virtual environments tend to be static. That is why it makes sense to drop the shadows computation each frame to gain the performance.通常,虚拟环境通常是静态的。这就是为什么要在每帧阴影计算中获得性能才有意义。

The idea behind precomputed Cached Shadows is to grab the shadow map of a light source and save it in an asset to be rendered later at run time.预先计算的“缓存阴影”背后的想法是获取光源的阴影贴图,并将其保存在资源中,以便稍后在运行时渲染。

To get shadows from a light source cached:要从缓存的光源获取阴影:

  1. Select Static Shadow Mode for all stationary surfaces. This is the default mode for surfaces of Mesh Static objects.为所有固定表面选择静态 阴影模式 。这是网格静态对象的表面的默认模式。
  2. Open Bake Lighting window and check Bake Static Shadows For Lights.

    注意
    Enable the Automatic Rebake option to make shadows for static light sources be automatically rebaked every time you make changes to their transformation and shadows-related settings.Enable the Automatic Rebake option to make shadows for static light sources be automatically rebaked every time you make changes to their transformation and shadows-related settings.
    Enable the Automatic Rebake option to make shadows for static light sources be automatically rebaked every time you make changes to their transformation and shadows-related settings.
    打开烘焙照明窗口,然后选中为灯光烘焙静态阴影

  3. Choose Static Mode for the light source.

    选择光源的静态模式。

  4. In the Shadow Settings, select the Static shadow mode and Resolution of the shadow map.

    在“阴影设置”中,选择静态阴影模式和阴影图的分辨率。

  5. Click Bake Selected in the Bake Lighting window. The shadow map of the light source will be saved at the bake_lighting/shadows folder and assigned to the Depth Texture asset field.Bake Lighting窗口中单击Bake Selected。 光源的阴影贴图将保存在bake_lighting/shadows文件夹中,并分配给Depth Texture资源字段。

After that, the light source will provide static cached shadows only. After changing light's position, rotation or parameters, it should be rebaked for proper shadow casting.之后,光源将仅提供静态缓存的阴影。更改光源的位置,旋转或参数后,应重新烘焙以正确投射阴影。

注意
Enable the Automatic Rebake option to make shadows for static light sources be automatically rebaked every time you make changes to their transformation and shadows-related settings.Bake Lighting窗口的相应部分中启用Auto Rebake选项,因此,每次更改静态光源的阴影时,它们都会自动重新烘烤。

World light sources require additional adjustments. For more details refer to the Shadow Settings of the World light.世界光源需要其他调整。有关更多详细信息,请参见“世界”灯光的阴影设置

Mixing Dynamic and Cached Shadows
混合动态阴影和缓存阴影#

By using the Mixed shadow mode you can combine baked shadows from static geometry and realtime shadows cast by certain dynamic meshes:通过使用混合阴影模式,您可以将静态几何图形中的烘焙阴影与某些动态网格物体投射的实时阴影相结合:

  1. Select Static Shadow Mode for all stationary surfaces.为所有固定表面选择静态 阴影模式
  2. Select Dynamic Shadow Mode for all moving or changing surfaces.为所有移动或变化的曲面选择动态 阴影模式
  3. Open Bake Lighting window and check Bake Static Shadows For Lights.

    打开烘焙照明窗口,然后选中为灯光烘焙静态阴影

  4. Choose Static Mode for the light source.

    选择光源的静态模式。

  5. In the Shadow Settings, select the Mixed shadow mode and Resolution of the shadow map.

    在“阴影设置”中,选择混合阴影模式和阴影图的分辨率。

  6. Click Bake Selected in the Bake Lighting window to bake static shadows. The shadow map containing shadows cast by static geometry will be saved at the bake_lighting/shadows folder and assigned to the Depth Texture asset field.Bake Lighting窗口中单击Bake Selected,以烘烤静态阴影。 包含由静态几何体投射的阴影的阴影贴图将保存在bake_lighting/shadows文件夹中,并分配给Depth Texture资源字段。

After that, the light source will provide both cached and dynamic shadows. After changing light's position, rotation or parameters, it should be rebaked for proper shadow casting.之后,光源将提供缓存的阴影和动态阴影。更改光源的位置,旋转或参数后,应重新烘焙以正确投射阴影。

注意
Bake Lighting窗口的相应部分中启用Auto Rebake选项,因此,每次更改静态光源的阴影时,它们都会自动重新烘烤。

Area Shadows
区域阴影#

Soft shadows from area lights can be simulated for both static and dynamic light sources by using the Penumbra Settings.可以使用 Penumbra设置来模拟区域光源的柔和阴影,用于静态和动态光源。

Screen-Space Shadows
屏幕空间阴影#

Screen-Space Shadows are raytraced shadows calculated in screen space. This effect does not depend on the polygon count, that is why it may be a great solution for small contact shadows or shadows at a high distance from the camera. 屏幕空间阴影是在屏幕空间中计算的光线跟踪阴影。此效果不取决于多边形数量,因此为什么它对于较小的接触阴影或距相机很远的阴影可能是一个很好的解决方案。

最新更新: 2024-08-16
Build: ()