UE4 Shadow Casting

1649 篇文章 11 订阅
1623 篇文章 22 订阅


lighting_overview_banner_001.png

Shadows make objects feel grounded in the world and give the viewer a sense of depth and space. Static shadows are free as far as rendering goes, but dynamic shadows can be one of the biggest drains on performance. This document covers the basics of the 4 types of shadow casting you can have in Unreal Engine 4.

Static Lights

Static lights cast completely static shadows and light, meaning they will have no direct effect on dynamic objects (static lights are baked into the Indirect Lighting Cache so they have some effect) like on the bronze men below.

LI_StaticMeansStatic.png

The bronze character on the left is standing in the light of a static light, it does not affect him in any way (lighting or shadows) while the one on the right is in the light of a stationary light.

Directional Light Cascading Shadow Maps (Whole Scene Shadows)

Directional Stationary Lights are special because they support whole scene shadows through Cascaded Shadow Maps at the same time as static shadowing. This is very useful in levels with a lot of animating foliage; you want to have moving shadows around the player but do not want to pay the cost of having many cascades to cover a large view range. The dynamic shadows are faded into static shadows over distance, such that the transition is often indistinguishable. To set this up, just change the Dynamic Shadow Distance StationaryLight of aDirectionalLightStationary to be the range at which you want the fade to happen.

Stationary Light Shadows

Dynamic objects (like StaticMeshComponents and SkeletalMeshComponents with Mobility set to Movable) must integrate into the static shadowing of the world from distance field shadowmaps. This is accomplished with Per Object shadows. Each movable object creates two dynamic shadows from a stationary light: a shadow to handle the static world casting onto the object, and a shadow to handle the object casting onto the world. With this setup, the only shadowing cost for stationary lights comes from dynamic objects that it affects. This means the cost can vary from very little to a large amount, depending on how many dynamic objects there are. With enough dynamic objects, it is more efficient to use a Movable light instead.

In the scene below, the spheres are all movable, and they all receive shadows from the static world and cast their own shadows, which merge with the distance field shadows. The Per Object shadow frustums for each Movable component are also shown.

DynamicObjectShadowFrustums.png

Per Object shadows used by movable components apply a shadowmap to the object's bounds, therefore the bounds must be accurate. For Skeletal meshes this means they should have a physics asset. For particle systems, any fixed bounding box must be large enough to contain all particles.

Dynamic Shadows

Movable lights cast completely dynamic shadows (and light) on everything. None of its light data will get baked into the light maps and it will be free to cast dynamic shadows on everything. Static Meshes, Skeletal Meshes, effects, etc... will all cast and receive dynamic shadows from a movable light.

On average, movable dynamic shadow casting lights are the most expensive.

Preview Shadows

When editing a Stationary or Static Light in such a way that the lighting becomes un-built, Preview Shadowing is enabled to give you an idea of what the shadows will look like when lighting is rebuilt.

These shadows are shown in the editor with the text "Preview" to distinguish them from pre-existing shadows as seen below.

UnbuiltShadows.png

If you test your game in the editor prior to rebuilding lighting, the Preview Shadows will disappear as the preview only exists within the editor and not during Play In Editor.

UnbuiltShadowsPIE.png

In order to generate shadows from the Preview Shadows, you will need to select Build Lighting from the Build option off the Main Editor Tool Bar.

BuiltShadows.png

You can disable Preview Shadows by un-checking the Preview Shadows Indicator option in the Viewport's Show/Visualize menu.

If you wish to tweak the Light Function Material used to project this text, it can be found at:Engine/EditorMaterials/PreviewShadowIndicator

All Together

When all the shadows are brought together, each bringing their strengths to make up for the weakness of the others, impressive and rapidly rendered visuals can be brought to life.

LO_Shadows_Footer.png

lighting_overview_banner_001.png

Shadows make objects feel grounded in the world and give the viewer a sense of depth and space. Static shadows are free as far as rendering goes, but dynamic shadows can be one of the biggest drains on performance. This document covers the basics of the 4 types of shadow casting you can have in Unreal Engine 4.

Static Lights

Static lights cast completely static shadows and light, meaning they will have no direct effect on dynamic objects (static lights are baked into the Indirect Lighting Cache so they have some effect) like on the bronze men below.

LI_StaticMeansStatic.png

The bronze character on the left is standing in the light of a static light, it does not affect him in any way (lighting or shadows) while the one on the right is in the light of a stationary light.

Directional Light Cascading Shadow Maps (Whole Scene Shadows)

Directional Stationary Lights are special because they support whole scene shadows through Cascaded Shadow Maps at the same time as static shadowing. This is very useful in levels with a lot of animating foliage; you want to have moving shadows around the player but do not want to pay the cost of having many cascades to cover a large view range. The dynamic shadows are faded into static shadows over distance, such that the transition is often indistinguishable. To set this up, just change the Dynamic Shadow Distance StationaryLight of aDirectionalLightStationary to be the range at which you want the fade to happen.

Stationary Light Shadows

Dynamic objects (like StaticMeshComponents and SkeletalMeshComponents with Mobility set to Movable) must integrate into the static shadowing of the world from distance field shadowmaps. This is accomplished with Per Object shadows. Each movable object creates two dynamic shadows from a stationary light: a shadow to handle the static world casting onto the object, and a shadow to handle the object casting onto the world. With this setup, the only shadowing cost for stationary lights comes from dynamic objects that it affects. This means the cost can vary from very little to a large amount, depending on how many dynamic objects there are. With enough dynamic objects, it is more efficient to use a Movable light instead.

In the scene below, the spheres are all movable, and they all receive shadows from the static world and cast their own shadows, which merge with the distance field shadows. The Per Object shadow frustums for each Movable component are also shown.

DynamicObjectShadowFrustums.png

Per Object shadows used by movable components apply a shadowmap to the object's bounds, therefore the bounds must be accurate. For Skeletal meshes this means they should have a physics asset. For particle systems, any fixed bounding box must be large enough to contain all particles.

Dynamic Shadows

Movable lights cast completely dynamic shadows (and light) on everything. None of its light data will get baked into the light maps and it will be free to cast dynamic shadows on everything. Static Meshes, Skeletal Meshes, effects, etc... will all cast and receive dynamic shadows from a movable light.

On average, movable dynamic shadow casting lights are the most expensive.

Preview Shadows

When editing a Stationary or Static Light in such a way that the lighting becomes un-built, Preview Shadowing is enabled to give you an idea of what the shadows will look like when lighting is rebuilt.

These shadows are shown in the editor with the text "Preview" to distinguish them from pre-existing shadows as seen below.

UnbuiltShadows.png

If you test your game in the editor prior to rebuilding lighting, the Preview Shadows will disappear as the preview only exists within the editor and not during Play In Editor.

UnbuiltShadowsPIE.png

In order to generate shadows from the Preview Shadows, you will need to select Build Lighting from the Build option off the Main Editor Tool Bar.

BuiltShadows.png

You can disable Preview Shadows by un-checking the Preview Shadows Indicator option in the Viewport's Show/Visualize menu.

If you wish to tweak the Light Function Material used to project this text, it can be found at:Engine/EditorMaterials/PreviewShadowIndicator

All Together

When all the shadows are brought together, each bringing their strengths to make up for the weakness of the others, impressive and rapidly rendered visuals can be brought to life.

LO_Shadows_Footer.png

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值