Hair shading BSDF method switch

We’ve updated the HairShading() BSDF function (HairBSDF.ush) to enhance our furry character rendering. The results look great, but the change creates backward compatibility issues for assets relying on the original method.

Is there a clean way to toggle the shading method per material, perhaps via a Material ID or another approach?

I saw that HairShading is called several times from different files, and I find no way to do that.

Best regards

[Attachment Removed]

Hi,

I believe what you could do is using CustomData.w has a descriminant to run either the HairShading() or HairShadingRef()

if (GBuffer.CustomData.w > 0)
{
  return HairShadingRef(...);
}

Walking this backward, you will need to update:

HairSampleToGBufferData() in Engine\Shaders\Private\HairStrands\HairStrandsVisibilityUtils.ush:

Out.CustomData.w = HasHairFlags(In.Flags, HAIR_FLAGS_REF_SHADING) ? 1u : 0u;You will need to add this into HairStrandsDefinitions.h

#define HAIR_FLAGS_REF_SHADING 0x20uThen you can add a bUseRefShading in FHairGroupDesc inEngine\Plugins\Runtime\HairStrands\Source\HairStrandsCore\Public\GroomDesc.h, and follow the pattern used by bScatterSceneLighting for pipping that data through.

This will expose a UseRefShading variable to the groom asset/groom instance, allowing you to toggle where/when needed.

I hope that makes sense.

/Charles.

[Attachment Removed]