opengl - GLSL tessellation control shader indexing gl_TessLevelOuter with gl_InvocationID -
opengl - GLSL tessellation control shader indexing gl_TessLevelOuter with gl_InvocationID -
why next tessellation command shader makes triangles disappear?
#version 410 layout(vertices = 3) out; void main(void) { gl_tesslevelinner[0]=1; gl_tesslevelouter[gl_invocationid]=gl_invocationid+1; gl_tesslevelouter[gl_invocationid]=gl_invocationid+1; gl_tesslevelouter[gl_invocationid]=gl_invocationid+1; }
i input triangles. when index gl_tesslevelouter 0,1 , 2, works fine. seems me build saves me if statement, believe helps in parallel execution of shader. of course, omitted vertex calculations in snippet.
triangles disappear because incurred in "undefined" behaviour, that's it. inner tesellation level should @ to the lowest degree 2.
gl_tesslevelinner[0] = 2;
the weird results obtain because of how baricentric coordinates computed when inner level 1. given provide @ to the lowest degree 2 value, can utilize value want outerlevels.
the next border association triangle
out0 => border 1-2 out1 => border 2-3 out2 => border 3-1
out[0] = 4 out[1] = 1 out[2] = 2
as see, inner
of 2, cutted triangle twice along triangle's bisectors, while 3 different outer
levels cutted triangle along edges (no cuts 1
, twice 2
, 4 pieces when value 4
)
tips:
also there little advices, info in tessellation command shared, that's means called multiple times, need set tessellation command once:
if(gl_invocationid==0){ gl_tesslevelinner[0] = 2; //take triangle gl_tesslevelouter[0] = 1; //and subdivde in 3 triangles gl_tesslevelouter[1] = 1; gl_tesslevelouter[2] = 1; } gl_out[gl_invocationid].gl_position = gl_in[gl_invocationid].gl_position;
so why still possible set different values each invocation? that's add together subdivisions based on screen error (at to the lowest degree reasonable use).
if(gl_invocationid==0){ gl_tesslevelinner[0] = 2; //take triangle gl_tesslevelouter[0] = lenghtonscreen<5? 3: 4; } if(gl_invocationid==1) gl_tesslevelouter[1] = lenghtonscreen<5? 3: 4; if(gl_invocationid==2) gl_tesslevelouter[2] = lenghtonscreen<5? 3: 4; gl_out[gl_invocationid].gl_position = gl_in[gl_invocationid].gl_position;
in end:
another illustration inner=3
, outer=2
.
note 3 cuts along bisector , 2 cuts along edges, other cuts "seamless transition"
opengl glsl tessellation
Comments
Post a Comment