And I would like to know what could be improved
Heres .frag:
Code: Select all
varying vec3 normal;
varying vec3 ec_pos;
void main()
{
vec4 color = vec4(0.3, 0.7, 1.0, 1.0);
vec3 light = vec3( gl_LightSource[0].position );
vec3 lightdir = light - ec_pos;
vec3 reflectVec = normalize(reflect( -lightdir, normal ));
vec3 viewVec = normalize( -ec_pos );
//Diffuse intensity
float diff = max( dot(normalize(lightdir), normalize(normal)), 0.0);
//Specular intensity
float spec = 0.0;
//Specular intensity
if (diff > 0.0)
{
spec = max(dot(reflectVec, viewVec), 0.0);
//The specular highlight only gets smaller when
//raised to some power.
//Leaving it out gives a nice big highlight.
spec = pow(spec,16);
}
diff = diff * 0.8 + spec * 0.4;
//Diffuse intensity
if (diff > 0.90)
diff = 1.5;
else if (diff > 0.7)
diff = 1.2;
else if (diff > 0.5)
diff = 0.9;
else
diff = 0.5;
gl_FragColor = color * diff;
}
Code: Select all
//Interpolates the vertex normal across the texture fragment
varying vec3 normal;
//Interpolate the texel position in eye space.
varying vec3 ec_pos;
void main()
{
normal = gl_NormalMatrix * gl_Normal;
ec_pos = gl_ModelViewMatrix * gl_Vertex;
//Perform fixed transformation for the vertex
gl_Position = ftransform();
}
PS. I'm currently just toying around with shaders.