Reputation: 57
My first stab at instancing. I have two attribute buffers that use vertexAttribDivisorANGLE
. I'm placing position and rotation data in one attribute buffer and texture data in another. I'm using a sprite sheet in one texture, so I have to send beginning position and dimensions of each "frame" that I want to draw. The position / rotation buffer appears fine, but on desktop chrome the texture buffer appears to be intermittently corrupted. You'll see flashes of the texture correctly displayed, but you mostly see the entire sprite sheet mapped onto the quad or just random noise. It appears to render perfectly on mobile chrome. The buffers have different divisors if that makes a difference.
I can't seem to find any results when searching for info on corrupted vertex buffers of discrepancies between how mobile and desktop might render.
Here's a live demo: http://industriousthought.com/glLab.html
Upvotes: 0
Views: 76
Reputation: 3619
The problem seems to be that if your vertex shader in drawCircles-vertex-shader
matrix poseM
isn't fully initialised. Here's part of your shader:
mat4 poseM;
poseM[0][0] = 1.0 / a_pose.z;
poseM[1][1] = 1.0 / a_pose.w;
poseM[2][2] = 1.0;
poseM[3][3] = 1.0;
poseM[3][0] = 1.0 / a_pose.z * a_pose.x;
poseM[3][1] = 1.0 / a_pose.w * a_pose.y;
Initialising remaining components of the matrix to zeroes produces what seems to be a reasonable result:
mat4 poseM;
poseM[0][0] = 1.0 / a_pose.z;
poseM[0][1] = 0.0;
poseM[0][2] = 0.0;
poseM[0][3] = 0.0;
poseM[1][0] = 0.0;
poseM[1][1] = 1.0 / a_pose.w;
poseM[1][2] = 0.0;
poseM[1][3] = 0.0;
poseM[2][0] = 0.0;
poseM[2][1] = 0.0;
poseM[2][2] = 1.0;
poseM[2][3] = 0.0;
poseM[3][0] = 1.0 / a_pose.z * a_pose.x;
poseM[3][1] = 1.0 / a_pose.w * a_pose.y;
poseM[3][2] = 0.0;
poseM[3][3] = 1.0;
Shorter version to initialize matrix:
mat4 poseM = mat4(1.); // Initializes matrix to identity
poseM[0][0] = 1.0 / a_pose.z;
poseM[1][1] = 1.0 / a_pose.w;
poseM[3][0] = 1.0 / a_pose.z * a_pose.x;
poseM[3][1] = 1.0 / a_pose.w * a_pose.y;
Upvotes: 1