Note that there are some explanatory texts on larger screens.

plurals
  1. POGLSL bypassing float array to uniform
    primarykey
    data
    text
    <p>setShaders</p> <pre><code> muOffsetHandle = getUniformLocation("offset"); muWeightHandle = getUniformLocation("weight"); </code></pre> <p>useProgram</p> <pre><code> GLES20.glUniform1fv(muOffsetHandle, 1, mOffset, 0); GLES20.glUniform1fv(muWeightHandle, 1, mWeight, 0); </code></pre> <p>vars</p> <pre><code>private int muOffsetHandle; private int muWeightHandle; protected float mOffset[] =new float[] {0.0f, 1.3f, 3.3f}; protected float mWeight[] =new float[] {0.2f, 0.3f, 0.3f}; </code></pre> <p>FragmentShader</p> <pre><code> "uniform float offset[3];\n" + "uniform float weight[3];\n" + </code></pre> <p>then trying to reach: weight[i]</p> <p>I get this:</p> <p>Shader log: 0:13: S0004: Member reference or swizzle attempted on non-structure and non-vector</p> <p>line 13: <code>tc += texture2D(uFrameBufferTexture, vTextureCoord[0].xy + vec2(0.0, offset[i])/uScreenHeight).rgb * weight[i];</code> </p> <p>(i = 0 to 2)</p> <p>so my question: How to bypassing a float array to a uniform? float[3]</p> <p>the code</p> <pre><code>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&lt;(uTime-0.01)) {\n"+ " tc = texture2D(uFrameBufferTexture, vTextureCoord[0].xy).rgb * weight[0];\n"+ " for (int i=1; i&lt;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&gt;=(uTime+0.01)) {\n"+ " tc = texture2D(uFrameBufferTexture, vTextureCoord[0].xy).rgb;\n"+ " }\n"+ " gl_FragColor = vec4(tc, 1.0);\n"+ "}\n"; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload