We can regulate image lightness in photoshop like this (Ctrl+U):
I find it results in different end lightness for different original lightness and for different lighness offset you want to regulate.
And I make a formula which I have described in previous article here.
And the ratio of three channels of rgb is fixed when we only ajust lightness.
so here is the shader implement the lightness regulation function(image dim effect):
#ifdef GL_ES
precision mediump float;
#endif
#ifdef GL_ES
varying mediump vec2 v_texCoord;
#else
varying vec2 v_texCoord;
#endif
float L(float l, float x)
{
return clamp((x + abs(x)) * 0.5 + l * (1.0 - abs(x)), 0.0, 1.0);
}
vec3 adjustLightness(vec3 rgb, float offset)
{
float l = max(rgb.r, max(rgb.g, rgb.b));
float e = 1.0e-6;
return clamp(rgb*L(l,offset)/(l+e), 0.0, 1.0);
}
void main()
{
vec4 color = texture2D(CC_Texture0, v_texCoord);
color.rgb = adjustLightness(color.rgb,-0.2);
gl_FragColor = color;
}
Photoshop图片亮度调节算法

本文介绍了一种在Photoshop中调整图片亮度的方法,并提供了一个用于实现亮度调节功能的shader代码示例。该方法适用于不同原始亮度级别的图片,并能够根据所需的亮度偏移进行调整。
1万+

被折叠的 条评论
为什么被折叠?



