我正在编写自定义模糊着色器,
"#include <common>",
// blur samples
"const int SAMPLES = 10;",
"uniform float radius;",
"uniform sampler2D tDiffuse;",
"varying vec2 vUv;",
"void main() {",
// sample the source
" vec2 uv = vUv;",
" vec4 cTextureScreen = texture2D( tDiffuse, vUv );",
" vec3 res = vec3(0);",
" for(int i = 0; i < SAMPLES; ++i) {",
" res += cTextureScreen.a;",
" vec2 d = vec2(0.5) - uv;",
" uv += d * radius;",
" }",
" gl_FragColor = vec4(res/float(SAMPLES), 1.0);",
"}"
哪个是:https://www.shadertoy.com/view/ltVSRK的直口
与三个效果作曲家一起使用。
[不幸的是,tDiffuse
似乎没有打包为rgb,对于如何实现所需的效果或所需的转换,我感到很困惑。
另请参阅以下问题以了解更多详细信息:what do texture2D().r and texture2D().a mean?