Can I calculate the normals in gpu?

I have an opengl application that loads dxf and draws it on the screen, every time I need to calculate the normals. is there any way to calculate normals in GPU instead of CPU? if so, how?

+5
source share
4 answers

Yes it is possible. You will want to know about shaders in Cg .

Official book .

+2
source

( ) . , " ", -. "" , GS .

(, ), . GPU.

, - .

IF GPU CUDA, OpenCL - , , , , , .

, , 5 ( ) " GPU" " GPU". . , , , ( ). ( ) GDC, SIGGRAPH, ATI SDK NVidia SDK.

+4

.

GLSL. GLSL . , .

  • , ! , , .
  • Cut and paste any tutorial to include a geometric shader in your application.
  • The shader should look like this:
//glsl shader

#version 120
#extension GL_EXT_geometry_shader4 : enable
void main(void)
{
// Compute per-face normal
    vec4 d1 = gl_PositionIn[1] - gl_PositionIn[0];
    vec4 d2 = gl_PositionIn[2] - gl_PositionIn[0];
    gl_Normal = cross(d1,d2);

// Emit all input vertices
    for(i=0; i< gl_VerticesIn; i++){
        gl_Position = gl_PositionIn[i];
        EmitVertex();
    }
    EndPrimitive();
}   
+4
source

Take a look glEnable(GL_AUTO_NORMAL).

+1
source

All Articles