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); } }
public void BackFaceCulling(Vect4 normal, Vect4 view) { if (normal.DotProduct(normal, view) >= 0) { //Dont draw triangle mr.enabled = false; } }
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); } }