Usnul
October 19, 2021, 3:42am
1
I’ve been trying to wrap my head around this for a while. Here’s what the scene looks like in r132:
and here’s the same in r33:
moreover, if I update all material in the scene with material.needsUpdate = true
I get this:
Indicating that there’s some problem with how lights are calculated.
There are 3 light sources in the scene:
1 DirectionalLight
that casts a shadow. White intensity 0.8
1 AmbientLight
, white with 0.4 intensity
1 PointLight
that’s black and has 0 intensity and 0 radius (distance)
There is an environment map on the whole scene, here’s how it’s loaded:
/**
*
* @param {string[]} paths URLs to faces of the cubemap
* @returns {Promise<void>}
*/
async function loadEnvironmentMap (paths) {
/**
*
* @type {THREE.CubeTexture}
*/
const cube_texture = await load_cube_texture(paths);
cube_texture.encoding = sRGBEncoding;
// generate pre-filtered cubemap
const pmremGenerator = new PMREMGenerator(this.renderer);
pmremGenerator.compileCubemapShader();
const cube_rt = pmremGenerator.fromCubemap(cube_texture);
// cleanup
cube_texture.dispose();
pmremGenerator.dispose();
// assign environment
this.scene.environment = cube_rt.texture;
}
I’ve tracked changes to envMap in r133:
opened 02:12PM - 15 Oct 21 UTC
closed 03:19PM - 15 Oct 21 UTC
Duplicate
**Describe the bug**
Many scenes use a CubeCamera to generate static reflecti… ons.
On 132 or 133 Standard Materials do not show the reflection. Either if set via material.envMap or scene.environment
**To Reproduce**
See live example
Essentially use the code from CubeCamera demo in 132 or 133
***Code***
```js
const cubeRenderTarget = new THREE.WebGLCubeRenderTarget( 128, { format: THREE.RGBFormat, generateMipmaps: true, minFilter: THREE.LinearMipmapLinearFilter } );
const cubeCamera = new THREE.CubeCamera( 0.1, 100, cubeRenderTarget );
scene.add( cubeCamera );
cubeCamera.update(renderer, scene);
const chromeMaterial = new THREE.MeshStandardMaterial( { color: 0xff9999, metalness: 1, roughness: 0 } );
const chromeMaterial2 = new THREE.MeshStandardMaterial( { envMap: cubeRenderTarget.texture, color: 0xff9999, metalness: 1, roughness: 0 } );
const geometry = new THREE.SphereGeometry(0.4, 16, 16);
const mesh = new THREE.Mesh( geometry, chromeMaterial );
scene.add(mesh);
cube.material = chromeMaterial;
cube2.material = chromeMaterial2;
scene.environment = cubeRenderTarget.texture;
mesh.position.y=0.5;
```
***Live example***
https://brass-husky-icicle.glitch.me/
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
131:
![image](https://user-images.githubusercontent.com/4225330/137500798-d9923005-e646-4075-9b0e-3d5c67e378f5.png)
132:
![image](https://user-images.githubusercontent.com/4225330/137500846-e836e183-c42d-42d5-b36a-b8511d7d4e8e.png)
but it doesn’t look like this applies to my case. Also, with the light setup that I have this level of darkness just doesn’t make sense. I spent many hours on this so far, any clues would be welcome.
For the sake of completeness, here r133 without the environment map (slightly darker still):
looeee
October 19, 2021, 4:30am
2
How does r132 look without the envMap? And can you compare the two with only the envMap to check whether the issue is with the lights or the envMap?
Usnul
October 19, 2021, 10:08am
3
Hey, thanks for checking in, here is 132 without envMap
just a tad darker as well
looeee
October 19, 2021, 10:20am
4
Hard to tell, but it seems like the envMap is probably correct then?
Seems unlikely that its the lights though since nobody else has reported anything like this when upgrading
Mugen87
October 19, 2021, 10:36am
5
Maybe related: We use EXT_sRGB
with r133
. Notice that many textures looked too dark in earlier three.js
versions due to the GLSL inline decode. More information in this comment: glTF conformance: khronos-TextureLinearInterpolationTest · Issue #22483 · mrdoob/three.js · GitHub
Although this does not explain why your scene is darker with r133
.
Mugen87
October 19, 2021, 10:41am
6
BTW: You can write loadEnvironmentMap()
like so now:
async function loadEnvironmentMap (paths) {
/**
*
* @type {THREE.CubeTexture}
*/
const cube_texture = await load_cube_texture(paths);
cube_texture.encoding = sRGBEncoding;
this.scene.environment = cube_texture;
}
2 Likes
Usnul
October 19, 2021, 12:45pm
7
That’s a cool tip, thanks for that, I’ll investigate the possibility
Are you using sRGBEncoding as your outputEncoding? I thought I figured out a fix for a problem I was seeing and found that it worked until r133, then worked in r135 and broke in r136 again. Looking at the merge that @Mugen87 referenced, I see that it enforces LinearEncoding when you use sRGBEncoding.
mrdoob:dev
← Mugen87:dev60
opened 03:54PM - 03 Dec 21 UTC
Related issue: Fixed #22892. Fixed #22483.
**Description**
Now that `three… .js` uses `gl.texStorage2D()`, it's possible to enable `SRGB8_ALPHA8` again without introducing a performance regression on Windows.
This might cause the problems that you’re seeing, as it does cause similar problems in the case I’m using.