Cycles: Sheen BSDF compatibility for MaterialX
Pull Request: https://projects.blender.org/blender/blender/pulls/133797
This commit is contained in:
@@ -719,6 +719,40 @@ ccl_device void osl_closure_sheen_setup(KernelGlobals kg,
|
||||
}
|
||||
}
|
||||
|
||||
/* MaterialX compatibility */
|
||||
ccl_device void osl_closure_sheen_bsdf_setup(KernelGlobals kg,
|
||||
ccl_private ShaderData *sd,
|
||||
const uint32_t path_flag,
|
||||
const float3 weight,
|
||||
const ccl_private SheenBSDFClosure *closure,
|
||||
float3 *layer_albedo)
|
||||
{
|
||||
osl_zero_albedo(layer_albedo);
|
||||
|
||||
if (osl_closure_skip(kg, sd, path_flag, LABEL_DIFFUSE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ccl_private SheenBsdf *bsdf = (ccl_private SheenBsdf *)bsdf_alloc(
|
||||
sd, sizeof(SheenBsdf), rgb_to_spectrum(weight * closure->albedo));
|
||||
if (!bsdf) {
|
||||
return;
|
||||
}
|
||||
|
||||
bsdf->N = safe_normalize_fallback(closure->N, sd->N);
|
||||
bsdf->roughness = closure->roughness;
|
||||
|
||||
const int sheen_flag = bsdf_sheen_setup(kg, sd, bsdf);
|
||||
|
||||
if (sheen_flag) {
|
||||
sd->flag |= sheen_flag;
|
||||
|
||||
if (layer_albedo != nullptr) {
|
||||
*layer_albedo = bsdf->weight * closure->albedo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ccl_device void osl_closure_diffuse_toon_setup(KernelGlobals kg,
|
||||
ccl_private ShaderData *sd,
|
||||
const uint32_t path_flag,
|
||||
|
||||
@@ -138,6 +138,12 @@ OSL_CLOSURE_STRUCT_BEGIN(Sheen, sheen)
|
||||
OSL_CLOSURE_STRUCT_MEMBER(Sheen, FLOAT, float, roughness, nullptr)
|
||||
OSL_CLOSURE_STRUCT_END(Sheen, sheen)
|
||||
|
||||
OSL_CLOSURE_STRUCT_BEGIN(SheenBSDF, sheen_bsdf)
|
||||
OSL_CLOSURE_STRUCT_MEMBER(SheenBSDF, VECTOR, packed_float3, N, nullptr)
|
||||
OSL_CLOSURE_STRUCT_MEMBER(SheenBSDF, VECTOR, packed_float3, albedo, nullptr)
|
||||
OSL_CLOSURE_STRUCT_MEMBER(SheenBSDF, FLOAT, float, roughness, nullptr)
|
||||
OSL_CLOSURE_STRUCT_END(SheenBSDF, sheen_bsdf)
|
||||
|
||||
OSL_CLOSURE_STRUCT_BEGIN(DiffuseToon, diffuse_toon)
|
||||
OSL_CLOSURE_STRUCT_MEMBER(DiffuseToon, VECTOR, packed_float3, N, nullptr)
|
||||
OSL_CLOSURE_STRUCT_MEMBER(DiffuseToon, FLOAT, float, size, nullptr)
|
||||
|
||||
Reference in New Issue
Block a user