Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: Regarding per-vtx normal in geometry shader

  1. #1
    Advanced Member Frequent Contributor
    Join Date
    Mar 2009
    Location
    Karachi, Pakistan
    Posts
    810

    Regarding per-vtx normal in geometry shader

    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.
    Regards,
    Mobeen

  2. #2
    Junior Member Regular Contributor tksuoran's Avatar
    Join Date
    Mar 2008
    Location
    Cambridge, UK
    Posts
    223

    Re: Regarding per-vtx normal in geometry shader

    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?

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Mar 2009
    Location
    Karachi, Pakistan
    Posts
    810

    Re: Regarding per-vtx normal in geometry shader

    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.
    Regards,
    Mobeen

  4. #4
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,214

    Re: Regarding per-vtx normal in geometry shader

    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.

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    Mar 2009
    Location
    Karachi, Pakistan
    Posts
    810

    Re: Regarding per-vtx normal in geometry shader

    Thanks for the response Aleksandar.
    Quote Originally Posted by 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?
    Regards,
    Mobeen

  6. #6
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,214

    Re: Regarding per-vtx normal in geometry shader

    Quote Originally Posted by mobeen
    How do i use adjacency how do u define it?
    References:

    ARB_geometry_shader4 Pay attention to figures: Fig.2.X1 - Fig.2.X3

    OpenGL SuperBible 5th Ed, Chapter 11 - Advanced Shader Usage, New Primitive Types Introduced by the Geometry Shader, pg. 438-441

    OpenGL 4.0 Shading Language Cookbook, pg.206-207

  7. #7
    Advanced Member Frequent Contributor
    Join Date
    Mar 2009
    Location
    Karachi, Pakistan
    Posts
    810

    Re: Regarding per-vtx normal in geometry shader

    Thanks Aleksandar, I will have a look at these.
    Regards,
    Mobeen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •