I have a simple model with a lot of triangles. To reduce bandwidth, I'd
like to use a VBO with the unique vertex coordinates, and have the vertex shader generate the UV values (they're always {0, 1} {0, 0}, {1, 0} for
each triangle) for the fragment shader.
Is this possible? I don't think my current setup allows for any other
shader stages...
On Wed, 23 Sep 2015 18:11:51 -0700, Edward Brekelbaum wrote:
I have a simple model with a lot of triangles. To reduce bandwidth, I'd like to use a VBO with the unique vertex coordinates, and have the vertex shader generate the UV values (they're always {0, 1} {0, 0}, {1, 0} for each triangle) for the fragment shader.
Is this possible? I don't think my current setup allows for any other shader stages...
How does the vertex shader know which vertex should have which UV coordinates?
If you're rendering distinct triangles (rather than strips or fans), you could use gl_VertexID % 3. Otherwise, you need some other way for the
vertex shader to know which of a triangle's vertices it's dealing with.
In the worst case, you can compress the UV coordinates down to one byte
per vertex, i.e. have a an extra attribute whose value is 0, 1 or 2 (or
-1, 0 or 1) which is then expanded to a (u,v) pair.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 376 |
Nodes: | 16 (2 / 14) |
Uptime: | 39:32:36 |
Calls: | 8,039 |
Calls today: | 3 |
Files: | 13,037 |
Messages: | 5,830,443 |