three.js: EXR Envmap not working on iOS
Following the example on: https://threejs.org/examples/webgl_materials_envmaps_exr.html and loading a EXR file as environment map with:
var pmremGenerator = new THREE.PMREMGenerator( this.renderer );
pmremGenerator.compileEquirectangularShader();
var exrCubeRenderTarget = pmremGenerator.fromEquirectangular( texture );
this.hdr = exrCubeRenderTarget.texture;
This works perfectly on all desktop browsers but on iOS the HDR is completely black and no lighting is applied to the model. This also applies to the example link on iOS: https://threejs.org/examples/webgl_materials_envmaps_exr.html
Three.js version
- Dev
- r115
- …
Browser
- All of them
- Chrome
- Firefox
- Internet Explorer
OS
- All of them
- Windows
- macOS
- Linux
- Android
- iOS
Hardware Requirements (graphics card, VR Device, …)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (6 by maintainers)
@sciecode Yes, that fits with my understanding. That sounds like a reasonable path forward; I don’t have a strong opinion on the shape of three’s API. If we’re planning to overhaul PMREMGenerator it might also be a good time to enable different sizes (right now it’s fixed to outputting a 256x256 cubemap regardless of input size). It seems like with the right choice of defaults we might even be able to make this change non-breaking, which would be nice.
I’ve pushed #19070 as a temporary fix for the situation. Even if we decide to pursue other solutions in the future, there’s no harm in allowing
EXRLoaderto outputUnsignedByteTypewithRGBEFormat.That way, at least, we have a viable option for people looking to use EXR envmaps with mobile support.
webgl_materials_envmaps_exr.html
@WestLangley I tried that way originally, but switched to RGBE because while floating point textures are widely available for decode, the same is not true for writing to framebuffers. Samsung devices can’t write halffloat buffers and iphones can’t write float buffers, so I ended up decoding RGBE in the shaders because that was the only way I could find to make a broadly cross-device solution.
Perhaps we should throw a warning about device compatibility when using non-8-bit formats with PMREM?