public virtual double GenerateRayDifferential(CameraSample sample, ref RayDifferential rd) { Ray r = new Ray (rd.Origin, rd.Direction, rd.MinT, rd.MaxT, rd.Time); double wt = GenerateRay (sample, ref r); rd.Origin = r.Origin; rd.Direction = r.Direction; rd.MinT = r.MinT; rd.MaxT = r.MaxT; rd.Time = r.Time; CameraSample sshift = sample; ++sshift.ImageX; Ray rx = new Ray (); double wtx = GenerateRay (sshift, ref rx); rd.RxOrigin = rx.Origin; rd.RxDirection = rx.Direction; --sshift.ImageX; ++sshift.ImageY; Ray ry = new Ray (); double wty = GenerateRay (sshift, ref ry); rd.RyOrigin = ry.Origin; rd.RyDirection = ry.Direction; if (wtx == 0.0 || wty == 0.0) return 0.0; rd.HasDifferentials = true; return wt; }
public override double GenerateRay(CameraSample sample, ref Ray ray) { ++NumberOfRays; // Generate raster and camera samples Point pRas = new Point (sample.ImageX, sample.ImageY, 0); Point pCam = new Point (); RasterToCamera.Apply (pRas, ref pCam); ray = new Ray (new Point (), new Vector (pCam), 0.0, double.PositiveInfinity); if (LensRadius > 0.0) { double lensU = 0.0, lensV = 0.0; MonteCarlo.ConcentricSampleDisk (sample.LensU, sample.LensV, ref lensU, ref lensV); lensU *= LensRadius; lensV *= LensRadius; double ft = FocalDistance / ray.Direction.z; Point pFocus = ray.Apply (ft); ray.Origin = new Point (lensU, lensV, 0.0); ray.Direction = (pFocus - ray.Origin).Normalized; } ray.Time = Util.Lerp (sample.Time, ShutterOpen, ShutterClose); CameraToWorld.Apply (ray, ref ray); return 1.0; }
public abstract double GenerateRay(CameraSample sample, ref Ray ray);
public override double GenerateRayDifferential(CameraSample sample, ref RayDifferential rd) { ++NumberOfRays; Point pRas = new Point (sample.ImageX, sample.ImageY, 0.0); Point pCam = new Point (); RasterToCamera.Apply (pRas, ref pCam); Vector dir = new Vector (pCam).Normalized; rd = new RayDifferential (new Point (), dir, 0.0, double.PositiveInfinity); if (LensRadius > 0.0) { double lensU = 0.0, lensV = 0.0; MonteCarlo.ConcentricSampleDisk (sample.LensU, sample.LensV, ref lensU, ref lensV); lensU *= LensRadius; lensV *= LensRadius; double ft = FocalDistance / rd.Direction.z; Point pFocus = rd.Apply (ft); rd.Origin = new Point (lensU, lensV, 0.0); rd.Direction = (pFocus - rd.Origin).Normalized; } rd.RxOrigin = new Point (rd.Origin); rd.RyOrigin = new Point (rd.Origin); rd.RxDirection = (new Vector (pCam) + dxCamera).Normalized; rd.RyDirection = (new Vector (pCam) + dyCamera).Normalized; rd.Time = Util.Lerp (sample.Time, ShutterOpen, ShutterClose); CameraToWorld.Apply (rd, ref rd); rd.HasDifferentials = true; return 1.0; }