public virtual double GenerateRayDifferential(CameraSample sample, out RayDifferential rd) { double wt = GenerateRay(sample, out Ray r); rd = new RayDifferential(r); if (wt == 0.0) { return(0.0); } // Find camera ray after shifting a fraction of a pixel in the $x$ direction double wtx = 0.0; foreach (double eps in new List <double> { 0.5, -0.5 }) { CameraSample sshift = sample; sshift.FilmPoint = new Point2D(sshift.FilmPoint.X + eps, sshift.FilmPoint.Y); wtx = GenerateRay(sshift, out Ray rx); rd.RxOrigin = rd.Origin + (rx.Origin - rd.Origin) / eps; rd.RxDirection = rd.Direction + (rx.Direction - rd.Direction) / eps; if (wtx != 0.0) { break; } } if (wtx == 0.0) { return(0.0); } // Find camera ray after shifting a fraction of a pixel in the $y$ direction double wty = 0.0; foreach (double eps in new List <double> { 0.5, -0.5 }) { CameraSample sshift = sample; sshift.FilmPoint = new Point2D(sshift.FilmPoint.X, sshift.FilmPoint.Y + eps); wty = GenerateRay(sshift, out Ray ry); rd.RyOrigin = rd.Origin + (ry.Origin - rd.Origin) / eps; rd.RyDirection = rd.Direction + (ry.Direction - rd.Direction) / eps; if (wty != 0.0) { break; } } if (wty == 0.0) { return(0.0); } rd.HasDifferentials = true; return(wt); }
public CameraSample GetCameraSample(Point2I pRaster) { CameraSample cs = new CameraSample(pRaster.ToPoint2D() + Get2D(), Get2D(), Get1D()); return(cs); }
public abstract double GenerateRay(CameraSample sample, out Ray ray);