天天看點

Moving Frostbite to Physically Based Rendering 3.0

https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf

https://www.ea.com/frostbite/news/moving-frostbite-to-pb

https://blog.csdn.net/poem_qianmo/article/details/100652463 參考毛星雲的部落格,非常有幫助

3.1 material models

3.1.1 appearance

surface appearance results from the interaction between incoming light and the material properties of a surface. the variety of appearances observable in the real world is quite wide, ranging from simple uniform materials to complex layered and heterogeneous 異構的 materials, see figure 4.

Moving Frostbite to Physically Based Rendering 3.0

figure 4: various surface appearance showing the diversity多樣性 of interaction between light and matter.

these different appearances can be categorized by certain intrinstic physical properties such as conductivity, mean-free-path, and absoption. baesd on these material properties, the literature has exposed various material models capable of representing a certain range of appearances amongst the full spectrum. material model literature is extensive, and a lot of different models exist with various trade-offs and accuracies. a material model, referred to as a BSDF (Bidirectional Scattering Distribution Function), can be decomposed into two parts: a Reflectance part (BRDF) and a Transmittance part (BTDF). in this document we will focuse on the reflective part and in particular on a material model capable of representing “standard” appearances i.e. the vase majority of surfaces we encounter in our every day life. hence, we will limit ourselves to reflective, isotropic, dielectric/conductor surfaces with short mean-free-paths.

3.1.2 Material models

in the context of this standard material model, a surface response f is often decomposed into two different terms: a low angular frequency signal called “diffuse” (fd) and a low to high angular frequency part called “specular” (fr), see figure 5.

Moving Frostbite to Physically Based Rendering 3.0

figure 5: light interaction with a slab of “standard” matter. left:light interactions. right: a BSDF model of the interaction with a diffuse term fd and a specular fr.

an interface sepearates two media: the air and the matter. surfaces made of a flat interface can easily be represented by the Fresnel law [Wikd] for both dieletric and conductor surfaces. when the interface is irregular, see figure 6,

Moving Frostbite to Physically Based Rendering 3.0

figure 6: shows surfaces of different roughness, modeled by D term. top: light interactions with the microfacets. middle: resulting BRDF fr lobe. bottom: resulting appearance on spheres.

the literature shows that microfacet based models[CT82] are well adapted to characterize the light interaction for these types of surfaces. a microfacet model is described by Equation 1, for more details about the derivations see [Hei14]:

Moving Frostbite to Physically Based Rendering 3.0

the term D models the microfacet distribution (i.e. the NDF, normal distribution function). the G term models the occlusion (shadow-masking) of the microfacets. this formulation is valid for both the diffuse term fd and the specular term fr. the difference between these two term lies in the microfacet BRDF fm. for the specular term, fm is a perfect mirror and thus is modeled with the Fresnel F law, which leads to the well-known following formulation:

Moving Frostbite to Physically Based Rendering 3.0

the term 我們把term翻譯成系數的意思 D plays an important role in the appearance of surfaces, as shown by figure 6. the literature, [Wal+; Bur12] has recently pointed out that “long-tailed” NDFs, like the GGX distribution, are good at capturing real world surfaces. the G term also plays an important role for high roughness values. Heitz [Hei14] has recently shown that the Smith visibility function is the correct and exact G term to use. he also points out that the literature often tends to use an approximated version of the Smith visibility function, while a more accurate form of the masking-shadowing function models the correleation between the masking and shadowing due to the height of the microsurface, see equation 3. figure 7 shows the difference between the simple Smith function and the height-correlated Smith function.

Moving Frostbite to Physically Based Rendering 3.0

For the diffuse term, fm follows a Lambertian model and Equation 1 can be simpli ed into:

Moving Frostbite to Physically Based Rendering 3.0

Until recently the diffuse term fd was assumed to be a simple Lambertian model. However, except for layered materials, the diffuse part needs to be coherent with the specular term and must take into account the roughness of the surface [Bur12] (i.e specular and diffuse term should use same roughness term3), see Figure 8. The Equation 4 does not have an analytic solution. Oren et al. [ON94] found

an empirical approximation of this equation using a Gaussian NDF distribution and a V-cavity G term know as the Oren-Nayar model. To correctly support our model we should make an equivalent approximation for Equation 4 with a GGX NDF as describe in Gotanda [Got14]. Appendix B details some of our analysis about such a diffuse model, but further research is required.

Moving Frostbite to Physically Based Rendering 3.0

Figure 8: Shows a view of the interaction at the micro scale for both the specular fr term, which has a mirror BRDF fm (left), and the diffuse term fd, which has a diffuse BRDF fm (right).

Burley [Bur12] has presented another diffuse model built on real world surface observations, see Equation 5. While this model is empirical, it allows us to reproduce the main features of the MERL database’s materials http://www.merl.com/brdf/. For this reason and because of its simplicity, we have chosen to use this model in Frostbite. This diffuse term takes into account the roughness of the material and creates some retro-reflection at grazing angles.

Moving Frostbite to Physically Based Rendering 3.0

3.1.3 energy conservation

energy conservation is important to consider in order to not add more energy than received. in addition it allows us to correctly handle the behavior at grazing angles, for which the light tends to be scattered more by the specular term than the diffuse term. in frostbite 寒霜引擎 we have chosen to keep the computation simple and only ensure the preservation of energy, by ensuring that the hemispherical directional reflectance, which gives the total reflecance in a given direction due to constant illumination over the hemisphere, is below for our whole BRDF (diffuse+specular term):

Moving Frostbite to Physically Based Rendering 3.0

3.1.5 frostbite standard model

to summarize, frostbite’s “standard” material model is close to the one used by other game engines [Kar13;NP13;Bur12]. it is composed of:

  1. specular term fr: a specular microfacet model (see equation 2) with a smith coorelated visibility function and a GGX NDF.
  2. diffuse term fd: the Disney diffuse term with energy renormalization.

for both parts, we apply our dominant direction correction (off-specular peak handling) when integrating lighting. the parameters for manipulating these models will be described in the next section.

forstbite also supports other types of material such as clear coat 漆 and materials with subsurface scattering, but we will focus only on the standard material model in this document.

插入一條消息:菲涅爾近似公式,F0就是當入射角為0的時候,其反射系數。詳細可參考:https://blog.csdn.net/wodownload2/article/details/100096281

Moving Frostbite to Physically Based Rendering 3.0

D_GGX——法線分布函數是:https://blog.csdn.net/wodownload2/article/details/100096281

Moving Frostbite to Physically Based Rendering 3.0
float3 F_Schlick (in float3 f0 , in float f90 , in float u)
{
	return f0 + (f90 - f0) * pow (1. f - u, 5.f);
}

float V_SmithGGXCorrelated ( float NdotL , float NdotV , float alphaG )
{
	// Original formulation of G_SmithGGX Correlated
	// lambda_v = (-1 + sqrt ( alphaG2 * (1 - NdotL2 ) / NdotL2 + 1)) * 0.5 f;
	// lambda_l = (-1 + sqrt ( alphaG2 * (1 - NdotV2 ) / NdotV2 + 1)) * 0.5 f;
	// G_SmithGGXCorrelated = 1 / (1 + lambda_v + lambda_l );
	// V_SmithGGXCorrelated = G_SmithGGXCorrelated / (4.0 f * NdotL * NdotV );
	
	// This is the optimize version
	float alphaG2 = alphaG * alphaG ;
	// Caution : the " NdotL *" and " NdotV *" are explicitely inversed , this is not a mistake .
	float Lambda_GGXV = NdotL * sqrt ((- NdotV * alphaG2 + NdotV ) * NdotV + alphaG2 );
	float Lambda_GGXL = NdotV * sqrt ((- NdotL * alphaG2 + NdotL ) * NdotL + alphaG2 );
	
	return 0.5 f / ( Lambda_GGXV + Lambda_GGXL );
 }

 float D_GGX ( float NdotH , float m)
 {
	 // Divide by PI is apply later
	 float m2 = m * m;
	 float f = ( NdotH * m2 - NdotH ) * NdotH + 1;
	 return m2 / (f * f);
 }

 // This code is an example of call of previous functions
 float NdotV = abs( dot (N, V)) + 1e -5f; // avoid artifact
 float3 H = normalize (V + L);
 float LdotH = saturate ( dot (L, H));
 float NdotH = saturate ( dot (N, H));
 float NdotL = saturate ( dot (N, L));

 // Specular BRDF
 float3 F = F_Schlick (f0 , f90 , LdotH );
 float Vis = V_SmithGGXCorrelated (NdotV , NdotL , roughness );
 float D = D_GGX (NdotH , roughness );
 float Fr = D * F * Vis / PI;

 // Diffuse BRDF
 float Fd = Fr_DisneyDiffuse (NdotV , NdotL , LdotH , linearRoughness ) / PI;
           

Listing 2: BSDF evaluation code.

關于Vis系數的來曆,在函數V_SmithGGXCorrelated 中的注釋部分已經給出了,考慮到fr的公式,分母除以了4倍的pi,還有ndol,ndov,那麼,和公式:

Moving Frostbite to Physically Based Rendering 3.0
Moving Frostbite to Physically Based Rendering 3.0

那麼将這部分:

Moving Frostbite to Physically Based Rendering 3.0

那麼,則會得到上面的V_SmithGGXCorrelated 中的方法體了。

而且在毛星雲的部落格中:https://blog.csdn.net/poem_qianmo/article/details/100652463

提到:Frostbite的Lagarde[Lagarde 2014 ]觀察到對GGX高度相關的Smith G2(height-correlated Smith G2)具有與鏡面微平面BRDF的分母組合時抵消的項, 是以可以簡化組合項為:

Moving Frostbite to Physically Based Rendering 3.0
Moving Frostbite to Physically Based Rendering 3.0

是以你會發現:

Moving Frostbite to Physically Based Rendering 3.0

fr的計算,就隻除以了pi,原因就是上面已經将分母的4NdotLNdotV,考慮過了。

3.2 material system

3.2.1 material

frostbite is used in a wide variety of games, from sports to racing, from first person shooters to open world games. in order to satisfy the different requriements that these games have, the engine needs to offer flexible controls regarding lighting and material support. in addition, one of the constraints during the move to PBR was to ensure compatibility with our old non-PBR lighting model in order to ease the transition. the lighting path is controllable, supporting: deferred, forward, or hybrid. this path will be detailed in section 4.11.

In Frostbite a “material” is defined by:

1) A lighting path: deferred, forward or both.

A set of input parameters: diuse, smoothness, thickness, etc.

A material model: rough surface, translucency, skin, hair, etc., as well as non-PBR rough

surface. This is the shader code.

A GBuffer layout in case of deferred path support. The number of buffers is variable.

a game team can choose a set of materials from those available for a given light path. each material is identified with a materialD attribute for the game. a base material covering the most common cases (which we call the “standard material”) is always present and defines parameters shared with other material (e.g. roughness). for deferred shading the base material is commonly set to the “Disney” model, referring to Burley’s model [Bur12]. however, we also support two other base material: a “two-color” material and an “old” material.

Disney base material: our disney material uses the following parameters:

normal: standard normals

basecolor: defines the diffuse albedo for non-metallic objects and Fresnel reflectance at normal incidence (f0) for metallic ones, as suggested by Burley’s presentation. for metallic objects the lower part of this attribute defines a micro-specular occlusion.

繼續閱讀