# 选择泛光

选择泛光可以单独给指定的对象添加泛光。

# 初始化

使用SelectiveBloom类添加选择泛光效果。

import { 
    
    Postprocessing, 
    SelectiveBloom, 
    KernelSize

} from '@tx3d/postprocessing';

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

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

    radius: 0.5, // 模糊半径
    levels: 8, // 模糊质量
    intensity: 1.0, // 光照强度

    threshold: 0.0, //过滤阈值
    smoothing: 0.1, //平滑值

    opacity: 1,//透明度
    dithering: false //是否对颜色应用抖动以消除条带的外观

} );
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

提示

选择泛光初始化参数,详见BloomParams

# 属性

🌏 intensity 泛光强度

// 设置泛光强度
effect.intensity = 1.0;
1
2

🌏 radius 模糊范围

// 设置模糊范围
effect.radius = 0.5;
1
2

🌏 levels 模糊质量

// 设置模糊质量
effect.levels = 0.5;
1
2

🌏 threshold 泛光阈值

// 设置泛光阈值
effect.threshold = 0.5;
1
2

🌏 smoothing 泛光阈值

// 设置平滑度
effect.smoothing = 0.5;
1
2

# 接口

🌏 setBloom 设置要泛光的对象

// 设置泛光
effect.setBloom( component, true );
1
2
Last Updated: 8/21/2023, 2:11:59 PM