当前位置:网站首页>threejs辉光通道01(UnrealBloomPass && layers)
threejs辉光通道01(UnrealBloomPass && layers)
2022-06-24 07:18:00 【hcdu】
前言
踩坑记录:
1、UnrealBloomPass 辉光参照three官网示例
2、分层渲染分为两篇:本篇为最简单的layers分层渲染
一、辉光
1、引入库:
import {
EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer'
import {
UnrealBloomPass } from 'three/examples/jsm/postprocessing/UnrealBloomPass'
import {
RenderPass } from 'three/examples/jsm/postprocessing/RenderPass'
2、注意事项:
其他three组件都是常规的写法,开启炫光通道的时候如下注意点
主要注意渲染器中添加
renderer.autoClear = false
通道添加
bloomPass.renderToScreen = true
渲染使用合成渲染
composer.render()
部分代码
除去常规写法的【场景、相机、控制器、光源等】
只需要注意上述这部分代码
initrenderer () {
var width = document.getElementById('threecanvas').offsetWidth
var height = document.getElementById('threecanvas').offsetHeight
renderer = new THREE.WebGLRenderer({
antialias: true,
})
renderer.setPixelRatio(window.devicePixelRatio)// 设置分辨率与电脑的分辨率相同
renderer.setSize(width, height)
renderer.toneMapping = THREE.ReinhardToneMapping
renderer.autoClear = false
document.getElementById('threecanvas').appendChild(renderer.domElement)
}
addBloomPass () {
var width = document.getElementById('threecanvas').offsetWidth
var height = document.getElementById('threecanvas').offsetHeight
const renderScene = new RenderPass(scene, camera)
const bloomPass = new UnrealBloomPass(new THREE.Vector2(width, height),1.5,0.4,0.85)
bloomPass.renderToScreen = true
bloomPass.threshold = params.bloomThreshold
bloomPass.strength = params.bloomStrength
bloomPass.radius = params.bloomRadius
composer = new EffectComposer(renderer)
composer.setSize( width, height );
composer.addPass(renderScene)
composer.addPass(bloomPass)
}
function render () {
requestAnimationFrame(render)
update()
composer.render()
}
二、layers分层渲染
问题: 使用简单的layers分层渲染会出现深度遮挡问题,或者有其他物体在光晕后方,光晕不生效
注意事项和上述相同,然后给物体分层即可
我们只需要在渲染的时候设置好层级
注意合成的渲染通道在上,正常的渲染在下,相当于两个图层,然后把相机分给两个图层
图层0:正常渲染
图层1:使用通道渲染
function render () {
requestAnimationFrame(render)
update()
renderer.clear()
camera.layers.set(1)
composer.render()
renderer.clearDepth()
camera.layers.set(0)
renderer.render(scene, camera)
}
然后自己需要哪些物体使用炫光的通道,就把这个物体
object.layers.set(1)
正常渲染的话
object.layers.set(0)
或不设置,正常的图层默认为0
总结
由于这种简单的layers分层会出现不确定性问题
下篇继续
边栏推荐
- leetcode 1642. Furthest building you can reach
- 听说你还在花钱从网上买 PPT 模板?
- GradScaler MaxClipGradScaler
- 基于QingCloud的 “房地一体” 云解决方案
- 常用表情符号
- 深度学习与神经网络:最值得关注的6大趋势
- Centos7 installation of jdk8, mysql5.7 and Navicat connection to virtual machine MySQL and solutions (solutions to MySQL download errors are attached)
- Analyze the meaning of Internet advertising terms CPM, CPC, CPA, CPS, CPL and CPR
- 2022-06-23:给定一个非负数组,任意选择数字,使累加和最大且为7的倍数,返回最大累加和。 n比较大,10的5次方。 来自美团。3.26笔试。
- Opencv maximum filtering (not limited to images)
猜你喜欢

Centos7 installation of jdk8, mysql5.7 and Navicat connection to virtual machine MySQL and solutions (solutions to MySQL download errors are attached)

Wan Weiwei, a researcher from Osaka University, Japan, introduced the rapid integration method and application of robot based on WRS system

Jenkins自动化部署,连接不到所依赖的服务【已解决】

ZUCC_ Principles of compiling language and compilation_ Experiment 0607 grammar analysis ll analysis

从华为WeAutomate数字机器人论坛,看政企领域的“政务新智理”

2022-06-23:给定一个非负数组,任意选择数字,使累加和最大且为7的倍数,返回最大累加和。 n比较大,10的5次方。 来自美团。3.26笔试。

MySQL | view notes on Master Kong MySQL from introduction to advanced

Liunx Mysql安装
![[quantitative investment] discrete Fourier transform to calculate array period](/img/0d/aac02463ff403fb1ff871af5ff91fa.png)
[quantitative investment] discrete Fourier transform to calculate array period

À propos de ETL il suffit de lire cet article, trois minutes pour vous faire comprendre ce qu'est ETL
随机推荐
基于QingCloud的 “房地一体” 云解决方案
所说的Get post:请求的区别,你真的知道了吗??????
Floating error waiting for changelog lock
【PyTorch基础教程30】DSSM双塔模型代码解析
打印出来的对象是[object object],解决方法
2022-06-23:给定一个非负数组,任意选择数字,使累加和最大且为7的倍数,返回最大累加和。 n比较大,10的5次方。 来自美团。3.26笔试。
剑指 Offer 55 - I. 二叉树的深度-dfs法
"Unusual proxy initial value setting is not supported", causes and Solutions
MySQL | 视图《康师傅MySQL从入门到高级》笔记
MySQL | store notes of Master Kong MySQL from introduction to advanced
À propos de ETL il suffit de lire cet article, trois minutes pour vous faire comprendre ce qu'est ETL
The pie chart with dimension lines can set various parameter options
110. 平衡二叉树-递归法
数据中台:数据中台技术架构详解
Xiaohei ai4code code baseline nibble 1
Solution: Nan occurs in loss during model training
快慢指针系列
Lombok use
OpenCV每日函数 结构分析和形状描述符(7) 寻找多边形(轮廓)/旋转矩形交集
Why can ping fail while traceroute can