diff --git a/intern/cycles/scene/shader_nodes.cpp b/intern/cycles/scene/shader_nodes.cpp index a04b4c5a1ff..304eab9ddbe 100644 --- a/intern/cycles/scene/shader_nodes.cpp +++ b/intern/cycles/scene/shader_nodes.cpp @@ -3372,14 +3372,23 @@ PrincipledHairBsdfNode::PrincipledHairBsdfNode() : BsdfBaseNode(get_node_type()) closure = CLOSURE_BSDF_HAIR_HUANG_ID; } -void PrincipledHairBsdfNode::attributes(Shader *shader, AttributeRequestSet *attributes) +/* Treat hair as transparent if the hit is outside of the projected width. */ +bool PrincipledHairBsdfNode::has_surface_transparent() { if (model == NODE_PRINCIPLED_HAIR_HUANG) { - /* Make sure we have the normal for elliptical cross section tracking. */ if (aspect_ratio != 1.0f || input("Aspect Ratio")->link) { - attributes->add(ATTR_STD_VERTEX_NORMAL); + return true; } } + return false; +} + +void PrincipledHairBsdfNode::attributes(Shader *shader, AttributeRequestSet *attributes) +{ + if (has_surface_transparent()) { + /* Make sure we have the normal for elliptical cross section tracking. */ + attributes->add(ATTR_STD_VERTEX_NORMAL); + } if (!input("Random")->link) { /* Enable retrieving Hair Info -> Random if Random isn't linked. */ diff --git a/intern/cycles/scene/shader_nodes.h b/intern/cycles/scene/shader_nodes.h index c5643c2166a..cd437d3f885 100644 --- a/intern/cycles/scene/shader_nodes.h +++ b/intern/cycles/scene/shader_nodes.h @@ -851,6 +851,8 @@ class PrincipledHairBsdfNode : public BsdfBaseNode { { return ShaderNode::get_feature() | KERNEL_FEATURE_NODE_PRINCIPLED_HAIR; } + + bool has_surface_transparent(); }; class HairBsdfNode : public BsdfNode {