Kneelawk/fractal-rs

Fractal colorizer is callibrated for sRGB

Opened this issue · 1 comments

The Issue

Currently the default fractal colorizer outputs raw sRGB values instead of the linear-sRGB values expected by shaders. This means that sometimes rendering to the wrong surface or texture format will cause fractals to look "washed-out".

The Workaround

The current work around is to just keep fractal textures in Rgba8Unorm format and to only render to Bgra8Unorm surfaces. Rendering fractal textures to a Rgb8UnormSrgb texture would cause generated PNGs to look washed-out and using a Bgra8UnormSrgb surface format will make the fractal look washed-out in the viewer.

The Solution

My eventual plan for a solution for this is to switch everything over to Rgba8UnormSrgb and Bgra8UnormSrgb formats and just have this specific colorizer convert its output back to linear-sRGB in the shader and not perform any conversion for the CPU variant.

When new colorizers are introduced, GPU colorizers will output linear-sRGB by default in the shader and let WGPU convert their output to sRGB for storage. CPU colorizers will also output linear-sRGB by default but will have to have their output manually converted to sRGB.

I should note that not everything supports the Bgra8UnormSrgb surface format (e.g. WebGPU). So instead, I should probably have it be configurable whether any colorizer outputs sRGB or linear.