Commit b8823876 authored by Sylvain Thery's avatar Sylvain Thery

flat colorperface modification

parent 8924e290
......@@ -6,7 +6,7 @@ uniform mat4 ModelViewMatrix;
uniform vec3 lightPosition;
uniform vec4 ambient;
VARYING_IN vec3 colorVertex[];
VARYING_IN vec3 colorVertex[3]; // input is triangles -> 3
VARYING_OUT vec4 ColorFS;
void main(void)
......@@ -20,26 +20,37 @@ void main(void)
vec4 newPos = ModelViewMatrix * vec4(center,0.0);
vec3 L = normalize (lightPosition - newPos.xyz);
float lambertTerm = dot(N,L);
#ifdef AVERGAGE_COLOR
int i;
vec3 averageColor=vec3(0.,0.,0.);
for(i=0; i< NBVERTS_IN; i++)
{
for(i=0; i< 3; i++)
averageColor +=colorVertex[i];
}
averageColor /= float(NBVERTS_IN);
averageColor /= 3.0;
ColorFS = ambient;
if(lambertTerm > 0.0)
ColorFS += vec4(averageColor,1.0) * lambertTerm;
for(i=0; i< NBVERTS_IN; i++)
for(i=0; i< 3; i++)
{
vec4 pos = explode * POSITION_IN(i) + (1.0-explode)* vec4(center,1.0);
gl_Position = ModelViewProjectionMatrix * pos;
EmitVertex();
}
EndPrimitive();
#else
int i;
for(i=0; i< 3; i++)
{
vec4 pos = explode * POSITION_IN(i) + (1.0-explode)* vec4(center,1.0);
ColorFS = ambient;
if(lambertTerm > 0.0)
ColorFS += vec4(colorVertex[i],1.0) * lambertTerm;
gl_Position = ModelViewProjectionMatrix * pos;
EmitVertex();
}
EndPrimitive();
#endif
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment