/Next-Generation-Character-Rendering

My research and attempt for character rendering, including hair、eyes and face in unity URP.(Won't upload any resources, only share shaders and algorithm)

Primary LanguageHLSLMIT LicenseMIT

Next-Generation-Character-Rendering

My research and attempt for character rendering, including hair、eyes and face in unity URP.(Won't upload any resources, only share shaders and ideas).

whole3

whole6

Hair

Due to the hair is rendered as transparent material, I use two layer materials, one rendered as opaque object, the other rendered as normal transparent hair.

And in order to solve the transparent sorting problem, I used Weighted Blended OIT method, but I found just ask the artist to merge the hair layers to just one model, can easily solve this question.

Another problem is the opaque layer will cause jaggies, so I use TAA to solve this.

image

Detail

I just use Kajiya-Kay Shading Model, it already shows a good look.The key to calclate the Kajiya-Kay specular is to replace the normal by tangent, then to calculate specular.

The most important part is about the uv and tangent space, for the hair patch, the tangent(in tangent space) is along with the U direction, so we can shift the specular based on this feature, and do the specular calculation.

For Strand-based anisotropic lighting, hair is a lot of wires, each is rendered as cylinder:

image

The correct way to calculate specular is the integral of (N · H), but it is too heave. Consider the tangent direction, Tangent、normal、Half Vector can be placed in a plane, and the angle is 90 degrees.

image

So we can replace the (N · H) by T and H:

image

Then just use this to calculate specular, we can get the circular specular and change with the view and light direction.

And in real world, the specular should have two layers, one with color and the other has no color, and should be shifted a little to show something like jaggies.

image

The theory behind is shift T by Normal, T + shift * Normal means scale and rotate the T:

IMG_20220807_181200_edit_433170275539632

With the projected length changed the specular position also changing.

The anisotopic map:

image

Face

To implement pre-integration and Separable Subsurface Scattering algorithm.(pre-integration is done)

Key:

(SSS + Diffuse) + Dual lobe specular + Transmittance

Diffuse calculation just use normal PBR calculation. The key is SSS and specular.

Classic Multilayer skin structure:

image

pre-integration:

Screenshot 2022-07-20 181356

The distance between light incident point and exit point can't be ignored. So we should use BSSRDF to replace BRDF. Through my study, when you try pre-integration algorithm, you can directly get sss result from a look-up table, the diffuse should be the sum of normal diffuse and sss, you can regard the diffuse that we calculate earlier by the Microfacet BRDF as a special case of subsurface scattering.

How to calculate curvature:

image

Face1

Specular

Kelemen/Szirmay-Kalos specular BRDF:

Face5

In skin layer structure, there will be multiple layers contributing to the specular, I use for reference the Dual lobe Specular in UE4 Digital Human. Use different roughness to calculate specular then mix by a certain proportion:

Mat

Eyes

The eyes are rendered with a more realistic multi-layered structure

Screenshot 2022-07-20 220637

To render the eye ball, shold give the possibility to scale the pupil and render the limbus.

Eye7