Currently I'm subdividing an icosahedron once by using the following Geometry Shader:
[maxvertexcount(8)]
void gs(triangle VS_OUT gin[3], inout TriangleStream<GS_OUT> s)
{
// p1
// / \
// / \
// m0 --- m1
// / \ / \
// / \ / \
// p0 -- m2 -- p2
float3 m0 = .5f * (gin[0].pos_l + gin[1].pos_l),
m1 = .5f * (gin[2].pos_l + gin[1].pos_l),
m2 = .5f * (gin[0].pos_l + gin[2].pos_l);
float3 v[6];
v[0] = gin[0].pos_l;
v[1] = m0;
v[2] = m2;
v[3] = m1;
v[4] = gin[2].pos_l;
v[5] = gin[1].pos_l;
GS_OUT gout;
for (int i = 0; i < 5; ++i)
{
gout.pos_h = mul(float4(v[i], 1.f), g_mat_wvp);
s.Append(gout);
}
s.RestartStrip();
gout.pos_h = mul(float4(v[1], 1.f), g_mat_wvp);
s.Append(gout);
gout.pos_h = mul(float4(v[5], 1.f), g_mat_wvp);
s.Append(gout);
gout.pos_h = mul(float4(v[3], 1.f), g_mat_wvp);
s.Append(gout);
}
However, I want to specify the subdivision level. Is there any possibility to call the Shader again with the outputed verticies or do I need to follow an other approach?