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.
|
|
#ifdef GL_ES precision mediump float; #endif; attribute vec4 position; attribute vec4 texcoord; attribute vec4 normal; uniform mat4 ModelMatrix; uniform mat4 ViewMatrix; uniform mat4 ProjectionMatrix; uniform mat4 IT_ModelMatrix; uniform vec4 U_AmbientMaterial; uniform vec4 U_AmbientLight; uniform vec4 U_LightPos; uniform vec4 U_DiffuseMaterial; uniform vec4 U_DiffuseLight; uniform vec4 U_CameraPos; uniform vec4 U_SpecularMaterial; uniform vec4 U_SpecualrLight; varying vec4 V_Color; void main(){ //ambient vec4 ambientColor = U_AmbientMaterial*U_AmbientLight;
//diffuse vec3 L = normalize(U_LightPos.xyz - vec3(0)); vec3 n = normalize((IT_ModelMatrix * normal).xyz); float diffuseIntensity = max(0.0, dot(L,n)); vec4 diffuseColor = U_DiffuseMaterial * U_DiffuseLight * diffuseIntensity;
//spacular vec4 specularColor = vec4(0.0, 0.0, 0.0, 0.0); if(diffuseIntensity > 0) { vec3 L = normalize(U_LightPos.xyz - vec3(0)); //�������� vec3 worldPos = (ModelMatrix * position).xyz; vec3 vd = normalize(U_CameraPos.xyz - worldPos); vec3 halfVector = normalize(L+vd); float specularIntensity = pow(max(0.0, dot(halfVector, n)),4.0); specularColor = U_SpecularMaterial * U_SpecualrLight * specularIntensity; }
V_Color = ambientColor + diffuseColor + specularColor;
gl_Position = ProjectionMatrix * ViewMatrix * ModelMatrix * position; }
|