Beispiel #1
0
        public override void RenderScene(World world)
        {
            Vector3 L;
            ViewPlane vp = new ViewPlane(world.ViewPlane);
            Ray ray = new Ray();
            int depth = 0;
            Vector2 pp  = new Vector2();
            vp.S /= Zoom;
            ray.Position = Position;
            int n = (int)MathHelper.Sqrt((float)vp.NumSamples);
            for (int r = 0; r < vp.VRes; r++)
                for (int c = 0; c < vp.HRes; c++)
                {
                    L = new Vector3(0, 0, 0);
                    for (int p = 0; p < n; p++)
                        for (int q = 0; q < n; q++)
                        {
                            pp.X = vp.S * (c - 0.5f * vp.HRes + (q + 0.5f) / n);
                            pp.Y = vp.S * (r - 0.5f * vp.VRes + (p + 0.5f) / n);
                            ray.Direction = GetDirection(pp);
                            L += world.Tracer.TraceRay(ray, depth);
                        }

                    L /= ((float)vp.NumSamples);
                    L *= ExposureTime;
                    world.Screen.AddPixel(r, c, L);
                }
        }
Beispiel #2
0
 public ViewPlane(ViewPlane vp)
 {
     HRes = vp.HRes;
     VRes = vp.VRes;
     S = vp.S;
     Gamma = vp.Gamma;
     Show_Out_Of_gammut = vp.Show_Out_Of_gammut;
     sampler = vp.sampler;
     NumSamples = vp.NumSamples;
 }
Beispiel #3
0
 public static ViewPlane CreateViewPlaneFromElement(this RElement ele)
 {
     ViewPlane vp = new ViewPlane();
     vp.HRes = ele.Attributes[P.Width].ToInt();
     vp.VRes = ele.Attributes[P.Height].ToInt();
     vp.NumSamples = ele.Attributes[P.Samples].ToInt();
     vp.SetSampler(ele.Attributes[P.Sampler].CreateSamplerFromAttribute(vp.NumSamples));
     vp.MaxDepth = ele.Attributes[P.MaxDepth].ToInt();
     return vp;
 }
Beispiel #4
0
 public PixelScreen(ViewPlane vp)
 {
     this.vp = vp;
 }