0
\$\begingroup\$

Before all, sorry for my poor english !

With DirectX 11, i'm trying to create a random map full with GPU.

Using Hull shader stage, I'm managing LOD with tessellation.

Using Domain shader stage, I'm generating the map (based on perlin noise).

Now my goal, is to compute normals in the geometry shader (normal on vertex). For that, I must use vertex adjency, like geometry is capable of.

But here is the problem... For tessellation, my primitives must be D3D11_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST.

But for geometry shader with 6 vertex (triangle primitive and adjency), I must use : D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ.

Think I'm missing something... It must be possible to tessellate and use the results in the geometry shader... However, it's working with 3 points, but I cannot use the 3 others (they are 0.0, 0.0, 0.0)....

Thank you in advance for any help ;)

\$\endgroup\$
0
\$\begingroup\$

You can use the geometry shader together with tessellation, but in DX11 I don't think you can get the tessellator to generate adjacency information. The topology generated by the tessellator is controlled by the outputtopology attribute of the hull shader, and there are no options for it that include adjacency.

It's understandable why this is the case: while the hardware tessellator could presumbly have been designed to generate adjacency information for triangles internal to a patch, it would have no way of knowing what the adjacency should be for triangles on the edge of a patch, as each patch is processed in isolation.

An alternate approach would be to generate normals in the domain shader, using the derivative of the noise function. Another possible approach would be to stream-out the tessellated vertices to a buffer and run a separate pass over them, perhaps using a compute shader, to generate the normals.

\$\endgroup\$
  • \$\begingroup\$ Thank you very much ! (I cannot upvote now for you because I'm new). Do you think the compute shader is fast enough for real time computation ? Or it's better to streamout and compute in the geometry shader with TRIANGLE_ADJ primitives in the second pass ? \$\endgroup\$ – chrisendymion Jul 8 '13 at 5:40
  • \$\begingroup\$ @chrisendymion Streaming out and passing back through the geometry shader with adjacency sounds really difficult, as you'll have to calculate the index buffer for adjacency yourself. I would try using the compute shader to generate the normals. \$\endgroup\$ – Nathan Reed Jul 8 '13 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.