示例#1
0
 public void CalculateBlinnPhongLight(Vect4 light, Vect4 view, float ka, float kd, float ks, float h)
 {
     //Check if face is visible
     if (mr.enabled == true)
     {
         float Ia = ka * 1;
         float Id = kd * normal.DotProduct(normal, light);
         Vect4 H  = view.Addition(light);
         H.Normalize();
         float Is = ks * Mathf.Pow(H.DotProduct(H, normal), h);
         float I  = Ia + Id + Is;
         mr.material.SetColor("_Color", IndexedFace.Instance.materialColor * I);
     }
 }
示例#2
0
 public void CalculatePhongLight(Vect4 light, Vect4 view, float ka, float kd, float ks, float h)
 {
     //Check if face is visible
     if (mr.enabled == true)
     {
         float Ia = ka * 1;
         float Id = kd * normal.DotProduct(normal, light);
         //calculate Reflection vector
         //dot product of Light * normal
         float dp = light.DotProduct(normal, light) * 2;
         Vect4 R  = new Vect4(normal.x * dp, normal.y * dp, normal.z * dp);
         R = R.Substraction(light);
         R.Normalize();
         float Is = ks * Mathf.Pow(R.DotProduct(R, view), h);
         float I  = Ia + Id + Is;
         mr.material.SetColor("_Color", IndexedFace.Instance.materialColor * I);
     }
 }
示例#3
0
 public void CalculateNormal(Vect4 p1, Vect4 p2, Vect4 p3)
 {
     normal = p1.CrossProduct(p2.Substraction(p1), p3.Substraction(p1));
     normal = normal.Normalize();
 }