cocos shader 之 模糊滤镜

cocos shader 之 模糊滤镜,第1张

概述效果: VSH: #ifdef OPENGL_ESprecision mediump vec2;precision mediump float;#endif// Attributesattribute vec3 a_position;attribute vec2 a_texCoord;attribute vec4 a_color;// Varyings#ifdef GL_ES

效果:


VSH:

#ifdef OPENGL_ESprecision mediump vec2;precision mediump float;#endif// Attributesattribute vec3 a_position;attribute vec2 a_texCoord;attribute vec4 a_color;// varyings#ifdef GL_ESvarying vec2 v_texCoord;#elsevarying vec2 v_texCoord;#endifvarying vec4 v_fragmentcolor;voID main(){    gl_position = CC_PMatrix * vec4(a_position,1.0);    v_texCoord = a_texCoord;    v_fragmentcolor = a_color;}

FSH:
#ifdef GL_ESprecision mediump float;#endifvarying vec4 v_fragmentcolor;varying vec2 v_texCoord;uniform vec2 resolution;//uniform float blurRadius;vec4 blur(vec2 p){    vec4 col = vec4(0);    vec2 unit = 1.0/resolution;    float r = 10.0;    float nCount = 0.0;    for (float x = -r; x < r; ++x) {        for (float y = -r; y < r; ++y) {            float weight = (r-abs(x)) * (r-abs(y));            col += texture2D(CC_Texture0,p + vec2(x*unit.x,y*unit.y))*weight;            nCount += weight;        }    }    return col / nCount;}voID main(voID){    gl_Fragcolor = blur(v_texCoord);}
总结

以上是内存溢出为你收集整理的cocos shader 之 模糊滤镜全部内容,希望文章能够帮你解决cocos shader 之 模糊滤镜所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1072014.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存