Cycles: Merge OSL Clearcoat closure into microfacet()
There's no reason why this would need to be its own closure, it was just a slightly different microfacet distribution with a hardcoded IOR and intensity multiplier internally. No functional change, just cleaning up the mess of custom OSL closures. Pull Request: https://projects.blender.org/blender/blender/pulls/109951
This commit is contained in:
committed by
Lukas Stockner
parent
89218b66c2
commit
56bc24aa9b
@@ -403,6 +403,10 @@ ccl_device void osl_closure_microfacet_setup(KernelGlobals kg,
|
||||
else if (closure->distribution == make_string("ashikhmin_shirley", 11318482998918370922ull)) {
|
||||
sd->flag |= bsdf_ashikhmin_shirley_setup(bsdf);
|
||||
}
|
||||
/* Clearcoat */
|
||||
else if (closure->distribution == make_string("clearcoat", 3490136178980547276ull)) {
|
||||
sd->flag |= bsdf_microfacet_ggx_clearcoat_setup(bsdf, sd);
|
||||
}
|
||||
/* GGX (either single- or multi-scattering) */
|
||||
else {
|
||||
if (closure->refract == 1) {
|
||||
@@ -645,30 +649,6 @@ ccl_device void osl_closure_principled_sheen_setup(
|
||||
sd->flag |= bsdf_principled_sheen_setup(sd, bsdf);
|
||||
}
|
||||
|
||||
ccl_device void osl_closure_principled_clearcoat_setup(
|
||||
KernelGlobals kg,
|
||||
ccl_private ShaderData *sd,
|
||||
uint32_t path_flag,
|
||||
float3 weight,
|
||||
ccl_private const PrincipledClearcoatClosure *closure)
|
||||
{
|
||||
weight *= 0.25f * closure->clearcoat;
|
||||
ccl_private MicrofacetBsdf *bsdf = (ccl_private MicrofacetBsdf *)bsdf_alloc(
|
||||
sd, sizeof(MicrofacetBsdf), rgb_to_spectrum(weight));
|
||||
if (!bsdf) {
|
||||
return;
|
||||
}
|
||||
|
||||
bsdf->N = ensure_valid_specular_reflection(sd->Ng, sd->wi, closure->N);
|
||||
bsdf->alpha_x = closure->clearcoat_roughness;
|
||||
bsdf->alpha_y = closure->clearcoat_roughness;
|
||||
bsdf->ior = 1.5f;
|
||||
|
||||
bsdf->T = zero_float3();
|
||||
|
||||
sd->flag |= bsdf_microfacet_ggx_clearcoat_setup(bsdf, sd);
|
||||
}
|
||||
|
||||
/* Variable cone emissive closure
|
||||
*
|
||||
* This primitive emits in a cone having a configurable penumbra area where the light decays to 0
|
||||
|
||||
@@ -136,12 +136,6 @@ OSL_CLOSURE_STRUCT_BEGIN(PrincipledSheen, principled_sheen)
|
||||
OSL_CLOSURE_STRUCT_MEMBER(PrincipledSheen, VECTOR, packed_float3, N, NULL)
|
||||
OSL_CLOSURE_STRUCT_END(PrincipledSheen, principled_sheen)
|
||||
|
||||
OSL_CLOSURE_STRUCT_BEGIN(PrincipledClearcoat, principled_clearcoat)
|
||||
OSL_CLOSURE_STRUCT_MEMBER(PrincipledClearcoat, VECTOR, packed_float3, N, NULL)
|
||||
OSL_CLOSURE_STRUCT_MEMBER(PrincipledClearcoat, FLOAT, float, clearcoat, NULL)
|
||||
OSL_CLOSURE_STRUCT_MEMBER(PrincipledClearcoat, FLOAT, float, clearcoat_roughness, NULL)
|
||||
OSL_CLOSURE_STRUCT_END(PrincipledClearcoat, principled_clearcoat)
|
||||
|
||||
OSL_CLOSURE_STRUCT_BEGIN(GenericEmissive, emission)
|
||||
OSL_CLOSURE_STRUCT_END(GenericEmissive, emission)
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ shader node_principled_bsdf(string distribution = "multi_ggx",
|
||||
}
|
||||
|
||||
if (Clearcoat > 1e-5) {
|
||||
BSDF += principled_clearcoat(
|
||||
ClearcoatNormal, Clearcoat, ClearcoatRoughness * ClearcoatRoughness);
|
||||
float clearcoat_r2 = ClearcoatRoughness * ClearcoatRoughness;
|
||||
BSDF += 0.25 * Clearcoat * microfacet("clearcoat", ClearcoatNormal, clearcoat_r2, 1.5, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ closure color ashikhmin_velvet(normal N, float sigma) BUILTIN;
|
||||
closure color ambient_occlusion() BUILTIN;
|
||||
closure color principled_diffuse(normal N, float roughness) BUILTIN;
|
||||
closure color principled_sheen(normal N) BUILTIN;
|
||||
closure color principled_clearcoat(normal N, float clearcoat, float clearcoat_roughness) BUILTIN;
|
||||
|
||||
/* Needed to pass along the color for multi-scattering saturation adjustment,
|
||||
* otherwise could be replaced by microfacet() */
|
||||
|
||||
Reference in New Issue
Block a user