// Glossy Method Definitions BSDF *GlossyCombined::GetBSDF(MemoryArena &arena, const SpectrumWavelengths &sw, const Intersection &isect, const DifferentialGeometry &dgs) const { // Allocate _BSDF_ // NOTE - lordcrc - changed clamping to 0..1 to avoid >1 reflection SWCSpectrum d(Kd->Evaluate(sw, dgs).Clamp(0.f, 1.f)); SWCSpectrum s(Ks->Evaluate(sw, dgs)); float i = index->Evaluate(sw, dgs); if (i > 0.f) { const float ti = (i - 1.f) / (i + 1.f); s *= ti * ti; } s = s.Clamp(0.f, 1.f); SWCSpectrum a(Ka->Evaluate(sw, dgs).Clamp(0.f, 1.f)); // Clamp roughness values to avoid artifacts with too small values const float u = Clamp(nu->Evaluate(sw, dgs), 6e-3f, 1.f); const float v = Clamp(nv->Evaluate(sw, dgs), 6e-3f, 1.f); const float u2 = u * u; const float v2 = v * v; float ld = depth->Evaluate(sw, dgs); const float anisotropy = u2 < v2 ? 1.f - u2 / v2 : v2 / u2 - 1.f; SingleBSDF *bsdf = ARENA_ALLOC(arena, SingleBSDF)(dgs, isect.dg.nn, ARENA_ALLOC(arena, SchlickBRDF)(d, s, a, ld, u * v, anisotropy, multibounce), isect.exterior, isect.interior); // Add ptr to CompositingParams structure bsdf->SetCompositingParams(&compParams); return bsdf; }
// Glass Method Definitions BSDF *Null::GetBSDF(MemoryArena &arena, const SpectrumWavelengths &sw, const Intersection &isect, const DifferentialGeometry &dgShading) const { // Allocate _BSDF_, possibly doing bump-mapping with _bumpMap_ SingleBSDF *bsdf = ARENA_ALLOC(arena, SingleBSDF)(dgShading, isect.dg.nn, ARENA_ALLOC(arena, NullTransmission)(), isect.exterior, isect.interior); // Add ptr to CompositingParams structure bsdf->SetCompositingParams(&compParams); return bsdf; }
// Mirror Method Definitions BSDF *Mirror::GetBSDF(MemoryArena &arena, const SpectrumWavelengths &sw, const Intersection &isect, const DifferentialGeometry &dgs) const { // Allocate _BSDF_ float flm = film->Evaluate(sw, dgs); float flmindex = filmindex->Evaluate(sw, dgs); // NOTE - lordcrc - changed clamping to 0..1 to avoid >1 reflection SWCSpectrum R = Kr->Evaluate(sw, dgs).Clamp(0.f, 1.f); BxDF *bxdf = ARENA_ALLOC(arena, SpecularReflection)(R, ARENA_ALLOC(arena, FresnelNoOp)(), flm, flmindex); SingleBSDF *bsdf = ARENA_ALLOC(arena, SingleBSDF)(dgs, isect.dg.nn, bxdf, isect.exterior, isect.interior); // Add ptr to CompositingParams structure bsdf->SetCompositingParams(&compParams); return bsdf; }
// Matte Method Definitions BSDF *Matte::GetBSDF(MemoryArena &arena, const SpectrumWavelengths &sw, const Intersection &isect, const DifferentialGeometry &dgs) const { // Allocate _BSDF_ // Evaluate textures for _Matte_ material and allocate BRDF // NOTE - lordcrc - changed clamping to 0..1 to avoid >1 reflection SWCSpectrum r = Kd->Evaluate(sw, dgs).Clamp(0.f, 1.f); float sig = Clamp(sigma->Evaluate(sw, dgs), 0.f, 90.f); BxDF *bxdf; if (sig == 0.f) bxdf = ARENA_ALLOC(arena, Lambertian)(r); else bxdf = ARENA_ALLOC(arena, OrenNayar)(r, sig); SingleBSDF *bsdf = ARENA_ALLOC(arena, SingleBSDF)(dgs, isect.dg.nn, bxdf, isect.exterior, isect.interior); // Add ptr to CompositingParams structure bsdf->SetCompositingParams(&compParams); return bsdf; }
// Velvet Method Definitions BSDF *Velvet::GetBSDF(MemoryArena &arena, const SpectrumWavelengths &sw, const Intersection &isect, const DifferentialGeometry &dgs) const { // Allocate _BSDF_ SWCSpectrum r = Kd->Evaluate(sw, dgs).Clamp(0.f, 1.f); float p1 = Clamp(P1->Evaluate(sw, dgs), -100.f, 100.f); float p2 = Clamp(P2->Evaluate(sw, dgs), -100.f, 100.f); float p3 = Clamp(P3->Evaluate(sw, dgs), -100.f, 100.f); float thickness = Clamp(Thickness->Evaluate(sw, dgs), 0.0f, 1.f); BxDF *bxdf = ARENA_ALLOC(arena, Asperity)(r, p1, p2, p3, thickness); SingleBSDF *bsdf = ARENA_ALLOC(arena, SingleBSDF)(dgs, isect.dg.nn, bxdf, isect.exterior, isect.interior); // Add ptr to CompositingParams structure bsdf->SetCompositingParams(&compParams); return bsdf; }
BSDF *Metal2::GetBSDF(MemoryArena &arena, const SpectrumWavelengths &sw, const Intersection &isect, const DifferentialGeometry &dgs) const { // Allocate _BSDF_ float u = nu->Evaluate(sw, dgs); float v = nv->Evaluate(sw, dgs); const float u2 = u * u; const float v2 = v * v; const float anisotropy = u2 < v2 ? 1.f - u2 / v2 : v2 / u2 - 1.f; SchlickDistribution *md = ARENA_ALLOC(arena, SchlickDistribution)(u * v, anisotropy); FresnelGeneral *fr = ARENA_ALLOC(arena, FresnelGeneral)(fresnel->Evaluate(sw, dgs)); MicrofacetReflection *bxdf = ARENA_ALLOC(arena, MicrofacetReflection)(1.f, fr, md, false); SingleBSDF *bsdf = ARENA_ALLOC(arena, SingleBSDF)(dgs, isect.dg.nn, bxdf, isect.exterior, isect.interior); // Add ptr to CompositingParams structure bsdf->SetCompositingParams(&compParams); return bsdf; }