Unity sauce ~ cartoon rendering of technical analysis (two)

In front of the words

Previous Unity sauce ~ cartoon rendering of technical analysis (a) written CharaMain.cginc, clothing rendering is how to achieve. This analyze achieve hair with skin

hair

Originally thought unitychan hair will achieve anisotropy, did not think she also used CharaMain.cginc achieve. We take a look at the hair of materials
Hair Material
other implementations are the same, but also to control the highlight areas with high light reflectance by the reflection area map

Calculating normal vector dot product with the angle of view, the effect is greater the higher the light vector perpendicular to the viewing angle, and to control the RGB map which highlights the regions more easily

RGB

A reflection is still used to control the channel, where the white, reflecting the stronger
Alpha Channel

How to achieve the effect of skin

Such a beautiful skin, in fact, only two results is realized

+ Light diffuse reflection edge

This time we talk about in detail to achieve diffuse reflection

    float_t normalDotEye = dot( i.normal, i.eyeDir );
    float_t falloffU = clamp( 1 - abs( normalDotEye ), 0.02, 0.98 );

Use line or dot product with the vector of angle of view, and is limited to the range of 0.02 to 0.98.
Originally smaller value the larger the angle, the smaller the angle the larger the value, the use of 1 - after the absolute value of the dot product, the more near one vector, the closer to zero. The larger the angle of view with vector angle, the greater the value, which is part of the greater value of the edge

    float4_t falloffSamplerColor = FALLOFF_POWER * tex2D( _FalloffSampler, float2( falloffU, 0.25f ) );
    float3_t combinedColor = lerp( diffSamplerColor.rgb, falloffSamplerColor.rgb * diffSamplerColor.rgb, falloffSamplerColor.a );

With just seek out value, this sampling attenuation map, which is an important step reflects the texture of the skin! The higher the value, the closer the color of the flesh-colored sample. That is, the more the flesh close to the edge

FALLOFF_POWER is a damping coefficient, skin shader value of 1, i.e. no attenuation

skin falloff

Diffuse skin

Coupled with the edge highlighter

Diffuse light skin edge +

to sum up

unity technical analysis chan almost finished, the main technical characteristics are as follows:

  1. Diffuse value NV is an attenuation of the sample to achieve texture, the texture can also be used to achieve this effect skin
  2. Controlled by a high light reflection map Zhang Gaoguang details, and the reflective display area to which
  3. Fresnel reflection light edge useless, but the texture sampling rim worth to multiply diffusely reflected light to the edge of the high
  4. Stroke is not solid, the sample color texture, do dark treatment

The last two photos again rendering it ~ ~ this is actually still pretty good

Guess you like

Origin www.cnblogs.com/lijiajia/p/12334145.html