public override Spectrum SampleL(Point p, double pEpsilon, LightSample ls, double time, ref Vector wi, ref double pdf, ref VisibilityTester visibility) { wi = new Vector (LightDir); pdf = 1.0; visibility.SetRay (p, pEpsilon, wi, time); return L; }
public override Spectrum SampleL(Scene scene, LightSample ls, double u1, double u2, double time, ref Ray ray, ref Normal Ns, ref double pdf) { Point org = ShapeSet.Sample (ls, ref Ns); Vector dir = MonteCarlo.UniformSampleSphere (u1, u2); if ((dir ^ Ns) < 0.0) dir *= -1.0; ray = new Ray (org, dir, 0.001, double.PositiveInfinity, time); pdf = ShapeSet.Pdf (org) * Util.InvTwoPi; Spectrum Ls = L (org, Ns, dir); return Ls; }
public override Spectrum SampleL(Point p, double pEpsilon, LightSample ls, double time, ref Vector wi, ref double pdf, ref VisibilityTester visibility) { Normal ns = new Normal (); Point ps = ShapeSet.Sample (p, ls, ref ns); wi = (ps - p).Normalized; pdf = ShapeSet.Pdf (p, wi); visibility.SetSegment (p, pEpsilon, ps, 0.001, time); Spectrum Ls = L (ps, ns, -wi); return Ls; }
public Point Sample(Point p, LightSample lightSample, ref Normal Ns) { double temp = 0.0; int sn = AreaDistribution.SampleDiscrete (lightSample.uComponent, ref temp); Point pt = Shapes[sn].Sample (p, lightSample.uPos[0], lightSample.uPos[1], ref Ns); // Find closest intersection of ray with shapes in _ShapeSet_ Ray r = new Ray (p, pt - p, 0.001, double.PositiveInfinity); double rayEps = 0.0, thit = 1.0; bool anyHit = false; DifferentialGeometry dg = new DifferentialGeometry (); foreach (IShape shape in Shapes) anyHit |= shape.Intersect (r, ref thit, ref rayEps, ref dg); if (anyHit) Ns = new Normal (dg.n); return r.Apply (thit); }
public override Spectrum SampleL(Scene scene, LightSample ls, double u1, double u2, double time, ref Ray ray, ref Normal Ns, ref double pdf) { // Choose point on disk oriented toward infinite light direction Point worldCenter; double worldRadius; scene.WorldBound.BoundingSphere (out worldCenter, out worldRadius); Vector v1, v2; Util.CoordinateSystem (LightDir, out v1, out v2); double d1 = 0.0, d2 = 0.0; MonteCarlo.ConcentricSampleDisk (ls.uPos[0], ls.uPos[1], ref d1, ref d2); Point Pdisk = worldCenter + worldRadius * (d1 * v1 + d2 * v2); // Set ray origin and direction for infinite light ray ray = new Ray (Pdisk + worldRadius * LightDir, -LightDir, 0.0, double.PositiveInfinity, time); Ns = new Normal (ray.Direction); pdf = 1.0 / (Util.Pi * worldRadius * worldRadius); return L; }
public Point Sample(LightSample lightSample, ref Normal Ns) { double temp = 0.0; int sn = AreaDistribution.SampleDiscrete (lightSample.uComponent, ref temp); return Shapes[sn].Sample (lightSample.uPos[0], lightSample.uPos[1], ref Ns); }
public abstract Spectrum SampleL(Scene scene, LightSample ls, double u1, double u2, double time, ref Ray ray, ref Normal Ns, ref double pdf);
public abstract Spectrum SampleL(Point p, double pEpsilon, LightSample ls, double time, ref Vector wi, ref double pdf, ref VisibilityTester visibility);