const loader3 = new RGBELoader();//HDR光 loader3.setPath('/hdr/') loader3.load( 'unfinished_office_night_1k.hdr', function(texture){ console.log(texture) var pmremGenerator = new THREE.PMREMGenerator(renderer); pmremGenerator.compileEquirectangularShader(); var envMap = pmremGenerator.fromEquirectangular(texture).texture; console.log(envMap) scene.background = envMap; scene.environment = envMap; texture.dispose(); pmremGenerator.dispose(); }) var axisHelper = new THREE.AxesHelper(40); scene.add(axisHelper);我想控制hdr的强度,要如何修改代码
时间: 2024-03-06 14:49:05 浏览: 210
C/C++ 中const关键字的用法小结
在Three.js中控制HDR的强度,可以通过调整PMREMGenerator的参数来实现。具体代码如下:
```javascript
const loader3 = new RGBELoader();
loader3.setPath('/hdr/');
loader3.load('unfinished_office_night_1k.hdr', function(texture) {
console.log(texture);
var pmremGenerator = new THREE.PMREMGenerator(renderer);
pmremGenerator.compileEquirectangularShader();
var envMap = pmremGenerator.fromEquirectangular(texture).texture;
console.log(envMap);
// 通过调整PMREMGenerator的参数来控制HDR强度
pmremGenerator.toneMappingExposure = 1.2; // 设置HDR强度值
pmremGenerator.toneMappingWhitePoint = 1.0; // 设置白平衡点
scene.background = envMap;
scene.environment = envMap;
texture.dispose();
pmremGenerator.dispose();
});
var axisHelper = new THREE.AxesHelper(40);
scene.add(axisHelper);
```
在上述示例中,我们通过设置PMREMGenerator的toneMappingExposure参数来控制HDR强度值。可以根据需要调整参数,达到预期的HDR效果。同时,我们还设置了PMREMGenerator的toneMappingWhitePoint参数来控制白平衡点,也可以根据需要进行调整。
阅读全文