使用固定管道的人均对比度控制

发布于 2025-02-03 06:25:47 字数 490 浏览 2 评论 0原文

我正在使用固定的Pipeline渲染,并希望以每个像素方式控制图像的对比度(即与背景的差异)。换句话说,如果C为r/g/b,我想获得

c = a*cs +(1 -a)*c0,

其中c0是背景颜色,而a可以从像素到像素。如果背景为黑色(C0 = 0),我知道该怎么做:首先将flamebuffer中的alpha设置为我想要的每个像素,然后

glblendfunc(gl_dst_alpha,gl_zero,gl_zero)>

如果背景不是黑色,则可以设置alpha,将颜色清除为背景,然后执行

glblendfunc(gl_dst_alpha,gl_one_one_minus_dst_alpha)

此操作仅在您绘制重叠的一个对象时才可行。在重叠的情况下,帧缓冲器值不再是背景颜色,因此您不再获得C = A*CS +(1-A)*C0。

我是否缺少一些明显的方法?也许我不应该使用alpha混合,而是其他东西?

I'm using fixed-pipeline rendering, and would like to control the contrast of my images (i.e., difference from background) in a per-pixel manner. In other words, if C is R/G/B, I'd like to get

C = A*Cs + (1 - A)*C0

where C0 is the background color, and A can vary from pixel to pixel. If the background is black (C0 = 0), I know how to do this: first set the alpha in the framebuffer to what I want on a per-pixel basis, then

glBlendFunc(GL_DST_ALPHA, GL_ZERO)

If the background isn't black, then you can set the alpha, clear the color to background, and do

glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA)

This works only if none of the objects you draw overlap; in case of overlap, the framebuffer value is no longer the background color, and therefore you no longer get C = A*Cs + (1 - A)*C0.

Is there some obvious way to do this that I'm missing? Maybe I shouldn't use alpha blending but something else?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文