Opengl es GLSL将浮点数组旁路到均匀

Opengl es GLSL将浮点数组旁路到均匀,opengl-es,glsl,Opengl Es,Glsl,定影器 muOffsetHandle = getUniformLocation("offset"); muWeightHandle = getUniformLocation("weight"); 使用程序 GLES20.glUniform1fv(muOffsetHandle, 1, mOffset, 0); GLES20.glUniform1fv(muWeightHandle, 1, mWeight, 0); 瓦尔斯 碎片着色器 "

定影器

    muOffsetHandle = getUniformLocation("offset");      
    muWeightHandle = getUniformLocation("weight");
使用程序

    GLES20.glUniform1fv(muOffsetHandle, 1, mOffset, 0);
    GLES20.glUniform1fv(muWeightHandle, 1, mWeight, 0);
瓦尔斯

碎片着色器

        "uniform float offset[3];\n" +
        "uniform float weight[3];\n" +
然后尝试达到:重量[i]

我明白了:

着色器日志:0:13:S0004:在非结构和非向量上尝试了成员引用或swizzle

第13行:
tc+=texture2D(uFrameBufferTexture,vtexturecord[0].xy+vec2(0.0,偏移量[i])/uScreenHeight.rgb*权重[i]

(i=0到2)

所以我的问题是:如何将浮点数组绕过到统一数组?浮动[3]

代码

protected static final String mFShader = 
        "precision mediump float;\n" +
        "varying vec2 vTextureCoord;\n" +
        "uniform float uTime;\n" +
        "uniform float uScreenWidth;\n" +
        "uniform float uScreenHeight;\n" +
        "uniform sampler2D uFrameBufferTexture;\n"+

        "uniform float offset[3];\n" +
        "uniform float weight[3];\n" +

        "void main() {\n"+
        "  vec3 tc = vec3(1.0, 0.0, 0.0);\n"+
        "  if (vTextureCoord[0].x<(uTime-0.01)) {\n"+
        "    tc = texture2D(uFrameBufferTexture, vTextureCoord[0].xy).rgb * weight[0];\n"+
        "    for (int i=1; i<3; i++) {\n"+
        "      tc += texture2D(uFrameBufferTexture, vTextureCoord[0].xy + vec2(0.0, offset[i])/uScreenHeight).rgb * weight[i];\n"+
        "      tc += texture2D(uFrameBufferTexture, vTextureCoord[0].xy - vec2(0.0, offset[i])/uScreenHeight).rgb * weight[i];\n"+
        "    }\n"+
        "  }\n"+
        "  else if (vTextureCoord[0].x>=(uTime+0.01)) {\n"+
        "    tc = texture2D(uFrameBufferTexture, vTextureCoord[0].xy).rgb;\n"+
        "  }\n"+
        "   gl_FragColor = vec4(tc, 1.0);\n"+
        "}\n";
protected static final String mFShader=
“精度中间泵浮动;\n”+
“可变vec2 vTextureCoord;\n”+
“统一浮点uTime;\n”+
“均匀浮动宽度;\n”+
“均匀浮动高度;\n”+
“统一采样器2D uFrameBufferTexture;\n”+
“均匀浮点偏移量[3];\n”+
“均匀浮动重量[3];\n”+
“void main(){\n”+
vec3 tc=vec3(1.0,0.0,0.0);\n+

“如果(vTextureCoord[0].x问题实际上不在于
权重
偏移量
。编译器抱怨您说
vTextureCoord[0].xy
,但您声明
vTextureCoord
变量vec2 vTextureCoord;
。”


要么将
vtexturecord
声明为数组,要么不说
[0]
问题实际上不在于
weight
offset
。编译器抱怨您说
vtexturecord[0].xy
,但您声明
vtexturecord
变量vec2 vtexturecord;


vTextureCoord
声明为数组,或者不说
[0]
您不需要将其声明为数组,但如果需要,您可以使用:

varying vec4 vTextureCoord[3]; // you can use anything you want between the brackets

另外,也不要忘记修改顶点着色器的变量,使它们相同。

您不需要将其声明为数组,但如果需要,可以简单地使用:

varying vec4 vTextureCoord[3]; // you can use anything you want between the brackets

另外,不要忘了修改顶点着色器,使它们相同。

我们能看到实际导致错误的线条吗?tc+=texture2D(uFrameBufferTexture,vTextureCoord[0]。xy+vec2(0.0,偏移量[i])/USScreenHeight)。rgb*权重[i];我们能看到实际导致错误的线条吗?tc+=texture2D(uFrameBufferTexture,vTextureCoord[0].xy+vec2(0.0,偏移量[i])/uScreenHeight.rgb*权重[i];
可变vec2 vTextureCoord[1];
(或任何您需要的,而不是1)
可变vec2 vTextureCoord[1];
(或任何您需要的,而不是1)