2
\$\begingroup\$

I'm in directx 11 with the geometry shader.

Is is possible to calculate vertex normals? Just one like segment per vertex? In the geometry shader?

I did vertex normals per face, this is what I got, enter image description here

My exercise in the book wants something like enter image description here

\$\endgroup\$
1
\$\begingroup\$

Computing vertex normals is a complex process as you need to have all incident faces available, and the ability to "split verts" when needed. This is not really something well suited to the Geometry Shader. Face normals do fit well with Geometry Shader because you only care about the primitive itself.

Is there some reason you have to do this on the GPU?

The DirectXMesh library implements a number of different vertex normal calculations, but works on the CPU. In particular, see ComputeNormals. Typically all your geometry data is conditioned at build time to include needed things like vertex normals, tangents or bi-tangents (if needed).

Here are some references as well:

  • S Jin, R R Lewis, and D West; "A comparison of algorithms for vertex normal computation". link
  • Nelson Max, "Weights for Computing Vertex Normals from Facet Normals" link
  • Max Wagner, "Generating Vertex Normals" link
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I'd also add that vertex normals tend to stay the same, and as such, computing them at a shader level also wastes computational time. \$\endgroup\$ – JonBee Mar 14 '16 at 14:50

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.