如何使用THREE.js在客户片段着色器中使用RGB进行tDiffuse处理

问题描述 投票:1回答:1

我正在编写自定义模糊着色器,

        "#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?

three.js glsl shader
1个回答
0
投票
我最终解决了我的问题(并努力解决):
© www.soinside.com 2019 - 2024. All rights reserved.