예제 #1
0
        public override float GenerateRayDifferential(CameraSample sample, out RayDifferential ray)
        {
            // Generate raster and camera samples
            Point Pras    = new Point(sample.ImageX, sample.ImageY, 0);
            Point Pcamera = RasterToCamera.TransformPoint(ref Pras);

            ray = new RayDifferential(new Point(0, 0, 0), Vector.Normalize((Vector)Pcamera), 0.0f);
            // Modify ray for depth of field
            if (LensRadius > 0.0f)
            {
                // Sample point on lens
                float lensU, lensV;
                MonteCarloUtilities.ConcentricSampleDisk(sample.LensU, sample.LensV, out lensU, out lensV);
                lensU *= LensRadius;
                lensV *= LensRadius;

                // Compute point on plane of focus
                float ft     = FocalDistance / ray.Direction.Z;
                Point Pfocus = ray.Evaluate(ft);

                // Update ray for effect of lens
                ray.Origin    = new Point(lensU, lensV, 0.0f);
                ray.Direction = Vector.Normalize(Pfocus - ray.Origin);
            }
            // Compute offset rays for _PerspectiveCamera_ ray differentials
            ray.RxOrigin    = ray.RyOrigin = ray.Origin;
            ray.RxDirection = Vector.Normalize((Vector)Pcamera + _dxCamera);
            ray.RyDirection = Vector.Normalize((Vector)Pcamera + _dyCamera);
            ray.Time        = sample.Time;
            ray             = CameraToWorld.TransformRayDifferential(ray);
            return(1.0f);
        }
예제 #2
0
파일: Disk.cs 프로젝트: MassVOiD/aether
        public override Point Sample(float u1, float u2, out Normal ns)
        {
            var p = new Point();

            MonteCarloUtilities.ConcentricSampleDisk(u1, u2, out p.X, out p.Y);
            p.X *= _radius;
            p.Y *= _radius;
            p.Z  = _height;
            ns   = Normal.Normalize(ObjectToWorld.TransformNormal(new Normal(0, 0, 1)));
            if (ReverseOrientation)
            {
                ns *= -1.0f;
            }
            return(ObjectToWorld.TransformPoint(ref p));
        }
예제 #3
0
        public override Spectrum SampleL(Scene scene, LightSample ls, float u1, float u2, float time, out Ray ray, out Normal ns, out float pdf)
        {
            // Choose point on disk oriented toward infinite light direction
            Point worldCenter;
            float worldRadius;

            scene.WorldBound.BoundingSphere(out worldCenter, out worldRadius);
            Vector v1, v2;

            Vector.CoordinateSystem(_direction, out v1, out v2);
            float d1, d2;

            MonteCarloUtilities.ConcentricSampleDisk(ls.UPos0, ls.UPos1, out d1, out d2);
            Point Pdisk = worldCenter + worldRadius * (d1 * v1 + d2 * v2);

            // Set ray origin and direction for infinite light ray
            ray = new Ray(Pdisk + worldRadius * _direction, -_direction, 0.0f, float.PositiveInfinity, time);
            ns  = (Normal)ray.Direction;

            pdf = 1.0f / (MathUtility.Pi * worldRadius * worldRadius);
            return(_radiance);
        }