# Hair shader calling with wrong arguments?

**URL:** <https://forums.unrealengine.com/t/hair-shader-calling-with-wrong-arguments/377101>\
**Category:** Rendering\
**Tags:** unreal-engine, Shaders, question\
**Created:** [November 22, 2016, 2:16pm UTC](https://forums.unrealengine.com/t/hair-shader-calling-with-wrong-arguments/377101 "2016-11-22T14:16:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![c4tnt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@c4tnt](https://forums.unrealengine.com/u/c4tnt)\
**Post date:** [November 22, 2016, 2:16pm UTC](https://forums.unrealengine.com/t/hair-shader-calling-with-wrong-arguments/377101/1 "2016-11-22T14:16:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [November 22, 2016, 7:47pm UTC](https://forums.unrealengine.com/t/hair-shader-calling-with-wrong-arguments/377101/2 "2016-11-22T19:47:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![c4tnt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@c4tnt](https://forums.unrealengine.com/u/c4tnt)\
**Post date:** [November 23, 2016, 2:30pm UTC](https://forums.unrealengine.com/t/hair-shader-calling-with-wrong-arguments/377101/3 "2016-11-23T14:30:09Z")

</div>

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/0/9/b096c76f5d23101bb726d301426cc8756eef321c.png)

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

![116091-screenshot_2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/0/0/70088befa9990926cb362c69fcbb7fc311fbad03.png)

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0c62419a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0c62419a](https://forums.unrealengine.com/u/anonymous_user_0c62419a)\
**Post date:** [November 25, 2016, 5:49pm UTC](https://forums.unrealengine.com/t/hair-shader-calling-with-wrong-arguments/377101/4 "2016-11-25T17:49:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![c4tnt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@c4tnt](https://forums.unrealengine.com/u/c4tnt)\
**Post date:** [November 26, 2016, 12:38am UTC](https://forums.unrealengine.com/t/hair-shader-calling-with-wrong-arguments/377101/5 "2016-11-26T00:38:22Z")

</div>

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

![116418-screenshot_4.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/3/5/f35ce47eb72b954b0e71f16b67ef4ad33b48b701.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0c62419a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0c62419a](https://forums.unrealengine.com/u/anonymous_user_0c62419a)\
**Post date:** [November 28, 2016, 8:08pm UTC](https://forums.unrealengine.com/t/hair-shader-calling-with-wrong-arguments/377101/6 "2016-11-28T20:08:16Z")

</div>

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

 ![116683-hair.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/a/f/6af12b6255555e4e8047576b857df68399262412.jpeg)

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.

---

<div class="post-metadata">

**Author:** ![c4tnt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@c4tnt](https://forums.unrealengine.com/u/c4tnt)\
**Post date:** [November 30, 2016, 5:05pm UTC](https://forums.unrealengine.com/t/hair-shader-calling-with-wrong-arguments/377101/7 "2016-11-30T17:05:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0c62419a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0c62419a](https://forums.unrealengine.com/u/anonymous_user_0c62419a)\
**Post date:** [December 2, 2016, 6:27pm UTC](https://forums.unrealengine.com/t/hair-shader-calling-with-wrong-arguments/377101/8 "2016-12-02T18:27:47Z")

</div>

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)](https://issues.unrealengine.com/issue/UE-39061)

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

,

Ed
