obsproject / obsproject/obs-browser

Semitransparent rendering bug in SRGB blending method

Open
#469 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
904
Forks
267
Avg merge
1d 23h
Merged PRs (30d)
2

Description

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 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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in obs-browser-source.cpp around the blending setup at lines 646 and 652, then reproduce the issue with the provided HTML page and compare the Default and SRGB Off methods. Check how premultiplied RGBA, framebuffer sRGB, and linear texture sampling interact. Done means semitransparent text and colors render without darkening or black edge artifacts.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.