imgui icon indicating copy to clipboard operation
imgui copied to clipboard

Adding sRGB colors to ImGui style.

Open RisingLiberty opened this issue 1 year ago • 4 comments

This is a pull request to enable SRGB colors within ImGui for all 3 styles (dark, light, classic) All linear colors have been converted to sRGB formats. The reason sRGB colors are hardcoded instead of calculated at runtime from the linear colors is for performance reasons. This brings in extra maintance as when the default style colors are changed, both the linear and sRGB values need updating.

This PR got created to resolve the issue raised in https://github.com/ocornut/imgui/issues/578

To enable the sRGB colors, simply add ImGuiConfigFlags_IsSRGB to the config flags and update the style

ImGuiIO& io = ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_IsSRGB;
ImGui::StyleColorsDark();

Normal dark theme normal_dark

sRGB dark theme before change srgb_before_change

sRGB dark theme after change srgb_after_change

RisingLiberty avatar Jul 28 '24 19:07 RisingLiberty

This can probably be merged with https://github.com/ocornut/imgui/pull/2943

RisingLiberty avatar Jul 28 '24 21:07 RisingLiberty

this doesn't degamma color wheels, only theme colors so is an incomplete solution.

here's a generic, dynamic fix to the issue (dx12 only - other backends can be upgraded in a similar fashion)

https://github.com/ocornut/imgui/pull/7904

adv-sw avatar Aug 19 '24 17:08 adv-sw

Working fine for me, haven't tested colorwheels tho. There is one bug in your code however. You're using &= to validate the config flags, but this ERASES all configflags except for the srgb one. The correct way would be simply just a &.

nepp95 avatar Nov 17 '24 13:11 nepp95

Some of the colors in the gamma corrected version are quite different from the original ones. This seems to be caused by many of the colors being rendered with transparency, using the alpha values in the colors. Multiplying the rgb channels with with the alpha channel before performing the sRGB conversion, and then dividing the result with the alpha seems to produce colors much closer to the original values.

Rectus avatar Mar 20 '25 14:03 Rectus