当前位置:网站首页>Threejs glow channel 01 (unrealbroompass & layers)
Threejs glow channel 01 (unrealbroompass & layers)
2022-06-24 09:03:00 【hcdu】
List of articles
Preface
Record on pit :
1、UnrealBloomPass Glow reference three Official website example
2、 Layered rendering is divided into two parts : This is the simplest layers Layered rendering
One 、 glow
1、 Import and stock in :
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、 matters needing attention :
other three Components are written in the normal way , When opening the glare channel, pay attention to the following
The main attention is to add... In the renderer
renderer.autoClear = false
Channel add
bloomPass.renderToScreen = true
Rendering uses compositing rendering
composer.render()
Part of the code
Get rid of the conventional way of writing 【 scene 、 The camera 、 controller 、 Light source, etc 】
Just pay attention to the above code
initrenderer () {
var width = document.getElementById('threecanvas').offsetWidth
var height = document.getElementById('threecanvas').offsetHeight
renderer = new THREE.WebGLRenderer({
antialias: true,
})
renderer.setPixelRatio(window.devicePixelRatio)// Set the resolution to be the same as that of the computer
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()
}
Two 、layers Layered rendering
problem : Easy to use layers Layered rendering can cause depth occlusion problems , Or there are other objects behind the halo , Glow does not take effect
The precautions are the same as above , Then layer the object
We just need to set the level when rendering
Note that the synthesized render channel is on , Normal rendering in the next , Equivalent to two layers , Then divide the camera into two layers
Layers 0: Normal rendering
Layers 1: Render using channels
function render () {
requestAnimationFrame(render)
update()
renderer.clear()
camera.layers.set(1)
composer.render()
renderer.clearDepth()
camera.layers.set(0)
renderer.render(scene, camera)
}
Then you need to choose which objects to use the glare channel , Just take this object
object.layers.set(1)
Normal rendering
object.layers.set(0)
Or not set , Normal layers default to 0
summary
Because of this simple layers There is uncertainty in layering
The next part continues
边栏推荐
- 数组相向指针系列
- The list of open source summer winners has been publicized, and the field of basic software has become a hot application this year
- 打印出来的对象是[object object],解决方法
- MySQL | view notes on Master Kong MySQL from introduction to advanced
- China chip Unicorn Corporation
- Camera projection matrix calculation
- Liunx change the port number of vsftpd
- The form image uploaded in chorme cannot view the binary image information of the request body
- 【LeetCode】541. Reverse string II
- GradScaler MaxClipGradScaler
猜你喜欢

Wan Weiwei, a researcher from Osaka University, Japan, introduced the rapid integration method and application of robot based on WRS system
![[pytoch basic tutorial 31] youtubednn model analysis](/img/18/dbeab69894583f6e5230772ce44652.png)
[pytoch basic tutorial 31] youtubednn model analysis
![Jenkins is deployed automatically and cannot connect to the dependent service [solved]](/img/fe/f294955a9bdf7492aab360e44e052d.png)
Jenkins is deployed automatically and cannot connect to the dependent service [solved]

【牛客】把字符串转换成整数

【LeetCode】415. String addition

嵌入式 | 硬件转软件的几条建议

【PyTorch基础教程30】DSSM双塔模型代码解析

Spark - the number of leftouterjoin results is inconsistent with that of the left table

I heard that you are still spending money to buy ppt templates from the Internet?

数云发布2022美妆行业全域消费者数字化经营白皮书:全域增长破解营销难题
随机推荐
A tip to read on Medium for free
How does the tunnel mobile inspection track robot monitor 24 hours to ensure the safety of tunnel construction?
Transplantation of xuantie e906 -- fanwai 0: Construction of xuantie c906 simulation environment
[pytoch basic tutorial 31] youtubednn model analysis
Kaformer personal notes
KaFormer个人笔记整理
Prompt code when MySQL inserts Chinese data due to character set problems: 1366
数据中台:数据治理概述
常用表情符号
1844. replace all numbers with characters
开源之夏中选名单已公示,基础软件领域成为今年的热门申请
双指针模拟
MySQL | 存储《康师傅MySQL从入门到高级》笔记
Data midrange: analysis of full stack technical architecture of data midrange, with industry solutions
“不平凡的代理初始值设定不受支持”,出现的原因及解决方法
Essay - Reflection
One article explains in detail | those things about growth
1528. rearrange strings
Squid代理服务器应用
MySQL——SQL语句