opengles实现卡通效果

			const char* vs =
{
"attribute vec3 inVertex;"
"attribute vec3 inNormal;"//法线

"uniform mat4 MVPMatrix;"
"uniform vec3 LightDirection;"//光的方向
"uniform vec3 EyePosition;"

"varying vec2 TexCoord;"

"void main()"
"{"
"gl_Position=MVPMatrix*vec4(inVertex,1.0);"
"vec3 eyeDirection=normalize(EyePosition-inVertex);"

"TexCoord.x=dot(LightDirection,inNormal);"//dot(x, y): 点积，各分量分别相乘 后 相加
"TexCoord.y=dot(eyeDirection,inNormal);"
"}"
};

const char* ps =
{
"precision lowp float;"
"uniform sampler2D sTexture;"

"varying vec2 TexCoord;"
"const vec3 cBaseColor=vec3(1,1,1);"
"void main()"
"{"

"gl_FragColor=vec4(cBaseColor*texture2D(sTexture, TexCoord).rgb,1.0);"

"}"
};

        virtual void    onRender(Program_CELL& shader,CELL3RDCamera& camera)
{
static float angle = 0;

matrix4 matRot(1);
matRot.rotateY(angle);

matrix4 matTrans;
matTrans.translate(0,5,0);

matrix4 matScale(1);
matScale.scale(0.3f,0.3f,0.3f);

//总的模型变换矩阵
matrix4 matModel = matTrans*matRot*matScale;

angle += 1.0f;

//观察点坐标  也就是眼睛的位置
float4 vMsEyePos = float4(0, 0, 125, 1)*matModel;

//从世界空间转换方向光到模型空间
float4 vMsLightDir = float4(1, 2, 1, 0)*matModel;//光的入射方向
//归一化
float3 vMsLightDirS = normalize(float3(vMsLightDir.x,vMsLightDir.y,vMsLightDir.z));

//光源位置
float4 vMsLightPos = float4(50,20,40,1);
vMsLightPos = vMsLightPos*matModel;
matrix4 MVP = camera._matProj*camera._matView*matModel;

}