Beispiel #1
0
        /// <summary> Create a new scene with some default objects </summary>
        /// <param name="screen">The screen to draw the raytracing to</param>
        /// <param name="primitives">The primitives in the scene</param>
        public Scene(IScreen screen, List <Primitive> primitives)
        {
            Camera     = new Camera(screen);
            Primitives = primitives;
            Lights     = primitives.FindAll(p => p.Material.Emitting);
            Stopwatch timer = Stopwatch.StartNew();

            AccelerationStructure = new SBVHTree(primitives);
            Console.WriteLine(timer.ElapsedMilliseconds + "\t| (S)BVH Building ms");
        }
Beispiel #2
0
        public void NodeCount()
        {
            const int primitiveCount = 1_000;

            for (int i = 0; i < 10; i++)
            {
                SBVHTree bvh       = RandomSBVH(primitiveCount);
                int      nodeCount = CountNodes(bvh.Root);
                Debug.WriteLine($"Node count in percentage of primitives: {(float)nodeCount / primitiveCount}");
                Assert.IsTrue(nodeCount <= primitiveCount * 4);
            }