Hello all, I have a simple model with a lot of triangles. To reduce bandwidth, I'd li= ke to use a VBO with the unique vertex coordinates, and have the vertex sha= der generate the UV values (they're always {0, 1} {0, 0}, {1, 0} for each t= riangle) for the fragment shader. Is this possible? I don't think my current setup allows for any other shad= er stages... Thanks!

0 |

9/24/2015 1:11:51 AM

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.

0 |

9/27/2015 1:01:01 AM

On Sunday, September 27, 2015 at 6:55:03 PM UTC-5, Nobody wrote: > 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. Thanks. I think I will go with sending an extra byte per vertex.

0 |

10/2/2015 2:03:46 AM