Gamma Space skin shader development.

Developer : JPLeeEmail :

Website :


Recently, most of them are developed in a linear space.
But in some cases … for example, you might develop a game that runs on very old hardware.
If linear space conversion is not supported in hardware, it must be efficiently implemented inside the shader.
After a long time, I developed a skin shader in a situation similar to the development environment before 2016.
The entire project is a gamma space.

Texture Channel information.

Albedo with Roughness
Albedo uses an RGB channel, and roughness for expressing light is an alpha channel.

Albedo RGB

Roughness A
A roughness texture stored in the channel.The closer it is to white, the less glossy it is.The closer it is to black, the stronger the amount of gloss.This was converted directly into Linear Space inside the shader.

Normal map.

If you see this screen in the editor edit screen, you need to ignore it.
I have to follow the rules for the UnpackNormal function of the shader I created.
Normal Map uses a total of two types, but it is stored in a single texture.
One texture is stored in the RG (xy) of the texture, and another one is stored in the BA (xy) channel.Each z value is calculated directly from the shader as
sqrt(1 – saturate(dot(normal.xy, normal.xy)))

Surface normal.
Surface normal.
Scattered Normal
Scattered Normal
The above two normal maps are stored in the RGBA channel.
It does not use Unity’s NormalMap encoding method.
Texture Type is Default
sRGB (Color Texture) is Off

Shader Map.
It is an important texture in skin expression.

Information on the curvature of the skin or the transmission weight of the face is stored in the R channel.
Occlusion information for light is recorded on the G channel.
In my shader, I used G channel information in addition to the Occlusion effect, so I saved it in the Shader map.

LUT texture management.

Wrap Mode must be Clamp.
Format should be RGB24.

This is the texture that records the standard Diffusion profile information for the skin.

I think the final texture size is 512 * 512.
This texture should not be compressed.
If it is due to Memory bandwith, it can sometimes be slow on old hardware.
In particular, there was a problem with Xiaomi products using Qualcomm GPUs (released in 2015).
In that case, reduce the size to 256.

Material Descriptions.

Roughness with Reflection
Multiply the Roughness texture and Roghness variable values to express the glossiness of the skin surface.Reflection creates a reflected light effect.This is linked to the final Roughness expression.The above two values are greatly influenced by Tone Mapper.

For skin expression, we need to calculate SkinBRDF.Default is on.

Skin Brdf Attenuation
Skin Brdf Attenuation slightly obscures the shadow boundary and the skin boundary.Default is on.The reason for implementing this feature is that Soft Shadow cannot be used in mobile rendering, and if you need to use Soft Shadow, you must implement your own shadow.If you can’t implement shadows yourself, it’s best to use this feature as much as possible to blur the boundaries between the shadow and skin areas.This can be modified with the Skin Tone Scale and BRDF Attenuation values.You need to find a suitable range for both values.

Skin Brdf Attenuation off.
Skin Brdf Attenuation on.

Skin Tone Color
It is the Scattering color of the skin.

Skin Trans Map
The R channel is used as a depth value for skin scattering.The G channel is used for the Occlusion effect.See ShaderMap for information on texture information.

BackLight Dir
It is a fake lighting direction.This is for skin penetration effect only.

Indirect lighting was added without using auxiliary light.It creates a lighting effect from the side.You can turn it on or off and modify the intensity with Lighting Intensity.On a mobile screen, if the gloss is strong, it tends to look whiter than the original color.Therefore, it is not desirable to give Lighting Intensity too strong.

not used SubLighting.
Use SubLighting.

Assuming that no post-processing is used, Tone mapping is implemented and applied directly inside the shader.When rendering in Gamma space, the most noticeable part is that the specular part of the light is finally calculated in the gamma space, resulting in the feeling that the skin color is displaced.This is to remove the characteristics of Gamma space as much as possible using TONE MAPPER.

Before applying tone mapping.
After applying the tone mapping default.

For example, the values applied to the following results.

Comparing between before tone mapped and after tone mapped.

It was developed under the condition that no post-treatment is used.
Tone mapping algorithm is implemented and applied inside the shader with reference to the Hable Filmic curve.

before tone mapped
after tone mapped

When modifying the tone mapper, you need to modify the roughness together to reach the final result.

See below for initial values.

Segment A = 0.2
Segment B = 0.29
Segment C = 0.24
Segment D = 0.272
Segment E = 0.02
Segment F = 0.3
White Level = 2.3

The final rendering result of the skin is determined by TONE MAPPER.Let’s modify the Segment F value from Segment D and modify the White Level to create the final rendering result.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s