opengl es - How to discriminate between vertices 1,2, and 3 inside a GLES Vertex Shader that is drawing triangle(s) -
is there way tell, within gl es vertex shader (that drawing triangles) of 3 vertices being processed?
using gl_vertexid doesn't work me, because gives index of vertex in list of vertices, use indices specify different order draw vertices, , value want cannot determined gl_vertexid alone.
you can add vertex attribute represent indices 0, 1, 2, @matic-oblak noted may have replicate vertices shared between triangles. if mesh "three-colorable" (in graph theory sense) can assign indices without replication.
a tetrahedron not 3-colorable, whereas cube 2-colorable, , can triangulate faces of cube , 3-colorable mesh. ordinary vertices have degree 6 in triangular mesh , "locally" 3-colorable.

therefore can 3-color mesh as possible -- fails have replicate vertices. unfortunately 3-coloring np-complete problem , simple heuristics think can reasonable job.
Comments
Post a Comment