Cycles: new Microfacet-based Hair BSDF with elliptical cross-section support #105600

Merged
Weizhen Huang merged 114 commits from weizhen/blender:microfacet_hair into main 2023-08-18 12:46:20 +02:00
3 changed files with 7 additions and 15 deletions
Showing only changes of commit b47cc2aaa7 - Show all commits

View File

@ -3695,9 +3695,6 @@ NODE_DEFINE(MicrofacetHairBsdfNode)
SOCKET_IN_FLOAT(TT, "TT lobe", 1.0f);
SOCKET_IN_FLOAT(TRT, "TRT lobe", 1.0f);
SOCKET_IN_NORMAL(normal, "Normal", zero_float3(), SocketType::LINK_NORMAL);
SOCKET_IN_FLOAT(surface_mix_weight, "SurfaceMixWeight", 0.0f, SocketType::SVM_INTERNAL);
SOCKET_OUT_CLOSURE(BSDF, "BSDF");
return type;
@ -3708,21 +3705,20 @@ MicrofacetHairBsdfNode::MicrofacetHairBsdfNode() : BsdfBaseNode(get_node_type())
closure = CLOSURE_BSDF_HAIR_MICROFACET_ID;
}
/* Enable retrieving Hair Info -> Random if Random isn't linked. */
void MicrofacetHairBsdfNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
/* Make sure we have the normal for elliptical cross section tracking */
/* Make sure we have the normal for elliptical cross section tracking. */
if (aspect_ratio != 1.0f) {
attributes->add(ATTR_STD_VERTEX_NORMAL);
}
/* Enable retrieving Hair Info -> Random if Random isn't linked. */
if (!input("Random")->link) {
attributes->add(ATTR_STD_CURVE_RANDOM);
}
ShaderNode::attributes(shader, attributes);
}
/* Prepares the input data for the SVM shader. */
void MicrofacetHairBsdfNode::compile(SVMCompiler &compiler)
{
compiler.add_node(NODE_CLOSURE_SET_WEIGHT, one_float3());
@ -3748,7 +3744,6 @@ void MicrofacetHairBsdfNode::compile(SVMCompiler &compiler)
int roughness_ofs = compiler.stack_assign_if_linked(roughness_in);
int normal_ofs = compiler.stack_assign_if_linked(input("Normal"));
int offset_ofs = compiler.stack_assign_if_linked(offset_in);
int ior_ofs = compiler.stack_assign_if_linked(ior_in);
@ -3774,7 +3769,7 @@ void MicrofacetHairBsdfNode::compile(SVMCompiler &compiler)
__float_as_uint(random_roughness));
/* data node */
compiler.add_node(normal_ofs,
compiler.add_node(SVM_STACK_INVALID,
compiler.encode_uchar4(offset_ofs, ior_ofs, color_ofs, parametrization),
__float_as_uint(offset),
__float_as_uint(ior));
@ -3806,7 +3801,6 @@ void MicrofacetHairBsdfNode::compile(SVMCompiler &compiler)
__float_as_uint(TRT));
}
/* Prepares the input data for the OSL shader. */
void MicrofacetHairBsdfNode::compile(OSLCompiler &compiler)
{
compiler.parameter(this, "parametrization");

View File

@ -895,7 +895,6 @@ class MicrofacetHairBsdfNode : public BsdfBaseNode {
NODE_SOCKET_API(float, ior)
/* Cuticle tilt angle. */
NODE_SOCKET_API(float, offset)
/* Direct coloring's color. */
NODE_SOCKET_API(float3, color)
/* Melanin concentration. */
@ -908,16 +907,14 @@ class MicrofacetHairBsdfNode : public BsdfBaseNode {
NODE_SOCKET_API(float, random_color)
/* Absorption coefficient (unfiltered). */
NODE_SOCKET_API(float3, absorption_coefficient)
/* Aspect Ratio. */
NODE_SOCKET_API(float, aspect_ratio)
/* Optional modulation factors for the lobes. */
NODE_SOCKET_API(float, R)
NODE_SOCKET_API(float, TT)
NODE_SOCKET_API(float, TRT)
NODE_SOCKET_API(float3, normal)
NODE_SOCKET_API(float, surface_mix_weight)
/* If linked, here will be the given random number. */
NODE_SOCKET_API(float, random)
/* Selected coloring parametrization. */

View File

@ -42,8 +42,9 @@ static void node_declare(NodeDeclarationBuilder &b)
.subtype(PROP_FACTOR)
.description(
"For elliptical hair cross-section, the aspect ratio is the ratio of the minor axis to "
"the major axis. Recommended values are 0.8~1 for Asian hair, 0.65~0.9 for Caucasian "
"hair, 0.5~0.65 for African hair. Set this to 1 for circular cross-section");
"the major axis (the major axis is aligned with the curve normal). Recommended values "
"are 0.8~1 for Asian hair, 0.65~0.9 for Caucasian hair, 0.5~0.65 for African hair. Set "
"this to 1 for circular cross-section");
b.add_input<decl::Float>(N_("Roughness"), "Hair Roughness")
.default_value(0.3f)
.min(0.0f)