INNER CODE UNIT · Python
Vx
SedulousWorks/SedulousEngine · Scripts/generate_brdf_lut.py:95
Vx = np.sqrt(1.0 - ndot_v * ndot_v)
Vz = ndot_v
# VdotH for all (x, sample) combos.
VdotH = Vx[:, None] * Hx[None, :] + Vz[:, None] * Hz[None, :]
VdotH = np.maximum(VdotH, 0.0)
# L = 2 * VdotH * H - V; only need L.z for NdotL since N = (0,0,1).
Lz = 2.0 * VdotH * Hz[None, :] - Vz[:, None]
NdotL = np.maximum(Lz, 0.0)
NdotH = np.maximum(Hz[None, :] * np.ones((SIZE, 1)), 0.0)
# Only contributing samples (NdotL > 0) accumulate.
mask = NdotL > 0.0
# Smith GGX geometry term (split-sum form).
gv = ndot_v[:, None] / (ndot_v[:, None] * (1.0 - k) + k)
gl = NdotL / (NdotL * (1.0 - k) + k + 1e-10)