# 环境光遮蔽2

SSAO2 - 另一种实现方法

# 初始化

使用SSAO2类添加环境光遮蔽效果。

import { 
    
    KernelSize,
    Postprocessing, 
    SSAO2

} from '@tx3d/postprocessing';

// 创建后处理类
const postprocessing = new Postprocessing( engine );

// 添加后处理效果
const effect = postprocessing.addEffect( SSAO2, {

    worldDistanceThreshold: 500,
    worldDistanceFalloff: 0.0,
    worldProximityThreshold: 500,
    worldProximityFalloff: 0.0,
    resolution: 1.0,
    depthAwareUpsampling: false,
    samples: 16.0,
    rings: 7.0,
    radius: 0.02,
    distanceScaling: true,
    minRadiusScale: 0.1,
    bias: 0.025,
    fade: 0.01,
    intensity: 3,
    luminanceInfluence: 0.7

} );
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

提示

SSAO2初始化参数,详见SSAO2Params

# 属性

🌏 worldDistanceThreshold: The world distance threshold at which the occlusion effect starts to fade out.

effect.worldDistanceThreshold = 500;
1

🌏 worldDistanceFalloff: The world distance falloff. Influences the smoothness of the occlusion cutoff.

effect.worldDistanceFalloff = 0.0;
1

🌏 worldProximityThreshold: The world proximity threshold at which the occlusion starts to fade out.

effect.worldProximityThreshold = 500;
1

🌏 worldProximityFalloff: The world proximity falloff. Influences the smoothness of the proximity cutoff.

effect.worldProximityFalloff = 0.0;
1

🌏 resolution: The resolution scale.

effect.resolution = 1.0;
1

🌏 depthAwareUpsampling: Enables or disables depth-aware upsampling. Has no effect if WebGL 2 is not supported.

effect.depthAwareUpsampling = false;
1

🌏 samples: The amount of samples per pixel. Should not be a multiple of the ring count.

effect.samples = 16;
1

🌏 rings: The amount of spiral turns in the occlusion sampling pattern. Should be a prime number.

effect.rings = 7;
1

🌏 radius:The occlusion sampling radius, expressed as a scale relative to the resolution. Range [1e-6, 1.0].

effect.radius = 0.02;
1

🌏 distanceScaling: Enables or disables distance-based radius scaling.

effect.distanceScaling = true;
1

🌏 minRadiusScale:The minimum radius scale. Has no effect if distance scaling is disabled.

effect.minRadiusScale = 0.1;
1

🌏 bias:An occlusion bias. Eliminates artifacts caused by depth discontinuities.

effect.bias = 0.025;
1

🌏 fade:Influences the smoothness of the shadows. A lower value results in higher contrast.

effect.fade = 0.01;
1

🌏 intensity:The intensity of the ambient occlusion.

effect.intensity = 2;
1

🌏 luminanceInfluence:Determines how much the luminance of the scene influences the ambient occlusion.

effect.luminanceInfluence = 0.7;
1

🌏 color:The color of the ambient occlusion.

effect.color = '#000000';
1
Last Updated: 3/10/2023, 1:05:22 PM