I have a basic shader which just renders a fragment based on a sampled vertex attribute color. However, the shading comes out as blocky/flat even with gl_Smooth turned on. I understand gourad and phong when it pertains to an eye position and a light, but I am trying to get smooth diffuse shading with only 'ambient light'; rather, the light values come in as part of the color as sampled with real world camera data. My world is constructed via rgbd input and creates very polygonized meshes (marching cubes) with sampled colors. My question is regarding the method of how to smooth out the shading per fragment when there is no direct light direction? I have my shader setup such that Colors, Position, and Normals are vertex attributes.
My current shaders:
vert:
#version 330
uniform mat4 ProjectionModelView;
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Color;
layout(location = 1) in vec3 Normal;
out vec3 VertexPosition;
out vec3 VertexColor;
out vec3 VertexNormal;
void main(void)
{
VertexColor = Color;
VertexPosition = Position;
VertexNormal = Normal;
gl_Position = ProjectionModelView*vec4(Position, 1.0);
}
fragment
#version 330
in vec3 VertexPosition;
in vec3 VertexColor;
in vec3 VertexNormal;
out vec4 FinalColor;
void main(void)
{
float intensity = dot(VertexPosition, VertexNormal);
FinalColor = vec4(VertexColor.x, VertexColor.y, VertexColor.z, 1)*intensity;
}
And for reference, the wireframe which is pretty high triangle count:
With normals rendered:
And with just rendering the per vertex color without modifications: