Exemple #1
0
        /// <summary>
        /// 光线追踪测试
        /// </summary>
        /// <param name="ray"></param>
        /// <returns></returns>
        public override RayCastResult Intersection(Ray ray, float nowbest)
        {
            // 包围盒测试失败
            {
                (bool happened, float mint) = BoundBox.Intersection(ray);
                if (!happened || mint > nowbest)                   // 未相交 或 当前最小解已不是最优
                {
                    return(null);
                }
            }

            RayCastResult result = BVH.Intersection(ray, float.MaxValue);

            if (result != null)
            {
                result.material = Material;
                if (result.internalPoint)
                {
                    result.IOR = 1.0f;
                }
                else
                {
                    result.IOR = Material.Refraction.IOR;
                }
            }
            return(result);
        }