I was very surprised when I ran my tessellation evaluation shader, which only counts the number of vertices through an atomicAdd command.
for the following tessellation levels:
gl_TessLevelOuter[0] = 10;
gl_TessLevelOuter[1] = 10;
gl_TessLevelOuter[2] = 10;
gl_TessLevelInner[0] = 10;
As we can see (Figure 1), there are only 91 vertices.... but the atomic counter tells me that there are 141 vertices.
Figure 1: generated vertices in the TES stage.
all inner and outer TessLevels were set to value 10
.
So I used my TES vertex enumeration algorithm to store the variable gl_TessCoord
in SSBO along with a uint incremented by the function atomicAdd
. I saved the result in an obj file and added a comment telling us how often this vertex is generated.
v 0.0666656 0.866653 0.0666809 #2
v 0.0666656 0.766647 0.166687 #3
v 0.0666656 0.666641 0.266693 #2
v 0.0666656 0.566635 0.366699 #2
v 0.0666656 0.46666 0.466675 #2
v 0.0666656 0.366684 0.56665 #2
v 0.0666656 0.266678 0.666656 #2
v 0.0666656 0.166672 0.766663 #2
v 0.133347 0.733307 0.133347 #2
v 0.133347 0.633301 0.233353 #1
v 0.133347 0.533295 0.333359 #1
v 0.133347 0.433319 0.433334 #1
v 0.133347 0.333344 0.53331 #1
v 0.133347 0.233337 0.633316 #1
v 0.200012 0.599976 0.200012 #1
v 0.200012 0.499969 0.300018 #1
v 0.200012 0.399994 0.399994 #1
v 0.200012 0.300018 0.499969 #1
v 0.266678 0.466629 0.266693 #2
v 0.266678 0.366653 0.366669 #2
v 0.0666656 0.0666656 0.866669 #3
v 0.166672 0.0666656 0.766663 #2
v 0.266678 0.0666656 0.666656 #2
v 0.366684 0.0666656 0.56665 #3
v 0.46666 0.0666656 0.466675 #3
v 0.566635 0.0666656 0.366699 #2
v 0.666641 0.0666656 0.266693 #2
v 0.766647 0.0666656 0.166687 #2
v 0.133331 0.133347 0.733322 #1
v 0.233337 0.133347 0.633316 #1
v 0.333344 0.133347 0.53331 #2
v 0.433319 0.133347 0.433334 #2
v 0.533295 0.133347 0.333359 #1
v 0.633301 0.133347 0.233353 #1
v 0.200012 0.200012 0.599976 #1
v 0.300018 0.200012 0.499969 #2
v 0.399994 0.200012 0.399994 #2
v 0.499969 0.200012 0.300018 #1
v 0.266678 0.266678 0.466644 #2
v 0.366653 0.266678 0.366669 #2
v 0.866653 0.0666809 0.0666656 #2
v 0.766647 0.166687 0.0666656 #2
v 0.666641 0.266693 0.0666656 #2
v 0.566635 0.366699 0.0666656 #3
v 0.46666 0.466675 0.0666656 #3
v 0.366684 0.56665 0.0666656 #2
v 0.266678 0.666656 0.0666656 #2
v 0.166672 0.766663 0.0666656 #2
v 0.733307 0.133347 0.133347 #1
v 0.633301 0.233353 0.133347 #1
v 0.533295 0.333359 0.133347 #1
v 0.433319 0.433334 0.133347 #3
v 0.333344 0.53331 0.133347 #3
v 0.233337 0.633316 0.133347 #2
v 0.599976 0.200012 0.200012 #1
v 0.499969 0.300018 0.200012 #1
v 0.399994 0.399994 0.200012 #2
v 0.300018 0.499969 0.200012 #2
v 0.466629 0.266693 0.266678 #1
v 0.366653 0.366669 0.266678 #2
v 0.333328 0.333328 0.333344 #2
v 0 1 0 #1
v 0 0.899994 0.100006 #1
v 0 0.799988 0.200012 #1
v 0 0.699982 0.300018 #1
v 0 0.599976 0.400024 #1
v 0 0.5 0.5 #1
v 0 0.400024 0.599976 #1
v 0 0.300018 0.699982 #1
v 0 0.200012 0.799988 #1
v 0 0.100006 0.899994 #1
v 0 0 1 #2
v 0.100006 0 0.899994 #1
v 0.200012 0 0.799988 #1
v 0.300018 0 0.699982 #1
v 0.400024 0 0.599976 #1
v 0.5 0 0.5 #1
v 0.599976 0 0.400024 #1
v 0.699982 0 0.300018 #1
v 0.799988 0 0.200012 #1
v 0.899994 0 0.100006 #1
v 1 0 0 #1
v 0.899994 0.100006 0 #1
v 0.799988 0.200012 0 #1
v 0.699982 0.300018 0 #2
v 0.599976 0.400024 0 #1
v 0.5 0.5 0 #1
v 0.400024 0.599976 0 #1
v 0.300018 0.699982 0 #1
v 0.200012 0.799988 0 #1
v 0.100006 0.899994 0 #1
As you can see, some vertices are created up to three times. Is there an option in OpenGL or GLSL to disable the creation of these duplicates?