Closed expenses closed 2 years ago
I double checked and BC6H is the only floating-point compressed texture format available: https://docs.rs/wgpu/latest/wgpu/enum.TextureFormat.html#variant.Bc6hRgbUfloat. As I don't think that basis universal handles these, I think we want to use another encoder for them. Luckily there's plenty. Not sure what platforms don't support the webgl extension, but we can use something like https://github.com/KhronosGroup/BC6H-Decoder-WASM in that case.
Not sure what platforms don't support the webgl extension, but we can use something like https://github.com/KhronosGroup/BC6H-Decoder-WASM in that case.
Phone GPUs do not, apparently.
I likw the look of https://github.com/KhronosGroup/glTF-IBL-Sampler for generating cubemaps from environment images.
It doesn't do bc6h compression though, and a lot of the compressors that I looked into don't support reading/writing to ktx2 images. Well, https://github.com/GPUOpen-Tools/Compressonator does but that ability is disabled in Linux and I couldn't work out how to link with libktx. Might try running it in wine.
Worst comes to worse, I implement ktx2 reading/writing in https://github.com/expenses/wgpu-bc6h-compression/ and then we have an easy 2-step workflow.
We want the max cubemap size we support to be 1024x1024(x6) as this is 128mb raw and 8mb BC6H compressed (5.81mb with zstd supercompression!)
Started a branch here: https://github.com/expenses/mateversum/compare/ibl.
Currently lighting is just a single fixed directional light and things look pretty ugly. A much better solution would be to load a HDR image (per world) for use as a skybox and IBL.
Babylon.js uses it's own funky format for IBL environment maps: https://doc.babylonjs.com/divingDeeper/materials/using/HDREnvironment#what-is-a-env-tech-deep-dive. It might be worth thinking about using this, but I don't like that it uses packed .PNGs but then treats them as being HDR even when they're not, really.
https://github.com/derkreature/IBLBaker is another project to look into. I think it exports DDSes though but I imagine there's some tool to losslessly convert them to KTX 2s.