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(); }
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;*/ }
public float Phase(ref Vector wi, ref Vector wo, IRadianceEvaluation lambda) { switch (PhaseType) { case PhaseFunctionTypes.Isotropic: default: return PhaseFunctions.PhaseIsotropic(ref wi, ref wo); case PhaseFunctionTypes.HeyneyGreenstein: return PhaseFunctions.PhaseHG(ref wi, ref wo, 0.5f); } }