Unity3d Hair real time rendering real-time Hair rendering, unity3drendering

Source: Internet
Author: User
Tags asin

Unity3d Hair real time rendering real-time Hair rendering, unity3drendering

Put the effect first


Amazing Serra sauce

The algorithm is improved by Weta Digital according to siggraph2003's paper. We used the Kajiya and Kay's model to improve the algorithm. The energy conservation is not physical, which is not accurate.


 
Under the electron microscope, we found that there were a lot of overlapping yarn layers, also known as fur scales, and their angle of inclination relative to the root was about 3 °.


 
Hair fiber model
R is reflection, T is transmission, that is, refraction.
Here we assume there are three propagation modes: R, TT, and TRT.
R is a direct reflection,
TT is reflected twice
TRT is penetrating (refraction) into the hair, reflecting inside the hair, penetrating (refraction) Out, detailed

 
Human Hair fibers are mainly composed of skin and cortex. As an external sheath, the epidermis protects the internal cortex, which is very important in light scattering because it is the edge of refraction,
The color in the core of the hair is called the marrow, And the pigment in the cortex and cortex determines the color of the hair,
We study the optical properties of hair. There are two factors: 1. refraction parameter (about 1.55) 2. Cross-sectional absorption rate σ

 
Such,
From the root to the tip of the hair, we assume that u is the tan value of the hair, the vectors v and w are a standard orthogonal basis of the right hand, and the incident direction of light is ω I, the direction of the scattered light is ω r, and the angle is θ I, θ r (0 ° perpendicular to the hair, u is 90 ° ). The azimuth angle of the hair is expressed as Phi I and Phi r (v 0 ° w + 90 °), and the difference angle (θ I-θ r) /2 indicates that the corresponding azimuth angle of θ d is (PHI r-phi I)/2 indicates that it is Phi d. Phi r-phi I is expressed as Phi. The mean value θ h = (θ I + θ r)/2 is the halfwidth.
Hair absorption mainly depends on eumelanin and pheomelanin. Their concentrations are defined as p e and p, and their absorption rates are σ a, respectively, e and σ a, p, spectral absorption rate of μ a = p e σ a, e + p σ a, p.
The number of changes (refraction, reflection) before the light leaves the hair is p. P ε {R = 0, TT = 1, TRT = 2, TRRT = 3 ,...}
The total reflection function S is the sum of the product of all longitudinal scattering functions Mp and azimuth scattering functions Np.
 
 
Our ultimate goal is to add all the S of p 0-3, that is, the sum of all the light of R, TT, TRT, and TRRT.



Longitudinal scattering)
The following describes the method for finding the Gaussian Mp longitudinal scattering (longitudinal scattering) function.
θ r = −θ I,
 
Reflection on a smooth surface forms a single taper (left ). Since the surface is rough, Mp simulates a surface without highlights. This kind of scattering like a cone will be scaled and more inclined to the normal plane (right ). The light scattering range is wider, and the energy decreases.
Because the surface is rough and cannot produce a perfect reflection highlight, Marschner uses the Gaussian function to calculate the Mp.

 

<span style="font-size:14px;">inlinefixed G(fixed beta, fixed theta){return pow(E, -(theta*theta) / (2 * beta * beta)) / (sqrt(2 * PIE)* beta);}</span>


The G function is a standard Gaussian function with the vertical angle θ as the parameter, and beta is the roughness (standard deviation angle on the longitudinal smooth cone ), α p is a simple function of cortex inclination. However, the Mp energy obtained is not conservation for the following reasons:
1. In the g function, θ 0 {−∞, ∞}, but θ h 0 {−π/2, π/2 }. Using θ h instead of θ will multiply the reflection energy.
2. When θ I = −θ r, a scaled cone is involved in the polarization from the conical highlight −θ I to θ r. In Marschner, There is only about 1/cos ² θ d
3. the deflection illumination angle moves a considerable amount of energy, resulting in angular conversion greater than θ ε {−π/2, π/2} (the angle is too large and will never be received, resulting in energy loss)

We use an energy conservation Mp
In this method, the reflection angle is re-allocated in the sphere, and the spherical Gaussian convolution (spherical-Gaussian convolution) is used to obtain
 
G after a series of deformation simplification to get the final Mp:

 

<span style="font-size:18px;">Mp = (1 / ((pow(E, V) - pow(E, -V))*V))*pow(E, (sin(-Theta_i)*sin(Theta_r) / V))*I0(cos(-Theta_i)*cos(Theta_r) / V);</span>


Here v = β² is the square of roughness.
The I0 function is the first type of Beier function.
 

The longitudinal scattering curve of conservation of energy is as follows:
 
The taper highlight is asymmetrical, and the off-specular peak is similar to the two-dimensional BRDF. All roughness is energy conservation.
 


Azimuthal Scattering
Marschner adopts the Bravais feature when the hair is smooth and circular, and studies the azimuth scattering in the hair fiber.

Modify the refractive index'
The direction of the azimuth direction change is related to the offset hε {−1,1} in the hair and the P value. The reflection mode is:
 
Gamma I = arcsin (h), gamma t = arcsin (h/ε ')

 

Because h cannot be obtained, we use another method that can simulate h.
Marschner uses cube approximation to simulate h, but has not yet verified its accuracy. When the P value is large or the reflection index is low (the hair is in the water)

Roughened Azimuthal Scattering Function Np


We use Gaussian distribution to simulate the surface roughness of a deformed plane. Each offset h in the hair fiber generates a continuous distribution of the azimuth Dp (Phi-phi (p, h )), this distribution is produced by the discrete azimuth angle (PHI, h) in the coens and smooth hair. As shown in:
 
Rough discrete angle scattering (TT): The offset h on the smooth hair can generate a definite azimuth angle of PHI (p, h ), we can obtain the Gaussian distribution of the azimuth value, Dp (φ−phi (p, h )).
All outbound light is integrated together:

 


A (p, h) is the attenuation produced by light absorption and freell. We use a new standard high-speed distribution function Dp called Gaussian detector.
 

<span style="font-size:14px;">for (fixed i = -1; i < 1; i += 0.1){Mu_a_d = Mu_a / cos(i / Eta_d);ref_1 = acos(cos(Theta_d) * cos(asin(i)));f = -_SC + (1 + _SC)*pow(2, -10 * dot(ref_1, _Eta));T = exp(-2 * Mu_a_d*(1 + cos(2 * asin(i / Eta_d))));A = pow((1 - f), 2) * pow(f, p - 1) * T;//Np += A *Dp(Phi - Phi_p_h(p, i, Eta_d));Np += A *Dp(Phi - Phi_p_h(i, Eta_d));}Np *= 0.5;</span>


 
By now, all our formulas are complete. We can use the for loop to accumulate S with different p values to get the final result.


After measuring σ a, e = {0.419, 0.697, 1.37} σ a, p = {0.187, 0.4, 1.05}, the results are relatively true.

Implementation results in the paper
 
At present, the blogger is not capable enough to get such hair in Unity (it feels like his hair is generated by surface subdivision). He can only use a better model to count it:



This article is part of the translation and the understanding and implementation of the bloggers themselves. If there are any mistakes, you are welcome to criticize and correct them.

Refer:

1. An Energy-Conserving Hair Re emerge ectance Model

2. Light Scattering from Human Hair Fibers


----- By wolf96 http://blog.csdn.net/wolf96


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.