Im currently writing my own GLSL shaders, and wanted to have smooth shading. The shading worked when i calculated the normals bevore sending them to a VBO, but the problem here is when I implement animations with bone matricies, the normals are not corect.
I am using a geometry shader to calculate the normals, but i cant find out how to smooth them.
Here is my geometry shader:
#version 150
layout(triangles) in;
layout (triangle_strip, max_vertices=3) out;
in vec2 texCoord0[3];
in vec3 worldPos0[3];
out vec2 texCoord1;
out vec3 normal1;
out vec3 worldPos1;
void main()
{
vec3 n = cross(worldPos0[1].xyz-worldPos0[0].xyz, worldPos0[2].xyz-worldPos0[0].xyz);
for(int i = 0; i < gl_in.length(); i++)
{
gl_Position = gl_in[i].gl_Position;
texCoord1 = texCoord0;
normal1 = n;
worldPos1 = worldPos0;
EmitVertex();
}
}
I need the faces next to the face that I calculate the normals for, but i dont know how to get them.