idea 亮度 调整_调整在OpenGL整个场景的亮度/伽玛

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

Change the brightness of the rendered scene

Or implementing a Gamma setting in OpenGL

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.

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.

解决方案

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.

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();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值