A discrete global grid is an approximately spherical grid formed by repeated refinement of a dodecahedron. Level 0 is just 12 cells, all pentagons. Level 5 is 10298 cells (30722 vertices), all but 12 being hexagonal. Level 6 has 40962 cells (122880 vertices).
The display geometry for a grid of a given level is fixed and what I want to vary is how the individual cells are ‘filled’. Rendering a grid with all cells having a fixed colour efficiently is easy, using triangle fans and primitive restart I have done it with a single draw elements call. Rendering each cell separately is simple but too slow. If in the geometry shader I can know which ‘segment’ of which cell is being rendered then it seems that it should be possible to draw many cells with one draw elements call (limited by the limits on uniform block size).
I have tried to do this by assuming that the primitive ID increments in the same order that the triangles occur in the element index array, and passing cell colour indicies via an array in a uniform block. Calculating the cell number is easy and I can use it to lookup a colour index which is then used to lookup the actual colour for the cell. If I change what the grid is displaying, then all that’s needed is to update the uniform buffer backing the uniform block.
Does this assumption hold? If not, is there any other way of working out in the geometry shader which cell the current triangle is part of?
I’m using Gl 3.2 core with GLSL 1.5 core under Ubuntu 10.4 with a GeForce 9800GT using the 195.36.15 driver. I don’t mind moving to 3.3 or using extensions, but I’d like to avoid ones which aren’t likely to move into the core in the near-ish future.
Any suggestions on better/other ways to achieve my goal appreciated.