博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
美颜代码
阅读量:6691 次
发布时间:2019-06-25

本文共 5342 字,大约阅读时间需要 17 分钟。

hot3.png

 precision highp float;

 varying highp vec2 textureCoordinate;

 uniform sampler2D inputImageTexture;

 uniform vec2 singleStepOffset;

 uniform highp vec4 params;

 const highp vec3 W = vec3(0.299,0.587,0.114);

 const mat3 saturateMatrix = mat3(

1.1102,-0.0598,-0.061,

-0.0774,1.0826,-0.1186,

-0.0228,-0.0228,1.1772);

               

 float hardlight(float color)

 {

   if(color <= 0.5){

        color = color * color * 2.0;

   }else{

        color = 1.0 - ((1.0 - color)*(1.0 - color) * 2.0);

   }

   return color;

}

 void main(){

     vec2 blurCoordinates[24];

     blurCoordinates[0] = textureCoordinate.xy + singleStepOffset * vec2(0.0, -10.0);

     blurCoordinates[1] = textureCoordinate.xy + singleStepOffset * vec2(0.0, 10.0);

     blurCoordinates[2] = textureCoordinate.xy + singleStepOffset * vec2(-10.0, 0.0);

     blurCoordinates[3] = textureCoordinate.xy + singleStepOffset * vec2(10.0, 0.0);

                   

     blurCoordinates[4] = textureCoordinate.xy + singleStepOffset * vec2(5.0, -8.0);

     blurCoordinates[5] = textureCoordinate.xy + singleStepOffset * vec2(5.0, 8.0);

     blurCoordinates[6] = textureCoordinate.xy + singleStepOffset * vec2(-5.0, 8.0);

     blurCoordinates[7] = textureCoordinate.xy + singleStepOffset * vec2(-5.0, -8.0);

                   

     blurCoordinates[8] = textureCoordinate.xy + singleStepOffset * vec2(8.0, -5.0);

     blurCoordinates[9] = textureCoordinate.xy + singleStepOffset * vec2(8.0, 5.0);

     blurCoordinates[10] = textureCoordinate.xy + singleStepOffset * vec2(-8.0, 5.0);

     blurCoordinates[11] = textureCoordinate.xy + singleStepOffset * vec2(-8.0, -5.0);

                   

     blurCoordinates[12] = textureCoordinate.xy + singleStepOffset * vec2(0.0, -6.0);

     blurCoordinates[13] = textureCoordinate.xy + singleStepOffset * vec2(0.0, 6.0);

     blurCoordinates[14] = textureCoordinate.xy + singleStepOffset * vec2(6.0, 0.0);

     blurCoordinates[15] = textureCoordinate.xy + singleStepOffset * vec2(-6.0, 0.0);

                   

     blurCoordinates[16] = textureCoordinate.xy + singleStepOffset * vec2(-4.0, -4.0);

     blurCoordinates[17] = textureCoordinate.xy + singleStepOffset * vec2(-4.0, 4.0);

     blurCoordinates[18] = textureCoordinate.xy + singleStepOffset * vec2(4.0, -4.0);

     blurCoordinates[19] = textureCoordinate.xy + singleStepOffset * vec2(4.0, 4.0);

                   

     blurCoordinates[20] = textureCoordinate.xy + singleStepOffset * vec2(-2.0, -2.0);

     blurCoordinates[21] = textureCoordinate.xy + singleStepOffset * vec2(-2.0, 2.0);

     blurCoordinates[22] = textureCoordinate.xy + singleStepOffset * vec2(2.0, -2.0);

     blurCoordinates[23] = textureCoordinate.xy + singleStepOffset * vec2(2.0, 2.0);

                   

                   

     float sampleColor = texture2D(inputImageTexture, textureCoordinate).g * 22.0;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[0]).g;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[1]).g;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[2]).g;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[3]).g;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[4]).g;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[5]).g;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[6]).g;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[7]).g;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[8]).g;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[9]).g;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[10]).g;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[11]).g;

                   

     sampleColor += texture2D(inputImageTexture, blurCoordinates[12]).g * 2.0;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[13]).g * 2.0;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[14]).g * 2.0;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[15]).g * 2.0;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[16]).g * 2.0;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[17]).g * 2.0;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[18]).g * 2.0;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[19]).g * 2.0;

                   

     sampleColor += texture2D(inputImageTexture, blurCoordinates[20]).g * 3.0;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[21]).g * 3.0;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[22]).g * 3.0;

     sampleColor += texture2D(inputImageTexture, blurCoordinates[23]).g * 3.0;

     sampleColor = sampleColor / 62.0;

     vec3 centralColor = texture2D(inputImageTexture, textureCoordinate).rgb;

     float highpass = centralColor.g - sampleColor + 0.5;

     for(int i = 0; i < 5;i++){

         highpass = hardlight(highpass);

     }

     float lumance = dot(centralColor, W);

     float alpha = pow(lumance, params.r);

     vec3 smoothColor = centralColor + (centralColor-vec3(highpass))*alpha*0.1;

     smoothColor.r = clamp(pow(smoothColor.r, params.g),0.0,1.0);

     smoothColor.g = clamp(pow(smoothColor.g, params.g),0.0,1.0);

     smoothColor.b = clamp(pow(smoothColor.b, params.g),0.0,1.0);

     vec3 lvse = vec3(1.0)-(vec3(1.0)-smoothColor)*(vec3(1.0)-centralColor);

     vec3 bianliang = max(smoothColor, centralColor);

     vec3 rouguang = 2.0*centralColor*smoothColor + centralColor*centralColor - 2.0*centralColor*centralColor*smoothColor;

     gl_FragColor = vec4(mix(centralColor, lvse, alpha), 1.0);

     gl_FragColor.rgb = mix(gl_FragColor.rgb, bianliang, alpha);

     gl_FragColor.rgb = mix(gl_FragColor.rgb, rouguang, params.b);

     vec3 satcolor = gl_FragColor.rgb * saturateMatrix;

     gl_FragColor.rgb = mix(gl_FragColor.rgb, satcolor, params.a);

}

转载于:https://my.oschina.net/gdxz111/blog/652678

你可能感兴趣的文章
如何做好一名售前工程师 [理论]
查看>>
什么是语法糖?
查看>>
rabbitMQ的安装和创建用户
查看>>
每天一道LeetCode--169.Majority Elemen
查看>>
Struts2笔记——第一个实例HelloWorld
查看>>
Maven安装
查看>>
2.1列表相关知识点
查看>>
OpenStack images
查看>>
xsigo systems
查看>>
ofbiz ins
查看>>
iOS动画实现改变frme和contenOffset
查看>>
深度学习框架搭建之最新版Python及最新版numpy安装
查看>>
mysql GRANT ALL PRIVILEGES 限制某个或所有客户端都可以连接至mysql
查看>>
AaronYang风格 C语言挑讲[二][基本类型、运算符和表达式]
查看>>
DroidPilot使用第一步 - 安装
查看>>
vue-cli —— 项目打包及一些注意事项
查看>>
linux下对/sys/class/gpio中的gpio的控制 (转)
查看>>
ubuntu启动报错 Errors were found while checking the disk-drive for /
查看>>
Django的ModelForm
查看>>
Asp.Net MVC及Web API框架配置会碰到的几个问题及解决方案
查看>>