当前位置:网站首页>THREEJS辉光与景深特效
THREEJS辉光与景深特效
2022-07-30 05:47:00 【杰拉拉德】
效果预览
辉光效果:

景深效果:

核心代码
辉光和景深尽量把场景背景设置为黑色,要不影响效果。
// 设置场景背景色为黑色
scene.background = new THREE.Color(0, 0, 0)
// 创建渲染通道
const renderPass= new RenderPass(scene, camera)
// 创建辉光bloom通道, 强度1.5,半径0,阈值0
const bloomPass = new UnrealBloomPass(new THREE.Vector2(window.innerWidth, window.innerHeight), 1.5, 0, 0)
// 创建景深参数
const params = {
focus: 0, // 聚焦
aspect: ts.camera.aspect,
aperture: 0.000005, // 孔径
maxblur: 1,
width: window.innerWidth,
height: window.innerHeight
}
// 创建景深通道
const bokehPass = new BokehPass(scene, camera, params)
// 创建效果合成器
const composer = new EffectComposer(renderer)
// 添加通道,注意顺序
composer.addPass(renderPass)
composer.addPass(bloomPass)
composer.addPass(bokehPass)
// 别忘记在render中添加composer
function render() {
renderer.render(scene, camera)
composer.render()
requestAnimationFrame(render)
}
在向composer添加通道时,要注意顺序,如果辉光和景深共存的情况下,景深要添加在辉光后面,否则先设置景深再设置辉光后,景深效果就没了。
边栏推荐
- -----博客声明
- vscode 设置 sublime 的主题
- C#二叉树的遍历方法(通过递归)
- 编程测试6.21
- Real-time waveform display of CAN communication data based on QT (serial eight) ==== "Sub function or new class calls ui control"
- 2020-09-03 Solve the very slow installation of pip install [Errno 101] Network unreachable problem
- ES6 syntax notes (ES6~ES11)
- VsCode connects to the remote server and modifies the file code
- 你不知道的JS思考题
- 你不知道的JS语法篇笔记
猜你喜欢
随机推荐
Antd 树拖拽一些细节,官网没有,摸坑篇
VSCode隐藏左边活动栏
Written before the official account - QT, ARM, DSP, microcontroller, power electronics and transmission!
vs compile boost library script
超详细的PCB高可靠辨别方法
Deep Interpretation of void (*signal(int , void(*)(int)))(int) in "C Traps and Defects"
VSCode hides the left activity bar
爬2.12.6的Antd上传图片坑
QT serial 4: LORA test platform based on QT and STM32H750 (3)
led闪烁
QT weekly skills (3)~~~~~~~~~ serial port addition
干货:线上下单应知应会,快来了解下
Delete all files containing a keyword in the current path
进制详解(二进制、八进制、十进制、十六进制详解及相互转换,位运算)
迷宫问题----经典回溯法解决
华秋第八届硬创大赛携手NVIDIA初创加速计划,赋能企业发展
暂时存着阿里云
This beta version of Typora is expired, please download and install a newer; workaround
测试第二题
单片机之流水灯









