OpenGL newbie here.
So I'm trying to implement sprite batching to draw ~100 sprites per draw call. I've created a VBO that contains texture coordinates, vertex coordinates, color data (for tinting), and a mat4 matrix for transforms.
So far, so good, right? Well, everything is working but the transform portion of my VBO. My theory is that I could push a mat4 with all of the rotation, scaling, flipping, and world location data applied to it, so that it gets multiplied in with viewports (see glsl code below).
#version 130
//Vertex position attribute
in vec2 vertexPos;
//Texture coordinate attribute
in vec2 texCoordIn;
out vec2 texCoord;
// Vertex color
in vec4 textureColorIn;
out vec4 textureColor;
// Matrix transformations for the sprite
in mat4 transformation;
void main()
{
//Process texCoord
texCoord = texCoordIn;
// Process texture color
textureColor = textureColorIn;
//Process vertex
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * vec4( vertexPos.x, vertexPos.y, 0.0, 1.0 ) * transformation;
}
So here's my question, if you were to send transform data to the GPU, how would you do it? Sending a mat4 over the wire per vertex seems like overkill.
(angle, tx, ty, scaleFactor)
to the GPU as avec4
and compute the matrix there... just trying to figure this stuff out myself. This might be useful: paroj.github.io/gltut/Positioning/… \$\endgroup\$