0
\$\begingroup\$

I'm subdividing a sphere so when distance gets greater, the sphere is subdivided less to save memory.

The sphere changes to another sphere when the distance is 10. My problem is that only one triangle gets rendered at a time in the geometry shader. This makes the rest of the sphere the different and causes holes and cracks. like the image below

enter image description here

How can I render all the triangles at one time?

my geometry function code is

 [maxvertexcount(50)]
void GS(triangle VertexOut gin[3], inout TriangleStream<GeoOut> stream)
{   


if(distance(gin[0]) < 10.0f)
{
VertexOut v[15];
Subdivide2(gin, v);
OutputSubdivision2(v,stream);

}
else if(distance(gin[0]) >= 10)
{
VertexOut v[6];
Subdivide(gin, v);
OutputSubdivision(v,stream);

}
}
\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

There are different ways to do this.

1. Tessellation

Do this with tessellation. That is exactly what tessellation was created for. You have to read a bit about it, but when you got it, thinks are going much easier.

2. Structured Buffer

Instead of using the normal pipeline, you can bind the triangle mesh (vertices) as a structured buffer. Then you can draw one vertex with Setting the Vertex buffer of IA Stage to NULL. Just render 1 vertex, using SV_VERTEXID. In the Geometry Shader you can access the structured buffer like an texture. Just sample everything you need

3. Point Primitive

Why not just render the center of sphere as a single point. Create the whole mesh with a bit of math completly in the Geometry Shader. Performance is not optimal for so many created vertices in the GS, but it does the job. You can read the distance to the camera once, and then create vertices around that center with the radius you want. be carefull with connecting the triangles. Maybe some drawing will help.

Hope the answer gives you some inspiration^^

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .