예제 #1
0
 public override IRadianceEvaluation Sample(ref Vector wo, ref IRadianceEvaluation radiance, float u0, float u1, float u2,
     out BsdfSample result, BrdfType flags = BrdfType.All)
 {
     result = new BsdfSample()
     {
         
     }; 
     throw new NotImplementedException();
 }
예제 #2
0
        public override void F(ShadePointInfo pt, out IColorType fs, BrdfType types = BrdfType.Diffuse)
        {
            float c = 1f - Vector.Dot(ref pt.IncomingDirection, ref pt.ShadingNormal);
            float Re = R0 + (1f - R0) * c * c * c * c * c;

            float P = .25f + .5f * Re;

            fs = pt.Diffuse.CloneValue().Mul(MathLab.INVPI).Mul((1f - Re) / (1f - P));
        }
예제 #3
0
        public IRadianceEvaluation Sample(ref Vector wo, ref IRadianceEvaluation radiance, float u0, float u1, float u2, out BsdfSample result, BrdfType flags = BrdfType.All)
        {
            float selPdf;
            BaseBsdf bxdf = GetBsdf(out selPdf, flags);
            
            if (bxdf == null)
            {
                result = new BsdfSample();
                return ColorManager.Instance.ZeroRadiance();
            }

            Vector wo1 = bxdf.WorldToLocal(ref wo);

            var r = bxdf.Sample(ref wo1, ref radiance, u0, u1, u2, out result, flags);
            result.DirectPdf *= selPdf;
            result.OutgoingDirection = bxdf.LocalToWorld(ref result.OutgoingDirection);
            return r;
            /*Vector wi = new Vector();
            var wiW = Vector.Zero;
            var pdf = 0f;
            bool specularBounce;
            if (pdf > 0f && pdf < MathLab.Epsilon) return ColorManager.Instance.ZeroRadiance();

            if (flags != BrdfType.All ) flags = bxdf.Type;
            wiW = bxdf.LocalToWorld(ref wi);
            if ((!bxdf.Type.Has(BrdfType.Specular)) && matchingComps > 1)
            {
                for (int i = 0; i < bxdfs.Count; ++i)
                {
                    if (bxdfs[i] != bxdf &&bxdfs[i].Type.Has(flags))
                        pdf += bxdfs[i].Pdf(scene, ref wo);
                }
            }
            if (matchingComps > 1) pdf /= matchingComps;
            if (bxdf.Type.Has(BrdfType.Specular))
            {
                var f = ColorManager.Instance.ZeroRadiance();
                if ((Vector.Dot(ref wiW , ref bxdf.Ng)) * Vector.Dot(ref wo1 ,ref  bxdf.Ng) > 0f)
                // ignore BTDFs
                {
                    flags = flags & ~BrdfType.Refractive;
                }
                else
                    // ignore BRDFs
                    flags = flags & ~BrdfType.Reflection;
                float cosp, rwp;
                for (int i = 0; i < bxdfs.Count; ++i)
                    if (bxdfs[i].Type.Has(flags))
                        f.Add(bxdfs[i].Evaluate(scene, ref wo, Vector.Dot(ref wiW, ref bxdf.Ng), out cosp, out rwp));

                f.Div(pdf);
            }
            return f;*/
        }
예제 #4
0
 public static bool Has(BrdfType val, BrdfType f)
 {
     //return val.HasFlag(f);
     return ((uint)val & (uint)f).Equals((uint)f);
 }
예제 #5
0
        public void f(ref Vector lwo, ref Vector lwi, ref Normal N, ref RgbSpectrum in_fs, out RgbSpectrum fs, BrdfType types = BrdfType.Diffuse)
        {
            this.CreateFrame(ref N);
            var wo = this.WorldToLocal(ref lwo);
            var wi = this.WorldToLocal(ref lwi);
            if (brdfs.Length == 1)
            {
                if (brdfs[0].IsSpecular())
                {
                    fs = new RgbSpectrum(0f);
                }
                else
                    brdfs[0].f(ref wo, ref wi, ref N, out fs);
                return;
            }

            var res = new RgbSpectrum();
            fs = new RgbSpectrum();
            foreach (var surfaceBsdf in brdfs)
            {
                if (surfaceBsdf.Type.HasFlag(types))
                {
                    surfaceBsdf.f(ref wo, ref wi, ref N, out res);
                    fs += res;
                }
            }
        }
예제 #6
0
 public override void F(ShadePointInfo pt, out IColorType fs, BrdfType types = BrdfType.Diffuse)
 {
     throw new NotImplementedException();
 }
예제 #7
0
파일: Brdf.cs 프로젝트: HungryBear/rayden
 public abstract void F(ShadePointInfo pt, out IColorType fs, BrdfType types = BrdfType.Diffuse);
예제 #8
0
 private BaseBsdf GetBsdf(out float pdf, BrdfType flags = BrdfType.All)
 {
     int matchingComps = 0;
     BaseBsdf b = null;
     foreach (var baseBsdf in bxdfs)
     {
         if (BaseBsdf.Has(baseBsdf.Type, flags))
         {
             if (b == null)
                 b = baseBsdf;
             matchingComps++;
         }
     }
     pdf = 1f / matchingComps;
     return b;
 }
예제 #9
0
 public void f(ref Vector wo, ref Vector wi, ref Normal N, ref RgbSpectrum in_fs, out RgbSpectrum fs, BrdfType types = BrdfType.Diffuse)
 {
     throw new NotImplementedException();
 }
예제 #10
0
 public override void F(ShadePointInfo pt, out IColorType fs, BrdfType types = BrdfType.Diffuse)
 {
     fs = pt.Diffuse.Mul(MathLab.INVPI);
 }
예제 #11
0
 public static bool Has(this BrdfType val, BrdfType f)
 {
     //return val.HasFlag(f);
     return ((byte)val & (byte)f).Equals((byte)f);
 }