/// <inheritdoc /> public override void Pdf_We(Ray ray, out double pdfPos, out double pdfDir) { // Interpolate camera matrix and fail if $\w{}$ is not forward-facing CameraToWorld.Interpolate(ray.Time, out Transform c2w); double cosTheta = ray.Direction.Dot(c2w.ExecuteTransform(new Vector3D(0.0, 0.0, 1.0))); if (cosTheta <= 0) { pdfPos = pdfDir = 0.0; return; } // Map ray $(\p{}, \w{})$ onto the raster grid Point3D pFocus = ray.AtPoint((LensRadius > 0.0 ? FocalDistance : 1.0) / cosTheta); Point3D pRaster = RasterToCamera.Inverse().ExecuteTransform(c2w.Inverse().ExecuteTransform(pFocus)); // Return zero probability for out of bounds points Bounds2I sampleBounds = Film.GetSampleBounds(); if (pRaster.X < sampleBounds.MinPoint.X || pRaster.X >= sampleBounds.MaxPoint.X || pRaster.Y < sampleBounds.MinPoint.Y || pRaster.Y >= sampleBounds.MaxPoint.Y) { pdfPos = pdfDir = 0.0; return; } // Compute lens area of perspective camera double lensArea = LensRadius != 0.0 ? (Math.PI * LensRadius * LensRadius) : 1.0; pdfPos = 1.0 / lensArea; pdfDir = 1.0 / (_a * cosTheta * cosTheta * cosTheta); }
public static WhittedIntegrator Create(ParamSet paramSet, Sampler sampler, Camera camera) { int maxDepth = paramSet.FindOneInt("maxdepth", 5); int[] pb = paramSet.FindInt("pixelbounds"); Bounds2I pixelBounds = camera.Film.GetSampleBounds(); if (pb != null) { if (pb.Length != 4) { //Error("Expected four values for \"pixelbounds\" parameter. Got %d.", // np); } else { pixelBounds = pixelBounds.Intersect(new Bounds2I(new Point2I(pb[0], pb[2]), new Point2I(pb[1], pb[3]))); if (pixelBounds.Area == 0) { //Error("Degenerate \"pixelbounds\" specified."); } } } return(new WhittedIntegrator(maxDepth, camera, sampler, pixelBounds)); }
public static PathIntegrator Create(ParamSet paramSet, Sampler sampler, Camera camera) { int maxDepth = paramSet.FindOneInt("maxdepth", 5); Bounds2I pixelBounds = camera.Film.GetSampleBounds(); int[] pb = paramSet.FindInt("pixelbounds"); if (pb.Length > 0) { if (pb.Length != 4) { throw new InvalidOperationException(); } pixelBounds = pixelBounds.Intersect(new Bounds2I(new Point2I(pb[0], pb[2]), new Point2I(pb[1], pb[3]))); if (pixelBounds.Area == 0.0) { throw new InvalidOperationException("degenerate pixelbounds specified"); } } double rrThreshold = paramSet.FindOneDouble("rrthreshold", 1.0); string lightStrategy = paramSet.FindOneString("lightsamplestrategy", "spatial"); return(new PathIntegrator(maxDepth, camera, sampler, pixelBounds, rrThreshold, lightStrategy)); }
public FilmTile GetFilmTile(Bounds2I sampleBounds) { // Bound image pixels that samples in _sampleBounds_ contribute to Point2D halfPixel = new Point2D(0.5, 0.5); Bounds2D floatBounds = sampleBounds.ToBounds2D(); Point2I p0 = (floatBounds.MinPoint - halfPixel - Filter.Radius.ToPoint2D()).Ceiling().ToPoint2I(); Point2I p1 = (floatBounds.MaxPoint - halfPixel + Filter.Radius.ToPoint2D()).Floor().ToPoint2I() + new Point2I(1, 1); Bounds2I tilePixelBounds = new Bounds2I(p0, p1).Intersect(CroppedPixelBounds); return(new FilmTile(tilePixelBounds, Filter.Radius, FilterTable, FilterTableWidth, _maxSampleLuminance)); }
public FilmTile( Bounds2I pixelBounds, Vector2D filterRadius, IEnumerable <double> filterTable, int filterTableSize, double maxSampleLuminance) { PixelBounds = pixelBounds; FilterRadius = filterRadius; InvFilterRadius = new Vector2D(1.0 / filterRadius.X, 1.0 / filterRadius.Y); _filterTable = filterTable.ToList(); FilterTableSize = filterTableSize; MaxSampleLuminance = maxSampleLuminance; _pixels = new List <FilmTilePixel>(Math.Max(0, pixelBounds.Area)); }
public Film( Point2I resolution, Bounds2D cropWindow, Filter filter, double diagonal, string filename, double scale, double maxSampleLuminance = double.MaxValue) { FullResolution = resolution; Diagonal = diagonal * 0.001; Filter = filter; Filename = filename; _scale = scale; _maxSampleLuminance = maxSampleLuminance; CroppedPixelBounds = new Bounds2I( new Point2I( Convert.ToInt32(Math.Ceiling(Convert.ToDouble(FullResolution.X) * cropWindow.MinPoint.X)), Convert.ToInt32(Math.Ceiling(Convert.ToDouble(FullResolution.Y) * cropWindow.MinPoint.Y))), new Point2I( Convert.ToInt32(Math.Ceiling(Convert.ToDouble(FullResolution.X) * cropWindow.MaxPoint.X)), Convert.ToInt32(Math.Ceiling(Convert.ToDouble(FullResolution.Y) * cropWindow.MaxPoint.Y)))); //LOG(INFO) << "Created film with full resolution " << resolution << // ". Crop window of " << cropWindow << " -> croppedPixelBounds " << // croppedPixelBounds; // Allocate film image storage _pixels = new Pixel[CroppedPixelBounds.Area]; // todo: this is a stat... _filmPixelMemory += croppedPixelBounds.Area() * sizeof(Pixel); // Precompute filter weight table int offset = 0; for (int y = 0; y < FilterTableWidth; ++y) { for (int x = 0; x < FilterTableWidth; ++x, ++offset) { Point2D p = new Point2D( (x + 0.5f) * filter.Radius.X / Convert.ToDouble(FilterTableWidth), (y + 0.5f) * filter.Radius.Y / Convert.ToDouble(FilterTableWidth)); FilterTable[offset] = filter.Evaluate(p); } } }
/// <inheritdoc /> public override Spectrum We(Ray ray, out Point2D pRaster2) { // Interpolate camera matrix and check if $\w{}$ is forward-facing CameraToWorld.Interpolate(ray.Time, out Transform c2w); double cosTheta = ray.Direction.Dot(c2w.ExecuteTransform(new Vector3D(0.0, 0.0, 1.0))); if (cosTheta <= 0.0) { pRaster2 = null; return(Spectrum.Create(0.0)); } // Map ray $(\p{}, \w{})$ onto the raster grid Point3D pFocus = ray.AtPoint((LensRadius > 0.0 ? FocalDistance : 1.0) / cosTheta); Point3D pRaster = RasterToCamera.ExecuteTransform(c2w.Inverse().ExecuteTransform(pFocus)); //Point3D pRaster = Inverse(RasterToCamera)(Inverse(c2w.Inverse)(pFocus)); // Return raster position if requested pRaster2 = new Point2D(pRaster.X, pRaster.Y); // Return zero importance for out of bounds points Bounds2I sampleBounds = Film.GetSampleBounds(); if (pRaster.X < sampleBounds.MinPoint.X || pRaster.Z >= sampleBounds.MaxPoint.X || pRaster.Y < sampleBounds.MinPoint.Y || pRaster.Y >= sampleBounds.MaxPoint.Y) { return(Spectrum.Create(0.0)); } // Compute lens area of perspective camera double lensArea = LensRadius != 0.0 ? (Math.PI * LensRadius * LensRadius) : 1.0; // Return importance for point on image plane double cos2Theta = cosTheta * cosTheta; return(Spectrum.Create(1.0 / (_a * lensArea * cos2Theta * cos2Theta))); }
public SamplerIntegrator(Camera camera, Sampler sampler, Bounds2I pixelBounds) { Camera = camera; _sampler = sampler; _pixelBounds = pixelBounds; }
public static void WriteImage(string filename, double rgb, Bounds2I outputBounds, Point2I totalResolution) { throw new NotImplementedException(); }
/// <inheritdoc /> public WhittedIntegrator(int maxDepth, Camera camera, Sampler sampler, Bounds2I pixelBounds) : base(camera, sampler, pixelBounds) { _maxDepth = maxDepth; }
/// <inheritdoc /> public PathIntegrator(int maxDepth, Camera camera, Sampler sampler, Bounds2I pixelBounds, double rrThreshold = 1.0, string lightSampleStrategy = "spatial") : base(camera, sampler, pixelBounds) { _maxDepth = maxDepth; }