public override void Render(IEnumerable <TiledBitmap.Tile> tiles) { if (buildPhotonMaps) { this.ScatterPhotons(); buildPhotonMaps = false; } float resX = this.scene.DefaultCamera.ResX; //g.VisibleClipBounds.Width; float resY = this.scene.DefaultCamera.ResY; //g.VisibleClipBounds.Height; float x, y; int iterations = 0; RayTracer tracer = new RayTracer(this.scene, new ScanlineRenderStrategy()); int pCol = 0, pRow = 0, pIteration = 1, pMax = 2; SolidBrush brush = new SolidBrush(Color.Black); float resTotal = resX * resY; while (iterations < resTotal) { //Render Pixels Out of Order With Increasing Resolution: 2x2, 4x4, 16x16... 512x512 if (pCol >= pMax) { pRow++; pCol = 0; if (pRow >= pMax) { pIteration++; pRow = 0; pMax = (int)Math.Pow(2, pIteration); } } bool pNeedsDrawing = (pIteration == 1 || (pRow % 2 != 0) || (!(pRow % 2 != 0) && (pCol % 2 != 0))); x = pCol * (resX / pMax); y = pRow * (resY / pMax); pCol++; if (pNeedsDrawing) { iterations++; Ray ray = this.scene.DefaultCamera.CreateRayFromScreen(x, y); ray.PrevRefractIndex = this.scene.RefractIndex; Intersection intersection; if (this.scene.FindIntersection(ray, out intersection)) { brush.Color = this.indirectEnlightenment.IrradianceEstimate(intersection.HitPoint, intersection.Normal, this.IrradianceArea, this.IrradiancePhotonNumber).ToColor(); //TODO: g.FillRectangle(brush, x, y, (resX / pMax), (resY / pMax)); } } } }
public override void Render(IEnumerable<TiledBitmap.Tile> tiles) { if (buildPhotonMaps) { this.ScatterPhotons(); buildPhotonMaps = false; } float resX = this.scene.DefaultCamera.ResX; //g.VisibleClipBounds.Width; float resY = this.scene.DefaultCamera.ResY; //g.VisibleClipBounds.Height; float x, y; int iterations = 0; RayTracer tracer = new RayTracer(this.scene, new ScanlineRenderStrategy()); int pCol = 0, pRow = 0, pIteration = 1, pMax = 2; SolidBrush brush = new SolidBrush(Color.Black); float resTotal = resX * resY; while (iterations < resTotal) { //Render Pixels Out of Order With Increasing Resolution: 2x2, 4x4, 16x16... 512x512 if (pCol >= pMax) { pRow++; pCol = 0; if (pRow >= pMax) { pIteration++; pRow = 0; pMax = (int) Math.Pow(2, pIteration); } } bool pNeedsDrawing = (pIteration == 1 || (pRow % 2 != 0) || (!(pRow % 2 != 0) && (pCol % 2 != 0))); x = pCol * (resX / pMax); y = pRow * (resY / pMax); pCol++; if (pNeedsDrawing) { iterations++; Ray ray = this.scene.DefaultCamera.CreateRayFromScreen(x, y); ray.PrevRefractIndex = this.scene.RefractIndex; Intersection intersection; if (this.scene.FindIntersection(ray, out intersection)) { brush.Color = this.indirectEnlightenment.IrradianceEstimate(intersection.HitPoint, intersection.Normal, this.IrradianceArea, this.IrradiancePhotonNumber).ToColor(); //TODO: g.FillRectangle(brush, x, y, (resX / pMax), (resY / pMax)); } } } }