gpt4 book ai didi

three.js - 使用 SSAO 获取 WebGLDeferredRenderer

转载 作者:行者123 更新时间:2023-12-03 16:54:35 33 4
gpt4 key购买 nike

以下是比较,以表明我确实正确设置了 SSAO。

WebGLRenderer with EffectsComposer + SSAO pass
WebGLRenderer with EffectsComposer + SSAO pass

具有 SSAO 通行证的 WebGLDeferredRenderer
WebGLDeferredRenderer with SSAO pass

我正在尝试将 WebGLDeferredRenderer 与 SSAO Composer 效果混合,如下所示:

renderer = new THREE.WebGLDeferredRenderer({
antialias: true,
tonemapping: THREE.FilmicOperator,
brightness: 2.5,
scale: 1.0,
width: renderWidth,
height: renderHeight
});

var depthShader = THREE.ShaderLib[ "depthRGBA" ];
var depthUniforms = THREE.UniformsUtils.clone( depthShader.uniforms );

depthMaterial = new THREE.ShaderMaterial( { fragmentShader: depthShader.fragmentShader, vertexShader: depthShader.vertexShader, uniforms: depthUniforms } );
depthMaterial.blending = THREE.NoBlending;

composer = new THREE.EffectComposer( renderer );
composer.setSize( window.innerWidth, window.innerHeight );

depthTarget = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, {
minFilter: THREE.NearestFilter,
magFilter: THREE.NearestFilter,
format: THREE.RGBAFormat,
antialias: true
});

var ssao = new THREE.ShaderPass( THREE.SSAOShader );
ssao.uniforms[ 'tDepth' ].value = depthTarget;
ssao.uniforms[ 'size' ].value.set( window.innerWidth, window.innerHeight );
ssao.uniforms[ 'cameraNear' ].value = camera.near;
ssao.uniforms[ 'cameraFar' ].value = camera.far * 0.8;
ssao.uniforms[ 'aoClamp' ].value = 0.3;
ssao.uniforms[ 'lumInfluence' ].value = 0.1;

renderer.addEffect( ssao );

scene.overrideMaterial = depthMaterial;
renderer.render( scene, camera, depthTarget );
scene.overrideMaterial = null;

renderer.render( scene, camera );

结果是……好吧……没什么。

我究竟做错了什么?我将如何在延迟渲染器中启用 SSAO?

最佳答案

不知道为什么会这样,但尝试更换:
renderer.render( scene, camera, depthTarget );
和:
renderer.renderer.render( scene, camera, depthTarget );

关于three.js - 使用 SSAO 获取 WebGLDeferredRenderer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29360438/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com