import math


def visibility(nov, nol, a):
  """Compute visibility using height-correlated GGX.

  Heitz 2014, "Understanding the Masking-Shadowing Function in Microfacet-Based
  BRDFs"

  Args:
    nov: Normal dot view direction.
    nol: Normal dot light direction.
    a: Linear roughness.

  Returns:
    The geometric visibility (V) term.
  """
  a2 = a * a
  ggxl = nov * math.sqrt((nol - nol * a2) * nol + a2)
  ggxv = nol * math.sqrt((nov - nov * a2) * nov + a2)
  return 0.5 / (ggxv + ggxl)