示例#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
 public override Spectrum SampleL(Point p, float pEpsilon, LightSample ls,
     float time, out Vector wi, out float pdf,
     out VisibilityTester vis)
 {
     wi = _direction;
     pdf = 1.0f;
     vis = new VisibilityTester(p, pEpsilon, wi, time);
     return _radiance;
 }
示例#3
0
 public override Spectrum SampleL(
     Point p, float pEpsilon, LightSample ls, float time, out Vector wi,
     out float pdf, out VisibilityTester vis)
 {
     wi = Vector.Normalize(_lightPosition - p);
     pdf = 1.0f;
     vis = new VisibilityTester(p, pEpsilon, _lightPosition, 0.0f, time);
     return _intensity / Point.DistanceSquared(_lightPosition, p);
 }
示例#4
0
 public Point TransformPoint(ref Point pt)
 {
     float x = pt.X, y = pt.Y, z = pt.Z;
     float xp = _m.M[0, 0] * x + _m.M[0, 1] * y + _m.M[0, 2] * z + _m.M[0, 3];
     float yp = _m.M[1, 0] * x + _m.M[1, 1] * y + _m.M[1, 2] * z + _m.M[1, 3];
     float zp = _m.M[2, 0] * x + _m.M[2, 1] * y + _m.M[2, 2] * z + _m.M[2, 3];
     float wp = _m.M[3, 0] * x + _m.M[3, 1] * y + _m.M[3, 2] * z + _m.M[3, 3];
     Debug.Assert(wp != 0);
     if (wp == 1.0f)
         return new Point(xp, yp, zp);
     return new Point(xp, yp, zp) / wp;
 }
示例#5
0
 public override Spectrum L(Point p, Normal n, Vector w)
 {
     throw new System.NotImplementedException();
 }
示例#6
0
 public override float Pdf(Point p, Vector wi)
 {
     throw new System.NotImplementedException();
 }
示例#7
0
 public override Spectrum SampleL(Point p, float pEpsilon, LightSample ls, float time, out Vector wi, out float pdf,
     out VisibilityTester vis)
 {
     throw new System.NotImplementedException();
 }
示例#8
0
 public abstract Spectrum L(Point p, Normal n, Vector w);
示例#9
0
 public override float Pdf(Point p, Vector wi)
 {
     return 0.0f;
 }
示例#10
0
 public PointLight(Transform lightToWorld, Spectrum intensity)
     : base(lightToWorld)
 {
     _intensity = intensity;
     _lightPosition = lightToWorld.TransformPoint(Point.Zero);
 }
示例#11
0
 public Point TransformPoint(Point pt)
 {
     return TransformPoint(ref pt);
 }
示例#12
0
        public static Transform LookAt(Point pos, Point look, Vector up)
        {
            var m = new float[4, 4];
            // Initialize fourth column of viewing matrix
            m[0, 3] = pos.X;
            m[1, 3] = pos.Y;
            m[2, 3] = pos.Z;
            m[3, 3] = 1;

            // Initialize first three columns of viewing matrix
            Vector dir = Vector.Normalize(look - pos);
            Vector left = Vector.Normalize(Vector.Cross(Vector.Normalize(up), dir));
            Vector newUp = Vector.Cross(dir, left);
            m[0, 0] = left.X;
            m[1, 0] = left.Y;
            m[2, 0] = left.Z;
            m[3, 0] = 0.0f;
            m[0, 1] = newUp.X;
            m[1, 1] = newUp.Y;
            m[2, 1] = newUp.Z;
            m[3, 1] = 0.0f;
            m[0, 2] = dir.X;
            m[1, 2] = dir.Y;
            m[2, 2] = dir.Z;
            m[3, 2] = 0.0f;
            var camToWorld = new Matrix4x4(m);
            return new Transform(Matrix4x4.Invert(camToWorld), camToWorld);
        }