Example #1
0
        public override bool Scatter(Ray r, HitRecord hitRecord, out Vector3 attenuation, out Ray scattered)
        {
            Vector3 reflected = VectorHelpers.Reflect(r.Direction.GetUnitVector(), hitRecord.SurfaceNormal);

            scattered   = new Ray(hitRecord.HitPoint, reflected + Fuzz * VectorHelpers.GetRandomInUnitSphere());
            attenuation = Albedo;
            return(Vector3.Dot(scattered.Direction, hitRecord.SurfaceNormal) > 0);
        }
Example #2
0
        public override bool Scatter(Ray r, HitRecord hitRecord, out Vector3 attenuation, out Ray scattered)
        {
            Vector3 target = hitRecord.HitPoint + hitRecord.SurfaceNormal + VectorHelpers.GetRandomInUnitSphere();

            scattered   = new Ray(hitRecord.HitPoint, target - hitRecord.HitPoint);
            attenuation = Texture.GetValue(0, 0, hitRecord.HitPoint);
            return(true);
        }