Calculate using vertex standards in shader geometry after tessellation

I managed to get the control and evaluation of tessellation to be properly managed, but the lighting for my scene is still blocky because I was counting on the face normal (triangle) and not on the top. Now, when I use tesselation, it seems necessary to calculate the new normal vertices for the new tessellated vertices, either in tess eval or in the geometric shader.

To get smoothness along the normals of the vertices, I need to calculate on the normals of each face for each triangle dividing the vertex in question, and then calculate the weighted average of these face normals. But I'm not sure how to get all these triangular faces in a tess eval or geometrized shader. The layout (triangles_adjacency) in option for the geometric shader looks promising, but there is not much information on how to use it.

Is it possible to calculate smooth by vertex normals on a GPU without using a normal / bump map in this way? The ultimate goal is to have smooth lighting on top, which increases the level of detail of tessellation.

Here are my control and evaluation shaders:

 // control #version 400 layout (vertices = 3) out; in vec3 vPosition[]; out vec3 tcPosition[]; const float tessLevelInner = 1.0; const float tessLevelOuter = 1.0; void main() { tcPosition[gl_InvocationID] = vPosition[gl_InvocationID]; if (gl_InvocationID == 0) { gl_TessLevelInner[0] = tessLevelInner; gl_TessLevelOuter[0] = tessLevelOuter; gl_TessLevelOuter[1] = tessLevelOuter; gl_TessLevelOuter[2] = tessLevelOuter; } } // eval #version 400 layout (triangles, equal_spacing, cw) in; uniform mat4 uProj; uniform mat4 uModelView; in vec3 tcPosition[]; out vec3 tePosition; void main() { vec3 p0 = gl_TessCoord.x * tcPosition[0]; vec3 p1 = gl_TessCoord.y * tcPosition[1]; vec3 p2 = gl_TessCoord.z * tcPosition[2]; tePosition = p0 + p1 + p2; gl_Position = uProj * uModelView * vec4(tePosition, 1); } 
+4
source share

All Articles