调整在OpenGL整个场景的亮度/伽玛 [英] Tweak the brightness/gamma of the whole scene in OpenGL

查看:1191
本文介绍了调整在OpenGL整个场景的亮度/伽玛的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道我如何能实现在OpenGL如下效果:

Does anyone know how I can achieve the following effect in OpenGL:

  • 更改渲染场景的亮度
  • 或实施在OpenGL灰度系数设置

我已通过改变光的环境参数和光(定向和全向)的类型尝试,但结果并不均匀。 TIA。

I have tried by changing the ambient parameter of the light and the type of light (directional and omnidirectional) but the result was not uniform. TIA.

感谢您的帮助,一些​​额外的信息:   *我不能使用任何窗口具体的API。   *伽马设置应该不会影响整个窗口,因为我必须有不同的伽玛不同的看法。

Thanks for your help, some additional information: * I can't use any windows specifics API. * The gamma setting should not affect the whole window as I must have different gamma for different views.

推荐答案

在win32的可以使用SetDeviceGammaRamp调整总体亮度/伽玛。但是,这会影响整个显示器,所以它不是一个好主意,除非你的应用程序是全屏。

On win32 you can use SetDeviceGammaRamp to adjust the overall brightness / gamma. However, this affects the entire display so it's not a good idea unless your app is fullscreen.

便携式的选择是要么绘制整个场景亮或更暗(这是一个麻烦),或拍击全屏Alpha混合四在整个场景变亮或变暗希望它。既不这些方法可影响伽玛曲线,只有整体亮度;调整需要抓住整个场景到纹理,然后通过一个像素着色器运行每一纹理像素通过伽玛函数使其回到屏幕的伽马

The portable alternative is to either draw the entire scene brighter or dimmer (which is a hassle), or to slap a fullscreen alpha-blended quad over the whole scene to brighten or darken it as desired. Neither of these approaches can affect the gamma-curve, only the overall brightness; to adjust the gamma you need grab the entire scene into a texture and then render it back to the screen via a pixel-shader that runs each texel through a gamma function.

好了,看了更新的问题,你需要的是用勾兑设置变暗或变亮的一切在它下面四。例如:

Ok, having read the updated question, what you need is a quad with blending set up to darken or brighten everything underneath it. Eg.

if( brightness > 1 )
{
    glBlendFunc( GL_DEST_COLOR, GL_ONE );
    glColor3f( brightness-1, brightness-1, brightness-1 );
}
else
{
    glBlendFunc( GL_ZERO, GL_SRC_COLOR );
    glColor3f( brightness, brightness, brightness );
}
glEnable( GL_BLEND );

draw_quad();

这篇关于调整在OpenGL整个场景的亮度/伽玛的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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