public void GetCameraSampleForPixels() { var start = new PixelCoordinate(0, 0); var end = new PixelCoordinate(100, 100); var area = new PixelArea(start, end); var hs = new HaltonSampler(10, area); var arena = new ObjectArena(); hs.StartPixel(in start); var cs = hs.GetCameraSample(in start, arena); cs.FilmPoint.X.Should().BeInRange(0f, 1f); cs.FilmPoint.Y.Should().BeInRange(0f, 1f); cs.LensPoint.X.Should().BeInRange(0f, 1f); cs.LensPoint.Y.Should().BeInRange(0f, 1f); var next = new PixelCoordinate(1, 0); hs.StartPixel(in next); var csn = hs.GetCameraSample(in next, arena); csn.FilmPoint.X.Should().BeInRange(1f, 2f); csn.FilmPoint.Y.Should().BeInRange(0f, 1f); csn.LensPoint.X.Should().BeInRange(0f, 1f); csn.LensPoint.Y.Should().BeInRange(0f, 1f); cs.FilmPoint.X.Should().NotBe(csn.FilmPoint.X); cs.FilmPoint.Y.Should().NotBe(csn.FilmPoint.Y); cs.LensPoint.X.Should().NotBe(csn.LensPoint.X); cs.LensPoint.Y.Should().NotBe(csn.LensPoint.Y); }
public BVH(IPrimitive[] p, SplitMethod splitMethod, int maxPerNode = 1) { _p = p; SplitMethod = splitMethod; MaxPerNode = maxPerNode; var primitiveInfo = new BVHPrimitiveInfo[p.Length]; for (var i = 0; i < primitiveInfo.Length; ++i) { primitiveInfo[i] = new BVHPrimitiveInfo(i, p[i].WorldBounds); } var ordered = new List <IPrimitive>(p); var arena = new ObjectArena(); var totalNodes = 0; var root = splitMethod == SplitMethod.HLBVH ? HLBVHBuild(arena, primitiveInfo, out totalNodes, ordered) : RecursiveBuild(arena, primitiveInfo, 0, p.Length, ref totalNodes, ordered); _p = ordered.ToArray(); _nodes = new LinearBVHNode[totalNodes]; var offset = 0; FlattenBVHTree(root, ref offset); arena.Clear(); }