Ejemplo n.º 1
0
 public override Spectrum Power(Scene scene)
 {
     Point worldCenter;
     double worldRadius;
     scene.WorldBound.BoundingSphere (out worldCenter, out worldRadius);
     return L * Util.Pi * worldRadius * worldRadius;
 }
Ejemplo n.º 2
0
        public static Spectrum SpecularReflect(RayDifferential ray, BSDF bsdf, Intersection isect, IRenderer renderer, Scene scene, Sample sample)
        {
            Vector wo = -ray.Direction, wi = new Vector ();
            double pdf = 0.0;
            Point p = bsdf.dgShading.p;
            Normal n = bsdf.dgShading.n;

            Spectrum f = bsdf.SampleF (wo, ref wi, new BSDFSample (), ref pdf, BxDFType.BSDF_REFLECTION | BxDFType.BSDF_SPECULAR);
            Spectrum L = new Spectrum ();

            if (pdf > 0.0 && !f.IsBlack && Util.AbsDot (wi, n) != 0.0)
            {
                RayDifferential rd = new RayDifferential (p, wi, ray, isect.RayEpsilon);
                if (ray.HasDifferentials)
                {
                    rd.HasDifferentials = true;
                    rd.RxOrigin = p + isect.dg.dpdx;
                    rd.RyOrigin = p + isect.dg.dpdy;

                    Normal dndx = bsdf.dgShading.dndu * bsdf.dgShading.dudx + bsdf.dgShading.dndv * bsdf.dgShading.dvdx;
                    Normal dndy = bsdf.dgShading.dndu * bsdf.dgShading.dudy + bsdf.dgShading.dndv * bsdf.dgShading.dvdy;
                    Vector dwodx = -ray.RxDirection - wo, dwody = -ray.Direction - wo;
                    double dDNdx = (dwodx ^ n) + (wo ^ dndx);
                    double dDNdy = (dwody ^ n) + (wo ^ dndy);
                    rd.RxDirection = wi - dwodx + 2 * new Vector ((wo ^ n) * dndx + dDNdx * n);
                    rd.RyDirection = wi - dwody + 2 * new Vector ((wo ^ n) * dndy + dDNdy * n);
                }

                Spectrum Li = renderer.Li (scene, rd, sample);
                L = f * Li * Util.AbsDot (wi, n) / pdf;
            }

            return L;
        }
Ejemplo n.º 3
0
 public SamplerRendererTask(Scene scene, IRenderer renderer, ICamera camera, ProgressReporter reporter, ISampler sampler, Sample sample, int tn, int tc)
 {
     Scene = scene;
     Camera = camera;
     Renderer = renderer;
     MainSampler = sampler;
     OrigSample = sample;
     TaskNumber = tn;
     TaskCount = tc;
     Reporter = reporter;
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
        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;
        }
Ejemplo n.º 6
0
        public static Spectrum SpecularTransmit(RayDifferential ray, BSDF bsdf, Intersection isect, IRenderer renderer, Scene scene, Sample sample)
        {
            Vector wo = -ray.Direction, wi = new Vector ();
            double pdf = 0.0;
            Point p = bsdf.dgShading.p;
            Normal n = bsdf.dgShading.n;
            Spectrum f = bsdf.SampleF (wo, ref wi, new BSDFSample (), ref pdf, BxDFType.BSDF_TRANSMISSION | BxDFType.BSDF_SPECULAR);
            Spectrum L = new Spectrum ();

            if (pdf > 0.0 && !f.IsBlack && Util.AbsDot (wi, n) != 0.0)
            {
                RayDifferential rd = new RayDifferential (p, wi, ray, isect.RayEpsilon);
                if (ray.HasDifferentials)
                {
                    rd.HasDifferentials = true;
                    rd.RxOrigin = p + isect.dg.dpdx;
                    rd.RyOrigin = p + isect.dg.dpdy;

                    double eta = bsdf.Eta;
                    Vector w = -wo;

                    if ((wo ^ n) < 0.0)
                        eta = 1.0 / eta;

                    Normal dndx = bsdf.dgShading.dndu * bsdf.dgShading.dudx + bsdf.dgShading.dndv * bsdf.dgShading.dvdx;
                    Normal dndy = bsdf.dgShading.dndu * bsdf.dgShading.dudy + bsdf.dgShading.dndv * bsdf.dgShading.dvdy;

                    Vector dwodx = -ray.RxDirection - wo, dwody = -ray.RyDirection - wo;
                    double dDNdx = (dwodx ^ n) + (wo ^ dndx);
                    double dDNdy = (dwody ^ n) + (wo ^ dndy);
                    double mu = eta * (w ^ n) - (wi ^ n);
                    double dmudx = (eta - (eta * eta * (w ^ n)) / (wi ^ n)) * dDNdx;
                    double dmudy = (eta - (eta * eta * (w ^ n)) / (wi ^ n)) * dDNdy;

                    rd.RxDirection = wi + eta * dwodx - new Vector (mu * dndx + dmudx * n);
                    rd.RyDirection = wi + eta * dwody - new Vector (mu * dndy + dmudy * n);
                }

                Spectrum Li = renderer.Li (scene, rd, sample);
                L = f * Li * Util.AbsDot (wi, n) / pdf;
            }

            return L;
        }
Ejemplo n.º 7
0
        public override Spectrum Transmittance(Scene scene, IRenderer renderer, RayDifferential ray, Sample sample)
        {
            if (scene.VolumeRegion == null)
                return new Spectrum (1.0);

            double step, offset;
            if (sample != null)
            {
                step = StepSize;
                offset = sample.samples[sample.oneD + TauSampleOffset][0];
            }
            else
            {
                step = 4.0 * StepSize;
                offset = Util.Random.NextDouble ();
            }
            /*Spectrum tau = scene.VolumeRegion.Tau (ray, step, offset);
            return (-tau).Exp;*/
            return null;
        }
Ejemplo n.º 8
0
 public override Spectrum Power(Scene scene)
 {
     return Lemit * area * Util.Pi;
 }
Ejemplo n.º 9
0
 public override void RequestSamples(ISampler sampler, Sample sample, Scene scene)
 {
     TauSampleOffset = sample.Add1D (1);
     ScatterSampleOffset = sample.Add1D (1);
 }
Ejemplo n.º 10
0
 public override Spectrum Li(Scene scene, IRenderer renderer, RayDifferential ray, Sample sample, ref Spectrum transmittance)
 {
     transmittance = new Spectrum (1.0);
     return new Spectrum ();
 }