PDA

View Full Version : Regarding per-vtx normal in geometry shader

mobeen
01-16-2012, 06:15 AM
Hi all,
I have successfully calculated the per-triangle normal and it looks pretty bad. Now I am looking on how to calculate per-vtx normals in the geometry shader. Is it even possible? If so how do i get the adjacency in the geometry shader when my vertex shader only has vertex positions and as far as I know the geometry shader has only info of the current triangle. Does anyone know of a method to get per-vertex normals in geometry shader, any link, reference, tutorial is highly appreciated.

tksuoran
01-16-2012, 07:43 AM
Some background would be useful here. Why do you need to compute per vertex normals in the geometry shader? Are you displacing your vertices somehow - how?

mobeen
01-16-2012, 09:14 PM
I am doing a basic cloth simulation on GPU. On CPU, after each iteration I can iterate over all the triangles and average the normal to get the per-vertex normal. Now I want to do it on the GPU otherwise I would have to transfer vertex postions to CPU to get the new normals. Therefore, I thought I would ask here if there is a way I could get the per-vertex normals in the geometry shader so that I donot have to transfer data to CPU.

Aleksandar
01-17-2012, 04:16 AM
Of course that you can do it on the GPU. Just use adjacency to generate index for a vertex buffer produced by the transform feedback (TF). I guess that you are using GL_POINTS primitive for TF. Otherwise, you'll have to increase number of vertices in the first pass.

mobeen
01-17-2012, 04:27 AM
Thanks for the response Aleksandar.

Just use adjacency to generate index for a vertex buffer produced by the transform feedback (TF). I guess that you are using GL_POINTS primitive for TF.
Yeah I am using points for TF. How do i use adjacency how do u define it? I have not used adjacency before can u suggest a good reference for this?

Aleksandar
01-17-2012, 07:11 AM
How do i use adjacency how do u define it?

References: