Here is a fixed version that has correct depth output and writes some other values that the pixel shader might need. you could think of adding tangents, if you want to use normal maps.
it also outputs one strip, and not individual triangles, which reduces the vertex output count.
That is important for the shader output limit, it is 1024 32-bit values. so the amount of vertices you can emit is 1024/vertexstride. That can vary, depending on what the pixel shader needs. you can set all stream values in the geometry shader and depending on the material features, your max count will be limited as the output datatype will be dynamically compiled.
Have you considered using geometry shader instancing? Assuming you are using D3D11 hardware, you can simply execute multiple copies of the geometry shader for each primitive. Then you can process one half of your data in one instance and the other half in the second instance - you would then just need to use the SV_GSInstanceID system value semantic in the shader to select the proper subset of data to produce. You can have up to 32 instances created for each primitive, so you could effectively up the limit to 1024*32.
you can add an [instance(N)] attribute, where N is a number between 1 and 32. And then use SV_GSInstanceID to emit more vertices. But not 100% sure if the SDSL parser knows about that. I’ve never tried it.
Looks great, they only seem to be missing setting the depth value, I’d recommend using the AppendVertex() method for them as well to be sure that all vertex shader variables are set…
error X8000: Validation Error: Declared output vertex count (64) multiplied by the total number of declared scalar components of out
put data (18) equals 1152. This value cannot be greater than 1024.
You can decrease the maxvertexcount inside the shader to 56 and it should “work” idk what side effects it causes though.
what is missing in the shader to make the mesh entity transform work?
i see the one part that is commented:
// override the vertex shader methods that handle position
but no idea what to do with it.
I found a shader from a project that reduces the vertex count a lot by emitting a triangle strip, effectively only creating each vertex position only once, except at the start/end of the angle. This allows to have almost double the resolution.
I’ll need to find it and remove some unrelated code in it…
also noticed these twists when the angles change in certain directions between the segments. seems something with the tangent, bitangent calculations turning negative or something but i am totally lost on this.
Its really the changing up vector and it seems there is no way to compute a continuous twist free up vector in a bare gs shader because you cant store any data between computations of segments:(
Using the texturecoordinate shader, I experience some weird behavior et the ends of the lines. Texurecoordinartes seems fine, except at the ends.
Very visible with low particles count.