On a web app with threeJs I have a float32array that I pass to my vertex shader as a bufferAttribute named "state" of my Geometry. How can I get the nth bit of each float in the vertex shader ? I need something like :
vertexShader: `
attribute float state;
varying float active;
void main() {
active = getnthbit(state, 4); // get the fourth bit of the float value of state
...
}`,...
I checked the answer of Tommy here : https://stackoverflow.com/a/41946046/3548345 Using this formulat
float bit = step(0.5, mod(float(value) / 8.0, 1.0));
to get the third bit, but it doesn't work and I don't get it.