Fix #113728: fireflies in Principled Hair Huang with MIS #116088

Merged
Brecht Van Lommel merged 1 commits from weizhen/blender:fix-hair-firefly into main 2023-12-12 13:31:04 +01:00
2 changed files with 14 additions and 3 deletions

View File

@ -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. */

View File

@ -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 {