原始图像
处理后
逻辑
提取图像中超过你需要的亮度的像素,根据曝光函数曲线图,让亮的更亮,暗的更暗
简易曝光函数 f = -4*gray^2+5*gray;
核心代码
1 #version 330 core 2 out vec4 FragColor; 3 4 in vec2 TexCoords; 5 6 uniform sampler2D screenTexture; 7 uniform sampler2D textrue0; 8 9 vec4 expose(vec4 col, float gray, float k) 10 { 11 float a = 4.0 * k - 1.0; 12 float b = 2.0 - 4.0 * k; 13 float result = gray * gray * b + gray * a; //求取曝光参数 14 15 return result * col; 16 } 17 18 void main() 19 { 20 vec4 col = texture(screenTexture, TexCoords); 21 vec4 col2 = texture(textrue0, TexCoords); 22 float gray = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b; //获取亮度值(灰度) 23 FragColor = expose(col2, gray, 1.5); 24 }