Geometric function

  • G is geometric attenuation/shadow factor.
  • The geometric function approximates statistically the ratio of shading between the microplanes, which will lose the energy of the light.
  • The geometry function is a multiplier in the range [0.0, 1.0], where white or 1.0 means no shading of the microplane and black or 0.0 means that the microplane is completely obscured.
  • The influence of geometric terms can be indirectly regarded as the influence of directional albedo
  • The directional albedo of most materials is relatively flat for the first 70 degrees, and the reflectivity at the tangent incidence is closely related to the surface roughness.
  • The choice of geometric terms affects the reflectivity, which in turn affects the appearance of the surface.
  • A model that completely omits the G term and the 1/cosθl cosθv term, known as the “No G” model, results in a response that is too dark at the grazing Angle.

Figure reflectivity diagrams of several geometric models of specular reflection. The same D (GGX/TR) term and F term are used in all graphs. Left: smooth surface (α= 0.02); Right: Rough surface (α= 0.5). The calculation of G and 1/cosθ L cosθv has been removed from the “No G” model.

Schematic diagram

The formula

Formula 1

    • G function
    • K variables
      • Direct sunlight
      • IBL ambient light
  • Geometric function GLSL
float GeometrySchlickGGX(float NdotV, float k)
{
    float nom   = NdotV;
    float denom = NdotV * (1.0 - k) + k;

    return nom / denom;
}

float GeometrySmith(vec3 N, vec3 V, vec3 L, float k)
{
    float NdotV = max(dot(N, V), 0.0);
    float NdotL = max(dot(N, L), 0.0);
    float ggx1 = GeometrySchlickGGX(NdotV, k);
    float ggx2 = GeometrySchlickGGX(NdotL, k);

    return ggx1 * ggx2;
}
Copy the code

Formula 2

  • The roughness parameters were remapped to reduce the extreme gain of the glossy surface, i.e. α was remapped from [0, 1] to [0.5, 1] with the value of (0.5 + Roughness /2)^2. Thus, the roughness variation of the geometric terms is smoother
// Smith GGX G term, isotropic version
float smithG_GGX(float NdotV, float alphaG)
{
    float a = alphaG * alphaG;
    float b = NdotV * NdotV;
    return 1 / (NdotV + sqrt(a + b - a * b));
}
Copy the code

The formula 3

// Smith GGX G item, each of the different versions
// Derived G function for GGX
float smithG_GGX_aniso(float dotVN, float dotVX, float dotVY, float ax, float ay)
{
    return 1.0 / (dotVN + sqrt(pow(dotVX * ax, 2.0) + pow(dotVY * ay, 2.0) + pow(dotVN, 2.0)));
}
Copy the code

The formula of 4

// GGX varnish geometry
// G GGX function for clearcoat
float G_GGX(float dotVN, float alphag)
{
    float a = alphag * alphag;
    float b = dotVN * dotVN;
    return 1.0 / (dotVN + sqrt(a + b - a * b));
}
Copy the code
  • For the secondary lobe treated with varnish layer, Disney did not use Smith G to derive, but directly used the G term of GGX with a fixed roughness of 0.25 to get a reasonable and good visual effect.