WebGl shader: Arrays in and out of shader and bitwise operations

I am trying to implement sha256 hashing algorithm with GLSL in WebGL and I have 3 questions:

  1. How to send the values of an array from javascript to the fragment shader? Right now I have:


     In program info:  
     	objectPropertieName: gl.getUniformLocation(shaderProgram, 'myArray')
     Attaching array:	
     	gl.uniform1f(programInfo.uniformLocations.objectPropertieName, myArray);
     In the shader:
     	uniform int myArray[64];

    but it doesn’t work.

2.How to do bitwise operations? ( xor, and, not, shiftleft )
3.How to get the values of an array from the fragment shader back to javascript?

For an array, this:

should use:

void uniform1fv(WebGLUniformLocation? location, Float32List v);


Your array contains ints so you should actually be using:

    void uniform1iv(WebGLUniformLocation? location, Int32List v);

GLSL ES 2 (= WebGL 1) doesn’t support bitwise operations or shifts; the operators are defined but reserved. GLSL ES 2 is designed to be supported on GPUs which only provide floating-point arithmetic.

By having the shader render into a texture. Desktop OpenGL has other options (SSBOs, image load/store), but ES 2 shaders don’t have any outputs except the framebuffer.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.