Skip to content

Commit

Permalink
[gldemo] add support for vertex absolute positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorbin committed Oct 12, 2023
1 parent 1ece8d9 commit bab57d7
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions gltiles.vert
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ uniform LayerParams {
// pixel size of each tile in this layer
float tileSize;

// Implicit positioning system, where tiles are laid out as a dense grid
// indexed by gl_VertexID in row-major order starting at layer origin
// (defined by transform) and progressing in stride-siied rows of tiles.
// Implicit positioning mode is enabled if stride > 0, where tiles are laid
// out as a dense grid indexed by gl_VertexID in row-major order starting at
// layer origin (defined by transform) and progressing in stride-sized rows.
// Any offset attribute value is added to this value.
//
// Otherwise absolute positioning is used, relying on offset to position each
// tile (still relative to transform origin of course).
int stride;
};

Expand Down Expand Up @@ -54,10 +57,13 @@ void main(void) {
return;
}

vec2 loc = vec2(
float(gl_VertexID % stride),
float(gl_VertexID / stride)
);
vec2 loc;
if (stride > 0) {
loc = vec2(
float(gl_VertexID % stride),
float(gl_VertexID / stride)
);
}
loc += 0.5;
loc += offset;

Expand Down

0 comments on commit bab57d7

Please sign in to comment.