Exemplo n.º 1
0
        public bool Scatter(Ray rayIn, HitRecord record, ref Color attenuation, ref Ray scatteredRay)
        {
            var target = record.Point + record.Normal + RayTraceUtility.GetRandomPointInUnitSphere();

            scatteredRay = new Ray(record.Point, target - record.Point);
            attenuation  = albedo;
            return(true);
        }
Exemplo n.º 2
0
        static Color GetColorFromHitRecord(Ray ray, HitableList list)
        {
            var rec = new HitRecord();

            if (list.Hit(ray, 0.001f, float.MaxValue, ref rec))
            {
                var target = rec.Point + rec.Normal + RayTraceUtility.GetRandomPointInUnitSphere();
                return(0.5f * GetColorFromHitRecord(new Ray(rec.Point, target - rec.Point), list));
            }

            var t = (ray.NormalizedDirection.y + 1f) * 0.5f;

            return((1 - t) * Color.white + t * new Color(0.5f, 0.7f, 1f));
        }