I want to rotate each texture individually in my rendercall. I read this tutorial, and it works as i want it to except that the rotation is applied to all objects(due to the rotation value being uniform).
So i rewrote it to use a buffer but i cant get it to work properly.
Heres my shader:
attribute vec2 a_position;
attribute vec2 a_texture_coord;
attribute vec2 a_rotation;
attribute vec4 a_color;
uniform vec2 u_resolution;
varying highp vec2 v_texture_coord;
varying vec4 v_color;
void main() {
v_color = a_color;
vec2 rotatedPosition = vec2(
a_position.x * a_rotation.y + a_position.y * a_rotation.x,
a_position.y * a_rotation.y - a_position.x * a_rotation.x);
vec2 zeroToOne = rotatedPosition / u_resolution;
vec2 zeroToTwo = zeroToOne * 2.0;
vec2 clipSpace = zeroToTwo - 1.0;
gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);
v_texture_coord = a_texture_coord;
}
and typescript code
this.gl.enableVertexAttribArray(this.rotationAttributeLocation);
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.rotationBuffer);
this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(renderCall.rotation), this.gl.STATIC_DRAW);
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.rotationBuffer);
this.gl.vertexAttribPointer(this.rotationAttributeLocation, 2, this.gl.FLOAT, false, 0, 0);
I get no errors from webgl or from the browser but end up with a blank canvas. Any ideas?