渲染到QGLFrameBufferObject与屏幕时Alpha合成错误 [英] Alpha compositing wrong when rendering to QGLFrameBufferObject vs screen

查看:117
本文介绍了渲染到QGLFrameBufferObject与屏幕时Alpha合成错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Qt中甚至对QGLFrameBufferObjects呈现部分不透明的简单形状时,我也会遇到问题.

I'm having a problem when rendering even simple shapes with partial opacity to QGLFrameBufferObjects in Qt.

我已将问题归结为:

当我将一个简单的四边形渲染为一个QGLFrameBufferObject并将颜色设置为(1,0,0,.5),然后将其着色到屏幕上时,我得到的结果是红色太亮,对于50%的不透明度.如果我将具有相同颜色(实际上是相同代码)的相同四边形直接绘制到屏幕上,则会获得正确的颜色值.如果我用不透明度== 1.0渲染四边形,那么结果是相同的...在两种情况下,我都会得到完整的深红色.我已经通过直接使用buffer.toImage().save("/tmp/blah.tif")将缓冲区转储到磁盘来确认缓冲区中的颜色确实错误.

When I render a simple quad to a QGLFrameBufferObject with color set to (1,0,0,.5), and then blit that to the screen, I get a result that is way too light a red for 50% opacity. If I draw the same quad with the same color (same code, in fact) directly to the screen, I get the correct color value. If I render the quad with opacity == 1.0, then the results are the same...I get a full, deep red in both cases. I've confirmed that the color is really wrong in the buffer by dumping the buffer to disk directly with buffer.toImage().save("/tmp/blah.tif").

在这两种情况下,我都已在执行操作之前将输出缓冲区清除为(1,1,1,1).

In both cases, I've cleared the output buffer to (1,1,1,1) before performing the operation.

为什么我绘制的部分透明的东西在绘制到屏幕外缓冲区时比在屏幕上正确绘制时更亮?必须在FBO上设置一些状态,但我无法弄清楚它是什么.

Why are things I draw that are partially transparent coming out lighter when drawn to an offscreen buffer than if I draw them right to the screen? There must be some state that I have to set on the FBO or something, but I can't figure out what it is.

推荐答案

Alpha并不表示透明".这根本没有任何意义.仅当 you 赋予一个含义时,它才有意义.当您设置使用Alpha来控制透明度的混合模式时,它仅表示透明".因此,如果您没有设置混合模式,而该模式

Alpha does not mean "transparent." It doesn't mean anything at all. It only takes up a meaning when you give it one. It only mean "transparent" when you set up a blend mode that uses alpha to control transparency. So if you didn't set up a blend mode that creates the effect of transparency, then alpha is just another color component that will be written exactly as is to the framebuffer.

这篇关于渲染到QGLFrameBufferObject与屏幕时Alpha合成错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆