Shaders to regulate image lightness like in PhotoShop(shader实现Photoshop的亮度调节效果,按钮变暗效果)
来源:互联网 发布:传奇npc算法 编辑:程序博客网 时间:2024/06/10 12:56
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_ESprecision mediump float;#endif#ifdef GL_ESvarying mediump vec2 v_texCoord;#elsevarying vec2 v_texCoord;#endiffloat 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;}
0 0
- Shaders to regulate image lightness like in PhotoShop(shader实现Photoshop的亮度调节效果,按钮变暗效果)
- Shader之Photoshop Color效果
- 【Unity Shaders】Using Textures for Effects —— 实现Photoshop的色阶效果
- PhotoShop效果的数学公式
- Photoshop Lightness Regulation Formula
- Unity Shaders and Effects Cookbook (2-7)实现 Photoshop 色阶效果
- CSS实现Photoshop选区效果
- 实现photoshop 颜色混合的shader
- PhotoShop设计简洁清新的小按钮效果
- Photoshop详细教程七之立体按钮的明暗效果
- 实现activity变暗的效果
- 实现activity变暗的效果
- HLSL编程实现PhotoShop滤镜效果
- HLSL编程实现PhotoShop滤镜效果
- HLSL编程实现PhotoShop滤镜效果
- HLSL编程实现PhotoShop滤镜效果
- HLSL编程实现PhotoShop滤镜效果
- HLSL编程实现PhotoShop滤镜效果
- 谈谈jquery的实现
- Android启动白屏问题解决办法
- Java获取网络时间
- OpenGl面试题(持续更新)
- caffe编译遇到的问题(持续更新)
- Shaders to regulate image lightness like in PhotoShop(shader实现Photoshop的亮度调节效果,按钮变暗效果)
- A 房间安排
- Springboot 跑单元测试
- Flex布局
- 支持向量机--SVM入门
- webstrom less 配置
- spring HelloWorld!
- 关于使用hadoop出各种错的一些积累
- python,apt-get安装包位置