Exemplo n.º 1
0
        public virtual bool Scatter(Ray p_rayIn, HitRecord p_hitRecord, ref Color p_attenuation, ref Ray p_scatteredRay)
        {
            if (p_attenuation == null)
            {
                throw new ArgumentNullException(nameof(p_attenuation));
            }
            var reflected = Vec3.GetReflection(Vec3.GetUnitVector(p_rayIn.Direction), p_hitRecord.Normal);

            p_scatteredRay = new Ray(p_hitRecord.Point, reflected + Roughness * Math.GetRandomPositionInUnitSphere());
            p_attenuation  = Albedo;
            return(Vec3.GetDotProduct(p_scatteredRay.Direction, p_hitRecord.Normal) > 0);
        }
Exemplo n.º 2
0
        public virtual bool Scatter(Ray p_rayIn, HitRecord p_hitRecord, ref Color p_attenuation, ref Ray p_scatteredRay)
        {
            if (p_attenuation == null)
            {
                throw new ArgumentNullException(nameof(p_attenuation));
            }
            var target = p_hitRecord.Point + p_hitRecord.Normal + Math.GetRandomPositionInUnitSphere();

            p_scatteredRay = new Ray(p_hitRecord.Point, target - p_hitRecord.Point);
            p_attenuation  = Albedo;
            return(true);
        }