Skip to content
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

Image-based lighting #21

Merged
merged 13 commits into from
Jun 3, 2022
Merged

Image-based lighting #21

merged 13 commits into from
Jun 3, 2022

Conversation

expenses
Copy link
Owner

Closes #4.

We need a way to transcode BC6H formats on mobile. https://github.com/KhronosGroup/BC6H-Decoder-WASM seems decent.

@expenses expenses changed the title Imaged-based lighting Image-based lighting May 30, 2022
@expenses
Copy link
Owner Author

A few pics:

20220530_17h34m01s_grim
20220530_17h31m26s_grim

@expenses
Copy link
Owner Author

The harder but nicer (for.me) thing to do might be to write my own bc6h decompressor. The format is atleast bit-exact. Links:

https://docs.microsoft.com/en-us/windows/win32/direct3d11/bc6h-format#decoding-the-bc6h-format

https://github.com/hglm/detex/blob/master/decompress-bptc-float.c

@expenses
Copy link
Owner Author

Fun fact: ASTC also supports HDR data according to https://themaister.net/blog/2021/08/29/compressed-gpu-texture-formats-a-review-and-compute-shader-decoders-part-3-3/.

We could theoretically use that as the format for IBL images and decompress to fp16 on desktop. It'd ideally use a compute shader though.

@expenses
Copy link
Owner Author

expenses commented Jun 1, 2022

Re: decoding bc6h textures for mobile GPUs, here's what I've tried so far:

  1. Converting https://github.com/KhronosGroup/BC6H-Decoder-WASM/blob/main/assembly/decoder.ts to rust. Hard because it's written in an asm flavour of js with some wasm built-ins
  2. Converting https://github.com/Themaister/Granite/blob/master/assets/shaders/decode/bc6.comp to rust. Got pretty far, but ran into a wall (I think?) because of uint->int casting differences between glsl and rust.
  3. Using https://github.com/ifeherva/bcndecode. Ran into an issue where the blue channel wasn't decoded correctly: DDS BC6 decoding has a broken blue channel python-pillow/Pillow#6344.

What I might try is converting https://github.com/Themaister/Granite/blob/master/assets/shaders/decode/bc6.comp to a full-screen fragment shader. This might be the best thing to do anyway because it'd be using gpu multithreading.

@expenses expenses marked this pull request as ready for review June 3, 2022 12:44
@expenses
Copy link
Owner Author

expenses commented Jun 3, 2022

What I might try is converting https://github.com/Themaister/Granite/blob/master/assets/shaders/decode/bc6.comp to a full-screen fragment shader. This might be the best thing to do anyway because it'd be using gpu multithreading.

This worked!

@expenses expenses merged commit 2342002 into master Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image Based Lighting (IBL)
1 participant