Hair shader calling with wrong arguments?

I’ve discovered that hair material output ‘backlit’ is broken, and actual shader always gets 1 as backlit argument

float3 SubsurfaceShading( FGBufferData GBuffer, float3 L, float3 V, half3 N, float Shadow, uint2 Random )
{
	float3 SubsurfaceColor = ExtractSubsurfaceColor(GBuffer);

	switch( GBuffer.ShadingModelID )
	{
		...
		case SHADINGMODELID_HAIR:
			return HairShading( GBuffer, L, V, N, Shadow, 1\*Backlit should be here*\, 0, Random );

Is there any way to fix this without updating?

Hey c4tnt-

Where is this code coming from? Can you provide information on how you’re using this code? If you’re able to reproduce this problem in a new project, please also include the reproduction steps to help me test the issue locally.

I took this code from “4.xx\Engine\Shaders\ShadingModels.usf”. To reproduce bug you have to create a material with hair shading type. This material have output called “backlit”, but this output makes no effect on the rendered image.
I have tested a bit this issue:
There is a render with default hair shader (backlit hardcoded to 1)

116060-screenshot_3.png

There is a render when I changed backlit value to 0 directly in the shader file

116091-screenshot_2.png

But when I trying to set backlit value in the material nothing changes

Hi c4int,

What are you trying to achieve? If you are trying to get better results with your characters hair you should be able to leave the backlighting value at 1 in the code.

I would recommend using the same material setup for the hair that is provided in the content examples. Once you have tried this let me know how the results turn out and I will continue to help you get the look that you want.

,

Ed

I’ve tried to use this one material, but unfortunately it’s glowing too

116418-screenshot_4.png

The content examples shouldn’t look like that. I downloaded 4.13 content examples and took a screenshot from that vantage point.

If you haven’t made any changes to the shader and are with default project settings something else is going on here.

Please make sure that your settings are all default and nothing was touched. If the hair shader still glows for you I will continue.

for tour attention. I updated to last 4.13.2 version and found that hair shader lighting model was changed:

Old:
		float Np = exp( (Phi - PI) / s ) / ( s * Pow2( 1 + exp( (Phi - PI) / s ) ) );

New:
		float Np = 0.83 * exp( -2.2 * Pow2(Phi - PI) );

Now it looks better, but I played with backlit in the content example hairs and it still seems broken - nothing changes when I change backlit from -1.0 to 1.0 and even -1000.0 to 1000.0

Hi c4tnt,

I’ve filled a bug report that is related to this post. I also added what you mentioned in a private comment to the devs. The only thing that seems to influence back lighting is the dynamic shadow distance on a directional light.

This may be a bug and is being looked into. Here is the link: Unreal Engine Issues and Bug Tracker (UE-39061)

Keep in mind this issue may bot be prioritized or addressed right away.

,

Ed