brdfGGX top-level property

dynamic brdfGGX
getter/setter pair

Implementation

var brdfGGX = shaderNode((inputs) {
  var lightDirection = inputs.lightDirection;
  var f0 = inputs.f0;
  var f90 = inputs.f90;
  var roughness = inputs.roughness;

  var alpha = pow2(roughness); // UE4's roughness

  var halfDir = normalize(add(lightDirection, positionViewDirection));

  var dotNL = saturate(dot(transformedNormalView, lightDirection));
  var dotNV = saturate(dot(transformedNormalView, positionViewDirection));
  var dotNH = saturate(dot(transformedNormalView, halfDir));
  var dotVH = saturate(dot(positionViewDirection, halfDir));

  var F = fSchlick({f0, f90, dotVH});

  var V = vGGXSmithCorrelated({alpha, dotNL, dotNV});

  var D = dGGX({alpha, dotNH});

  return mul(F, mul(V, D));
});