You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

25 lines
583 B

#ifdef GL_ES
precision mediump float;
#endif
uniform vec4 U_AmbientMaterial;
uniform vec4 U_AmbientLight;
uniform vec4 U_LightPos;
uniform vec4 U_DiffuseMaterial;
uniform vec4 U_DiffuseLight;
varying vec4 V_Normal;
void main()
{
//ambient
vec4 ambirntColor = U_AmbientMaterial*U_AmbientLight;
//diffuse
vec3 L = normalize(U_LightPos.xyz - vec3(0));
vec3 n = normalize(V_Normal.xyz);
float diffuseIntensity = max(0.0, dot(L,n));
vec4 diffuseColor = U_DiffuseMaterial * U_DiffuseLight * diffuseIntensity;
gl_FragColor=ambirntColor + diffuseColor;
}