I would like use flat shading with vbo. I wish that each face has the same color as with the old glShadeModel(GL_FLAT).
Someone have some piece of shader to do it?
I tried this fragment shader but doesn't work correctly... I saw some sort of color interpolation on the faces.
I tried to use it:
bool resultVertex=p.attachVertexShader(STRINGIFY(
varying vec3 ec_pos;
void main()
{
ec_pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
gl_Position = ftransform();
}
));
bool resultFragment=p.attachFragmentShader(STRINGIFY(
varying vec3 ec_pos;
void main()
{
vec3 ec_normal = normalize(cross(dFdx(ec_pos), dFdy(ec_pos)));
vec3 light_dir=vec3(0.0,0.85,0.85);
float d=dot(light_dir,ec_normal);
gl_FragColor = vec4(d,d,d,0);
}));
Thanks.