kpreid / all-is-cubes

Yet another block/voxel game; in this one the blocks are made out of blocks. Runs in browsers on WebGL+WebAssembly.
https://kpreid.dreamwidth.org/tag/all+is+cubes
Apache License 2.0
164 stars 8 forks source link

`wgpu::TextureFormat::Rgba16Float` output is broken on `webgl` backend #310

Open kpreid opened 2 years ago

kpreid commented 2 years ago

Expected rendering (all-is-cubes-desktop):

Screen Shot 2022-10-23 at 10 30 49

Actual rendering (web):

web14

It appears that any channel with a value above 1.0 gets 0.0 (whereas clamping might be more expected).

This is as of commit c49b52810515bcdd362e3dd4120bb68d89cfc8a1. If I revert to when all-is-cubes was using wgpu 0.13, Rgba16Float doesn't appear in the list of supported formats.

Modifying a wgpu web example to use Rgba16Float and have some over-1 values does not reproduce the problem, so there is some kind of additional factor to discover (possibly something to do with my temporary frame buffer and optional tonemapping logic?).

I am going to temporarily work around this by avoiding the Rgba16Float format in choose_surface_format().

kpreid commented 9 months ago

Testing update: with wgpu 0.19.0 and the workaround code removed, colors are no longer corrupted as above. However, they appear to have incorrect gamma (and no actual HDR output to display), on both Chrome and Firefox.

image

This suggests that either wgpu or the browser is (inappropriately for this application) assuming the colors in the Rgba16Float texture are sRGB encoded.

kpreid commented 3 months ago

Testing: Same result as previous comment with wgpu 22.0.0.