I am trying to implement sha256 hashing algorithm with GLSL in WebGL and I have 3 questions:
How to send the values of an array from javascript to the fragment shader? Right now I have:
Code:
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?
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.