hello_imgui icon indicating copy to clipboard operation
hello_imgui copied to clipboard

Request: Apple Extended Dynamic Range, use linear instead of gamma 2.2 rendering for ImageMetal (StoreTextureFloat16Rgba)

Open AndrewKeYanzhe opened this issue 10 months ago • 2 comments

hello_imgui's ImageMetal buffers (float16) are rendered with gamma 2.2 encoding. I would like to render it as linear.

I have modified the EDR demo code to show grayscale bars with float input linearly scaling from 0-1

https://github.com/AndrewKeYanzhe/hello_imgui_template/blob/grayscale-gamma2.2-demo-metal/hello_edr_og.mm

Digital color meter reads the middle bar as middle gray 127/128, which means that the ImageMetal buffer goes through gamma encoding. Linear float 0.5 (50 nits) would map to around 186 in gamma 2.2 encoded value.

Image

Pinging @wkjarosz , I'm assuming for HDRView you are not using HelloImGui::ImageMetal ? I see that your app shows HDR images without gamma issues. I would love to hear how you implemented this, if possible.

AndrewKeYanzhe avatar Apr 27 '25 16:04 AndrewKeYanzhe

I would need more explanation. I'm not proficient with EDR.

You rewrote the whole float32_to_float16 function, but apart from that I cannot see any change as far as gamma is supported.

pthom avatar May 14 '25 14:05 pthom

@AndrewKeYanzhe I am not using HelloImGui::ImageMetal. I display my images using the CustomBackground callback, with a custom fragment shader that performs color management and appropriate non-linear transfer functions. If I recall, with EDR, you should output sRGB encoded values, but with appropriate mirroring of the sRGB curve to handle negative values.

wkjarosz avatar Jul 25 '25 04:07 wkjarosz