Debugging with dat.gui? #297
-
I'd like to debug some effects such as SSAO using dat.gui but unfortunately changing the value using SSAO isn't working as intended. What I tried: const loadSsao = (intensity) => {
const normalPass = new NormalPass(scene, camera)
const ssaoEffect = new SSAOEffect(camera, normalPass.renderTarget.texture, {
blendFunction: BlendFunction.MULTIPLY, // intentionally set as normal for better debugging
depthAwareUpsampling: true,
samples: 50,
rings: 12,
distanceThreshold: 0.2,
distanceFalloff: 0.0025,
rangeThreshold: 0.0009,
rangeFalloff: 0.0001,
luminanceInfluence: 0,
radius: 12.5,
intensity: intensity,
bias: 0.0
})
const renderPass = new RenderPass(scene, camera)
const effectPass = new EffectPass(camera, ssaoEffect)
// dat.gui
const gui = dat.GUI()
const ssaoFolder = gui.addFolder("SSAO")
ssaoFolder.add(ssaoEffect, 'intensity', 0, 100, 1)
ssaoFolder.open()
composer.addPass(renderPass)
composer.addPass(normalPass)
composer.addPass(effectPass)
}
loadSsao(12) I also tried to use the
Please excuse the formatting, I really need in a rush as I'm using this package for work :/ For more information I'm using Three.js, dat.gui, etc in a ReactJS/NextJS environnement and most postprocessing and threejs functions are in a |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Try using the const uniforms = ssaoEffect.ssaoMaterial.uniforms;
menu.add(uniforms, "intensity", 1.0, 4.0, 0.01).onChange((value) => {
uniforms.intensity.value = value;
}); |
Beta Was this translation helpful? Give feedback.
-
Ah sorry, I forgot that uniforms have a const uniforms = ssaoEffect.ssaoMaterial.uniforms;
// Aliases used for displaying purposes in the GUI.
const params = {
"intensity": uniforms.intensity.value
};
// Using a proxy object allows us to display the label "intensity" instead of "value".
menu.add(params, "intensity", 1.0, 20.0, 0.01).onChange((value) => {
uniforms.intensity.value = value;
});
// This would work too, but displays "value" in the GUI.
// menu.add(uniforms.intensity, "value", 1.0, 20.0, 0.01); |
Beta Was this translation helpful? Give feedback.
Ah sorry, I forgot that uniforms have a
value
property. The following code should work even inuseEffect()
: