# How can i have a softer Skin using BRDF

This topic is 1293 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi,

i implemented physically based shading, using the Cook Torrance BRDF Equation, with Trowbridge Reitz GGX for Normal Distribution, the Smith Schlick GGX for Geometric Shadowing, Schlick Approximation for Fresnel and for diffuse, Lambert.

All is working in Linear Space with pow(2.33) on Input and pow(0.4545) on output, and it looks good.

But the problem i have is for skin :

[attachment=22294:Skin harsh.jpg]

The falloff is too harsh, good for general objects, but the skin should look softer.

And it looks like cell shading...

So how can i make it softer like this :

##### Share on other sites

Why aren't you taking advantage of gamma corrected texture reads / back buffers?

Cheers!

##### Share on other sites
I think I accidentally down voted someone in this post. Tablet jumping around.

##### Share on other sites

@Promit Yes, the falloff is very harsh, and without specular too (it stay the same). Do you know another diffuse equation i can use to have something softer ?

@kauna It's because Unity Free have his inputs in Gamma Space, so i had to manually correct the gamma in shaders.

I will try Sub Surface Scaterring, but i cant' use a method in Screen Space or anything which needs a rendertexture : in free version, rendertexture are very expensive.

So i'll try the Pre-Integrated Skin Shading but i have some questions :

if i understood well, i need my usual textures :

- Albedo, Normal map, Specular Map, Gloss Map

and

- Curvature Map (Baked from the mesh) and BRDF look up

So this method only affect diffuse calculations right ?

I can keep my Cook Torrance Specular, i just have to modify classic Diffuse Lambert to add SSS ?

##### Share on other sites
Will sub-surface scattering necessarily help the falloff though? You can however get good skin results with nice ambient occlusion, SSS, a subtle texture map, and a decent normal map.

##### Share on other sites

@Promit Yes, the falloff is very harsh, and without specular too (it stay the same). Do you know another diffuse equation i can use to have something softer ?
At risk of revealing my mountain man situation of being trapped on mobile ... I just like gamma space half lambert, as described in the HL2 slides.
	float ndotl = dot(N, L1);
//compute half lambert term
ndotl = (ndotl * 0.5) + 0.5;
ndotl *= ndotl;
ndotl = clamp(ndotl, 0.0, 1.0);



##### Share on other sites

I tested your half lambert, but the problem is the lighting looks flat : the falloff is very large, so it looks incorrect, especially with shadows.

I tried to downscale the normal map, and the result is a little softer, but it's still very harsh.

[attachment=22313:Image based Lighting Woman Harsh 2.jpg]

I'll try pre integrated sss too.

Someone knows where i can download the head scan all people use ? The Infinite site is down :(

##### Share on other sites

So this method only affect diffuse calculations right ?

Yes. Current sub-surface scattering techniques only address diffuse reflectance, so you can leave specular alone.

Will sub-surface scattering necessarily help the falloff though?

Absolutely. Take a look at this image from Eric Penner's slides:

[attachment=22314:SSS.PNG]

Notice how the falloff becomes much softer as curvature increases.

##### Share on other sites

Are you using self shadowing in these screenshots?

##### Share on other sites

Hi,

Now, i implemented Pre Integrated SSS, so i use curvature and BRDF lookup but i have a new problem :

the SSS have ugly artifacts, and i don't know why. I tried to use a smaller mip map but it doesn't resolve the problem.

You can see the SSS is pretty hard, with a "polygon" look.

After that, i tried to do a pow(2.2) on the lookupsample, and there is less artifacts but it's incorrect(the falloff is not linear).

I also have some banding.

##### Share on other sites

The look-up table is data, not imagery, and should not be “converted” to any spaces (including linear).

It would appear that you have a problem with normals.  How does the model render normally?

L. Spiro

##### Share on other sites

Looks to me like your curvature map is simply rubbish.

##### Share on other sites

It's not a problem of normal :

Normals are ok.

And about the curvature, i calculate it dynamically using :

length( fwidth(WorldNormal)  ) / length( fwidth (worldPos ) );

I'm manually correcting gamma by doing pow(2.2) on input (Albedo) and pow(1/2.2) on output.

When i remove this (so without gamma correction) it looks like it should (but its in gamma).

So i found a compromise which is i do gamma correction AFTER brdf calculations.

So the code looks like this :

half3 falbedo = tex2D(_MainTex,uv);
float ndotl = dot(s.blurNormal,lightDir);
lookUpPos.x = ndotl * 0.5 + 0.5;
lookUpPos.y = curvature * lightIntensity;
float3 dif = tex2D (_BRDFLookUp, lookUpPos).xyz;
fAlbedo*=dif;
float3 final = (pow(fAlbedo,2.2) + spec) * _LightColor0.rgb * (attenuation * 2);
return float4(final,1);



I know that it's not correct but i found nothing else.

Edited by toto5100

##### Share on other sites

If you calculate your curvature map using screen space derivatives of lerped normals then it is only to be expected that the curvature values are constant over individual polygons. Normalizing your normals beforehand could help a bit, I'm not sure how much though.

EDIT: Ok, the prob is that you have to consider the change in position too, which is constant over triangles anyways.

Edited by Tasty Texel

##### Share on other sites

When i do :

length( fwidth(normalize(WorldNormal) )  ) / length( fwidth (worldPos ) );

it changes nothing.

Also, i'm using Unity's Surface Shaders, which compute normals automatically. Normal map is also taken in account.

I don't know how can i smooth them. It's also strange that the SSS effect works well when i do BRDF before gamma correction and looks ugly when i do gamma correction on input.

PS : You think Cook Torrance with GGX is good for skin specular or i should move to Kelemen/Szirmay-Kalos ?

Edited by toto5100

##### Share on other sites

In my experience you really need to use curvature maps for the pre-integrated shading. The trick with using derivatives and clever and might work for certain simple scenarios, but the fact it has discontinuities across triangle edges is pretty much a deal-breaker for faces.

##### Share on other sites

@MJP: Do you use a single curvature map regardless of facial animations?