예제 #1
0
        /**
         * Renders the part <code>id</code> of <code>splitCount</code> of the image to ibuf.
         *
         * @param id a number from <code>0</code> to <code>splitCount-1</code>
         */

        private int RenderImagePart(int id)
        {
            int splitCount = _threadCount * SplitMultiplier;
            int slotHeight = _heightPx / splitCount;
            int from       = slotHeight * id;
            int to         = slotHeight * (id + 1);

            if (id == splitCount - 1)
            {
                to = _heightPx;
            }

            BackwardRayTracer logic  = GetLogic();
            Camera            camera = _scene.Camera;

            var baseDirection = camera.ViewPaneEdge - camera.Position;
            var vertAdd       = camera.ViewPaneHeightVector / (_heightPx - 1);
            var horzAdd       = camera.ViewPaneWidthVector / (_widthPx - 1);

            int localMaxBrightness = 0;

            for (int i = from; i < to; i++)
            {
                for (int j = 0; j < _widthPx; j++)
                {
                    var ray = new Shapes.Ray {
                        Origin    = camera.Position,
                        Direction = (baseDirection + vertAdd * i + horzAdd * j).Normalize()
                    };

                    WideColor color = logic.Shoot(ray);

                    ushort localBrightness = color.GetMax();
                    if (localBrightness > localMaxBrightness)
                    {
                        localMaxBrightness = localBrightness;
                    }

                    _lbuf[i, j] = color;
                }
            }
            return(localMaxBrightness);
        }
예제 #2
0
 public abstract double GetHitPointDistance(Ray r);