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

sRGB support #15

Closed
pezcode opened this issue Mar 1, 2020 · 2 comments · Fixed by #49
Closed

sRGB support #15

pezcode opened this issue Mar 1, 2020 · 2 comments · Fixed by #49
Labels
enhancement New feature or request

Comments

@pezcode
Copy link
Contributor

pezcode commented Mar 1, 2020

Support for sRGB textures and swapchain would be nice to have. sRGB texture formats will perform the conversion to and from linear RGB in hardware. This is important for loading color images (this excludes normal maps, etc.) which are almost always stored as sRGB, as well as applying the correct gamma transformation for display output. You can do it manually, but that's slow, error prone and enforces bad habits.

Currently, three things are blocking this:

  • Swapchain surface format doesn't request _SRGB formats, but _UNORM
  • load_texture doesn't support _SRGB formats, even though all 4 formats (RGBA, BC, ASTC, ETC2) have SRGB versions. not sure why they're not supported, maybe there's a good reason I'm not aware of.
  • Imgui :< theme colors are defined as sRGB, then interpolated in the shader (which is incorrect), and finally output as mangled sRGB. As a result, storing to an sRGB swapchain image will effectively apply the transform twice. There's an ongoing PR (sRGB support ocornut/imgui#2943) that partly fixes this. This is the real blocking thing here.

Would appreciate some input 😃 Maybe there's a reason you went without sRGB, or you think it's a non-issue.

@TheLavaBlock TheLavaBlock added question Further information is requested enhancement New feature or request labels Mar 2, 2020
@TheLavaBlock TheLavaBlock removed the question Further information is requested label Oct 10, 2020
TheLavaBlock added a commit that referenced this issue Jan 12, 2021
@TheLavaBlock
Copy link
Member

The first two issues should now be fixed.

Request sRGB swapchain if needed:

app.config.surface.formats = { VK_FORMAT_R8G8B8A8_SRGB };

if (!app.setup())
    return error::not_ready;

I don't know what to do about the last one (imgui) at the moment. Let's wait and see what happens there 👀

@TheLavaBlock
Copy link
Member

FYI: Added FreeType in 89c95f2 - See Gamma Correct Blending

FreeType assumes blending in linear space rather than gamma space. See FreeType note for FT_Render_Glyph. For correct results you need to be using sRGB and convert to linear space in the pixel shader output. The default Dear ImGui styles will be impacted by this change (alpha values will need tweaking).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants