Ejemplo n.º 1
0
 void init_vector_table(int seed)
 {
     float r1, r2;
     float x, y, z;
     float r, phi;
     MathHelper.SetRandomSeed(seed_value);
     MultiJittered sample_ptr = new MultiJittered(256, 1);
     for (int j = 0; j < kTableSize; j++)
     {
         Vector2 sample_point = sample_ptr.SampleOneSet();
         r1 = sample_point.X;
         r2 = sample_point.Y;
         z = 1.0f - 2.0f * r1;
         r = MathHelper.Sqrt(1.0f - z * z);
         phi = MathHelper.TwoPI * r2;
         x = r * MathHelper.Cos(phi);
         y = r * MathHelper.Sin(phi);
         vector_table[j] = Vector3.Normalize(new Vector3(x, y, z));
     }
 }
Ejemplo n.º 2
0
 void build2()
 {
     int ns = 100;
     world.ViewPlane = new ViewPlane();
     world.ViewPlane.HRes = world.ViewPlane.VRes = 400;
     world.ViewPlane.SetSamples(ns);
     world.Tracer = new RayCast(world);
     MultiJittered sampler = new MultiJittered(ns);
     AmbientOccluder occulder = new AmbientOccluder();
     occulder.RadianceScale = 1.0f;
     occulder.Color = Vector3.One;
     occulder.MinAmount = 0.0f;
     occulder.SetSampler(sampler);
     occulder.Shadows = true;
     world.AmbientLight = occulder;
     Directional light_ptr = new Directional();
     light_ptr.Direction = Vector3.Normalize(new Vector3(100, 100, 100));
     light_ptr.RadianceScale = 1.0f;
     light_ptr.Shadows = true;
     light_ptr.Color = new Vector3(1);
     world.Lights.Add(light_ptr);
     Pinhole cam = new Pinhole();
     cam.Position = new Vector3(25, 20, 45);
     cam.Target = new Vector3(0, 1, 0);
     cam.Distance = 5000;
     world.Camera = cam;
     Matte matte = new Matte(0.25f, 0.7f, new Vector3(1, 1, 0));
     matte.Shadows = true;
     Sphere s = new Sphere(new Vector3(0, 1, 0), 1);
     s.Shadows = true;
     s.SetMaterial(matte);
     world.Objects.Add(s);
     Matte matte2 = new Matte(0.75f, 0, new Vector3(1, 1, 1));
     matte2.Shadows = true;
     Plane p = new Plane(Vector3.Zero, new Vector3(0, 1, 0));
     p.Shadows = true;
     p.SetMaterial(matte2);
     world.Objects.Add(p);
 }
Ejemplo n.º 3
0
 public void SetSamples(int num_samples, float exp)
 {
     Sampler = new MultiJittered(num_samples);
     Sampler.MapSamplesToHemisphere(exp);
 }