Semitransparent rendering bug in SRGB blending method #469

Open
opened 2024-12-21 19:35:42 -06:00 by SoprachevAK · 2 comments
SoprachevAK commented 2024-12-21 19:35:42 -06:00 (Migrated from github.com)

Operating System Info

Other

Other OS

macOS 15, Windows 10

OBS Studio Version

Other

OBS Studio Version (Other)

31.0.0, 30.2.3

OBS Studio Log URL

https://obsproject.com/logs/ZJw0Cy9mkJNEyV3i

OBS Studio Crash Log URL

No response

Expected Behavior

The OBS Browser Source should correctly render half transparent colors without darkening colors or introducing artifacts around edges.

image

Current Behavior

Half transparent pixels render darkened than actual should, and black artifacts are present around text (due anti aliasing, which produce half transparency)
image

Steps to Reproduce

  1. Add white color background
  2. Add this html page like Browser source with default CSS preset (transparent body background)
<html lang="en">
<body>
  <div style="
    margin: 0;
    font-size: 2em;
    font-weight: 900;
    font-family: monospace;
  ">
    <p style="color: #ffffff">#ffffff / 100%</p>
    <p style="color: rgb(255 255 255 / 75%)">#ffffff / 75%</p>
    <p style="color: rgb(255 255 255 / 25%)">#ffffff / 25%</p>
    <p style="color: #1e6ce080">#1e6ce0 / 50%</p>
  </div>
</body>
</html>
  1. Switching Blending Method between Default and SRBG Off and see differences

Anything else we should know?

This artifacts looks like premultiplied RGBA rendering like non premultiplied

I am check rendering mechanism, and it correctly set blending mode for premultiplied renderer github.com/obsproject/obs-browser@082a0a2d1c/obs-browser-source.cpp (L646)

I try to play with srgb texture binding, and if set gs_enable_framebuffer_srgb(false); and gs_effect_set_texture(image, draw_texture) here:
github.com/obsproject/obs-browser@082a0a2d1c/obs-browser-source.cpp (L652)
All works correctly, but i think, that this code and linear_sample needed for something

I am interested in fixing this bug and can create a PR, but I need advice on which direction to take next.

### Operating System Info Other ### Other OS macOS 15, Windows 10 ### OBS Studio Version Other ### OBS Studio Version (Other) 31.0.0, 30.2.3 ### OBS Studio Log URL https://obsproject.com/logs/ZJw0Cy9mkJNEyV3i ### OBS Studio Crash Log URL _No response_ ### Expected Behavior The OBS Browser Source should correctly render half transparent colors without darkening colors or introducing artifacts around edges. <img width="364" alt="image" src="https://github.com/user-attachments/assets/aabff468-9b66-496d-9d51-358e22404c92" /> ### Current Behavior Half transparent pixels render darkened than actual should, and black artifacts are present around text (due anti aliasing, which produce half transparency) <img width="405" alt="image" src="https://github.com/user-attachments/assets/52a67010-ced8-4258-aea7-cf09da485528" /> ### Steps to Reproduce 1. Add white color background 2. Add this html page like `Browser` source with default `CSS` preset (transparent body background) ```html <html lang="en"> <body> <div style=" margin: 0; font-size: 2em; font-weight: 900; font-family: monospace; "> <p style="color: #ffffff">#ffffff / 100%</p> <p style="color: rgb(255 255 255 / 75%)">#ffffff / 75%</p> <p style="color: rgb(255 255 255 / 25%)">#ffffff / 25%</p> <p style="color: #1e6ce080">#1e6ce0 / 50%</p> </div> </body> </html> ``` 3. Switching `Blending Method` between `Default` and `SRBG Off` and see differences ### Anything else we should know? This artifacts looks like `premultiplied RGBA` rendering like `non premultiplied` I am check rendering mechanism, and it correctly set blending mode for premultiplied renderer https://github.com/obsproject/obs-browser/blob/082a0a2d1c393f66dc68b62fa402ca23d4c02dbe/obs-browser-source.cpp#L646 I try to play with srgb texture binding, and if set `gs_enable_framebuffer_srgb(false);` and `gs_effect_set_texture(image, draw_texture)` here: https://github.com/obsproject/obs-browser/blob/082a0a2d1c393f66dc68b62fa402ca23d4c02dbe/obs-browser-source.cpp#L652 All works correctly, but i think, that this code and `linear_sample` needed for something I am interested in fixing this bug and can create a PR, but I need advice on which direction to take next.
SoprachevAK commented 2024-12-21 19:42:18 -06:00 (Migrated from github.com)

May be srgb rendering mode overrides blend functions somewhere in rendering pipeline outside CEF

May be `srgb` rendering mode overrides blend functions somewhere in rendering pipeline outside CEF
SoprachevAK commented 2025-07-15 16:46:13 -05:00 (Migrated from github.com)

still reproduced

still reproduced
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-obsproject/obs-browser#469
No description provided.