主题
AmbientOcclusionEffect
概览
| 字段 | 值 |
|---|---|
| Kind | Unit · 单位 Unit |
| Realm | common |
继承关系
- Unit(4 属性 / 25 函数 / 6 事件)
- BasePostEffect(1 属性)
- [AmbientOcclusionEffect](3 属性)
- BasePostEffect(1 属性)
继承成员
2 个来源 / 5 属性 / 25 函数 / 6 事件
- 来自 BasePostEffect(1 属性)
- 属性:
Enabled
- 属性:
- 来自 Unit(4 属性 / 25 函数 / 6 事件)
- 属性:
AssetId、Name、Desc、Parent - 函数:
ClearAllChildren、GetChildren、GetDescendants、IsAncestorOf、IsDescendantOf、FindFirstAncestor、FindFirstAncestorWhichIsA、FindFirstAncestorOfClass、FindFirstChild、FindFirstChildWhichIsA、FindFirstChildOfClass、HasChildren、GetChildCount、GetChildAtIndex、SetAttribute、GetAttribute、GetAllProps、Clone、IsA、Destroy、GetPropertyChangedSignal、GetAttributeChangedSignal、FindFromPath、GetFullPath、GetDebugId - 事件:
ChildAdded、ChildRemoved、DescendantAdded、DescendantRemoving、AncestryChanged、Destroying
- 属性:
环境光遮蔽效果用于模拟物体角落和缝隙处的柔和阴影,增强场景的立体感和真实度。通过调整采样半径、深度偏移和遮蔽强度,可以控制阴影的扩散范围与浓淡程度。该效果继承自基础后处理,可启用或禁用以实时切换画面表现。
适用场景
在需要提升场景视觉层次时,将环境光遮蔽效果挂载到光照服务下,并调节参数来微调阴影质感。
使用要点
通过 game:CreateUnit("AmbientOcclusionEffect", { Enabled = true }) 创建实例,将其 Parent 设置为 LightingService。然后修改 Radius、Bias 和 Intensity 属性来调整效果,并通过 Enabled 属性控制开关。
注意事项
实例必须挂载到 LightingService 下才能生效。修改属性后效果会立即更新,无需额外刷新。该效果属于后处理特效,可能与其他后处理效果存在叠加关系。
代码示例
创建 AmbientOcclusionEffect 并挂载到光照服务
lua
-- @runtime client
local Lighting = game:GetService('LightingService')
local ambientOcclusionEffect = game:CreateUnit('AmbientOcclusionEffect', {
Enabled = true,
})
ambientOcclusionEffect.Parent = Lighting
print('后处理已启用:', ambientOcclusionEffect.Enabled)属性 (3)
| Name | 类型 | 默认值 | 说明 |
|---|---|---|---|
Radius | Float | 1.0 | 控制环境光遮蔽的采样半径,影响遮蔽的扩散范围。 |
Bias | Float | 0.02 | 控制环境光遮蔽的深度偏移量,用于调整遮蔽计算的敏感度。 |
Intensity | Float | 1.0 | 控制环境光遮蔽效果的强度,数值越大遮蔽越明显。 |
