/** * @param normal previous hit normal * @param pos previous hit pos * @param type previous hit material (reflection or refraction) */ Vector3 updateObjectPotition_sup(Vector3 viewDir, Vector3 normal, Vector3 pos, LightPath.Type type, LightPath path) { Vector3 o = Vector3.zero; if (type == LightPath.Type.Reflection) { o = RotationFromNormal.VectorRotateAroundAxis(-viewDir, normal, 180); } else if (type == LightPath.Type.Refraction) { o = RotationFromNormal.RefractRayDirection(viewDir, normal, 0.6666f, RotationFromNormal.Space.AirTo); } if (Physics.Raycast(pos, o, out RaycastHit hit, 1000)) { path.Add(hit.point, type); LightPath.Type tp = LightPath.Type.None; if (hit.transform.tag == "ReflectionMaterial") { tp = LightPath.Type.Reflection; } else if (hit.transform.tag == "RefractionMaterial") { tp = LightPath.Type.Refraction; } if (tp != LightPath.Type.None) { return(updateObjectPotition_sup(o, hit.normal, hit.point, tp, path)); } return(hit.point - rayOffset * viewDir); } Debug.Log("Reflection/Refraction ray do not hit anything !"); return(pos - rayOffset * viewDir); }