-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RGBM texture banding on iOS #20786
Comments
Please fill out the bug report template properly. Especially you should share a screenshot that shows the rendering issues. |
Will do that. By studying the forums it looks that it is related to the way iOS loads PNGs. Other formats like BASIS work ok, but then again they suffer from artifacts, especially in the alpha channel. I have no idea what would be the right solution. |
I've tested this issue today on a iPad (8th generation) with iPadOS 14.3 and Safari. I can see the same artifacts like in the screenshot. The RGBM example does look as expected on a Pixel 4a though. Besides, the RGBE/HDR example looks good on the iPad, too. |
Do we still need RGBM? 🤔 |
/cc @elalish |
AFAIK, encoding/decoding with RGBM is faster than RGBE. Besides, you can always use linear filtering which does only work with RGBE when using floating point textures. |
RGBM is essential for working with 8bit encoded HDR images. Alpha channel usage for holding noncolor data is also mega important. |
But, can't those 8bit HDR images be converted into a RGBE DataTexture at load time? |
No. |
It's true that RGBE is a bit more expensive than RGBM (since you have to do custom interpolation instead of the normal hardware version), but it also works much better, especially for very high dynamic ranges. RGBE does great with 8bit HDR images, but converting between RGBM and RGBE could easily have bugs. However, using hardware interpolation on RGBM is also wrong (just not quite as wrong as RGBE) and could easily be responsible for the banding you see. I would recommend removing RGBM support entirely, as the whole format feels like a hack to me. |
RGBM format is not a hack. It is a legitimate algorithm to pack high dynamic range data in 8bit per channel image. Banding occurs due to iOS natively premulitplying alpha on PNG loading. Premultiplying alpha channel is wrong in so many different ways, especially in 3D engines. I would suggest implementing a custom loader for PNG on iOS (based on libpng), as this would solve many other issues too. |
Okay, but have you looked at how much error is introduced by doing naive 4-channel linear interpolation on correct RGBM data? It can get significant if the gradients are steep. Also, for any given float triple there are multiple ways to encode the value to RGBM, which makes consistency tricky. |
Of course limitations are expected when you are packing float point data in fixed point. No matter how you pack/unpack them what is important is that texture data that has alpha channel is tempered natively by iOS on loading PNGs, and that is not ok. Let's focus on that problem. RGBM or any other format (or algorithm) that is utilizing alpha channel in textures is in the same situation. |
Is there a JavaScript port of |
@vjevremovic I've quickly hacked a |
There is a refactored version of RGBMLoader which also supports loading cube maps. It is now derived from @mrdoob If you like I can make a PR with this code so Otherwise I leave my branch as it is so user can copy/paste the implementation into their project if necessary. |
@Mugen87 it works! well done! |
Yes, this is much better for me, too. Two issues, though...
|
I'm not familiar with the internals of PNG but according to the |
I think it is the application's responsibility to honor the Note that the So the file headers are messed up. |
We probably should regenerate the RGBM files to have consistency. As far as I can see here, the original tool is not available. @vjevremovic Can you recommend a tool that converts HDR/EXR to RGBM? Otherwise the conversion has to be done with BTW: Couldn't we store RGBM textures in TGA files instead of PNG? In this way, we could load the textures with the existing |
Sounds good to me!
Are file sizes comparable? |
AFAIK, TGA will produce bigger files. Besides, not all TGA files are compressed which means sometimes the size can vary noticeably. I've mentioned TGA since I've encountered its usage in combination with RGBM, see https://github.com/box/hdrCompressor. @MiiBond Does it make sense to use RGBM encoded TGA files on the web, too? Or should we focus on PNG? |
Definitely png or maybe webp. Both of those support transparency and are good for the web. ps. I forgot that this |
Describe the bug
RGBM PNG textures on iOS are showing extreme banding.
To Reproduce
Run these examples on any iPhone/iPad
https://threejs.org/examples/#webgl_loader_texture_rgbm
https://threejs.org/examples/#webgl_materials_envmaps_hdr
(select RGBM map)
Platform
iOS iPhone/iPad
The text was updated successfully, but these errors were encountered: