sub-surface scattering is a very common effect and can be used on many materials
such as skin, milk, cream cheese, tomato sauce, potatoes, etc.
The original intention was to make a milk shader, but then simply studied the SSS
This is the sub-surface scattering effect on the vray.
This is the subsurface scattering effect that this article has achieved in unity:
BRDF (bidirectional reflection distribution) on the left and BSSRDF on the right (two-way subsurface scattering reflection distribution)
The parameters are as follows:
S:BSSRDF Results
Diffuse reflection of the RD:BSSRDF
Fr:: Fresnel reflex
Ft: Fresnel transparency, transmittance
FDR: Fresnel reflectance of diffuse reflectance
E: Irradiation Direction
In the wiki: Radiant Fluence is the radiant energy received by a surface per unit area, or equivalently the irradiance of a Sur Face integrated over time of irradiation
Phi: The irradiation energy per unit surface
Sigma A: Absorption rate
Sigma S: Scatter rate
Sigma T: Dissipation rate
Sigma T ': reduced dissipation rate
Sigma TR: Effective dissipation rate
D: Diffuse constant
Alpha: reflectivity
P: Phase function
Eta: Correlation Index of reflection
G: mean cos value of scattering angle
Q: Source Distribution Value
Q0: No. 0 Source Distribution
Q1:1th Source Distribution
Diffuse reflectance approximation
Diffuse reflectance approximation is based on the observation that the high dispersion medium tends to anisotropic, and the distribution of the light source and the phase function are anisotropic. Each scattering blurs the distribution of light, and the distribution of light is more uniform as the number of scattering increases.
This irradiation is similar to a two-item formula involving the irradiation energy and irradiation direction of the unit surface
The phase function of the Henyey-greenstein is used:
Constants are determined by the irradiation energy and direction of irradiation on the unit surface.
For an infinitely small light into a medium, the incident energy will decrease exponentially with the enter depth S.
Decrease Strength:
<span style= "FONT-SIZE:14PX;" >float Lri (float3 w_p, float phi_x, float p_l_dist, float D) {float _sigma_t = _sigma_a + _sigma_s;float L = 1/(4 * PI) E) * phi_x + 3/(4 * PIE) * DOT (w_p,-d*_nabla * phi_x); float Lri = L * POW (E,-_sigma_t* p_l_dist); return Lri;} </span>
first scattering decreases strength and is treated as volume source
for (int i = 0; i < i++) {w_p = normalize (FLOAT3 (n.x + rand (FIXED2, i*0.05)), i*0.05 + rand (N.Y (FIXED2,-i*0.05). ), N.z + rand (FIXED2 (i*0.05,-i*0.05))),//float3 w_p = Normalize (FLOAT3 (lightdir.x + rand (I.uv_maintex + fixed2 (i*0.0 1, i*0.01)), Lightdir.y + rand (I.uv_maintex + fixed2 (-i*0.01, i*0.01)), Lightdir.z + rand (I.uv_maintex + fixed2 (i*0.01,-I *0.01))); Q + = phase (dot (lightdir, w_p)) *lri (w_p, phi_x, P_l_dist, D); Q *= _sigma_s; Q1 + = q*w_p;}
30 Random light scattering direction
This equation is useful for observing the propagation of light within the volume.
This equation is associated with a scalar or flux of irradiance
NO. 0 Distribution formula with first source
The sigma parameter is pushed between each other,
As the light becomes anisotropic, the backscattering relationship changes the net flux, and there is no difference between the forward scattering and the non-scattering.
Here D = 1/(sigma_t '); is a diffuse constant
Finally we get the diffuse formula.
The derivation formula of the diffuse reflection section obtains the following result
The 30 random light scattering directions are superimposed when the definite integral is made, and the effect is quite good.
the reflective part of the diffuse reflectionand then it's the reflection part of the diffuse reflection.
Fresnel reflex formula, reflection of Fresnel diffuse reflection in a conductive medium:
The nature of the medium itself varies with the reflector, and ETA is the correlation index of this nature.
This is a precisely measured reflectivity, and we can use this formula to eliminate the computational cost.
Flux formula:
Dr = | | x-xr| | The distance from the current point to the light source
Dv = | | x-xv| | For the distance between the current point and the eye (camera)
if (_WORLDSPACELIGHTPOS0.W! = 0) {p_l_dist = distance (_worldspacelightpos0, i.worldpos);} float v_c_dist = distance (_worldspacecamerapos, i.worldpos) *0.3;
Φ for light intensity
In the end, our reflection formula is
<span style= "FONT-SIZE:14PX;" >FLOAT3 ref =-D * (dot (N, _nabla*phi_x_s))/(Diff*_lumpow_d);</span>
at the end of joining Physically-based Rendering's specular, it's done.
parameter Adjustmentabout parameter adjustment, the parameters are very bad, the PDF and their own parameters do not match, can only adjust their own
Final effect:
Reference:
1. A Practical Model for subsurface light Transport
2. A measurement-based Skin re?ectance Model for the face Rendering and Editing
-----by wolf96 http://blog.csdn.net/wolf96
Unity3d Shader subsurface scattering (subsurface scattering)