【问题标题】:Why do my semi-opaque vertices make background objects brighter in OpenGL?为什么我的半透明顶点会使 OpenGL 中的背景对象更亮?
【发布时间】:2010-10-17 20:19:36
【问题描述】:

我在一个彩色立方体前面渲染 4 个顶点(一个正方形)。顶点颜色为白色,但在 0.5f 处混合。

相关:Why does my colored cube not work with GL_BLEND?

请有人告诉我为什么彩色立方体在被半透明方块遮挡时显得更亮?

立方体呈现在前面没有正方形:

Normal cube http://img408.imageshack.us/img408/2853/normalcube.png

并且,用正方形渲染:

Cube with square http://img142.imageshack.us/img142/6255/brightsquare.png

请查看用于create the colored cube 的代码、用于实际draw the cube 的代码和code where the cube and square are rendered

这是我的 init 函数中的代码:

glEnable(GL_CULL_FACE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);

【问题讨论】:

  • 所有链接都指向同一段代码
  • 该死,谢谢提醒!现已修复...

标签: opengl opacity


【解决方案1】:

我会说这是因为你的半透明方块被添加到现有像素中,从而增加了它们的强度。

documentation for glBlendFunc() 建议将第二个参数设置为GL_ONE_MINUS_SRC_ALPHA,这是实现透明度的样板。试试看。

【讨论】:

  • 是的,看起来像一个白色半透明方块,我看不出问题。
猜你喜欢
  • 2014-02-26
  • 2012-10-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-07
相关资源
最近更新 更多