Skip to content

ebiten: add a mode for automatic gamma correction #3313

@hajimehoshi

Description

@hajimehoshi

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • PlayStation 5
  • Xbox
  • Web Browsers

What feature would you like to be added?

Currently Ebitengine doesn't distinguish linear sRGB and gamma-corrected sRGB. An image file basically has gamma corrected values, while a shader should treat linear values. So the rendering result is not actually correct.

We can use automatic conversion in graphcis libraries:

  • OpenGL's GL_SRGB8_ALPHA8
  • Metal's MTLPixelFormatRGBA8Unorm_sRGB
  • DirectX's DXGI_FORMAT_R8G8B8A8_UNORM_SRGB

With this, we can send pixel data to GPU as gamma-corrected sRGB values, and when a color is picked in a shader, GPU automatically converts them to linear sRGB values.

As this is a breaking change, this should be done in v3. We might be able to have an option for v2 as an experimental flag.

The current concern is that I am not sure if premultiplied-alpha gamma-corrected values make sense. This might confuse the graphics library's conversion.

Why is this needed?

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions