From 0079dcd6a451bb356e9197d40181913ddad63e72 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 23 Aug 2022 04:17:12 -0700 Subject: SL-17766: PBR: Add V_GGX references --- .../shaders/class1/deferred/deferredUtil.glsl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index 46463818f8..8ecdafa167 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -392,17 +392,35 @@ float D_GGX( float nh, float alphaRough ) } // NOTE: This is different from the GGX texture +// See: +// Real Time Rendering, 4th Edition +// Page 341 +// Equation 9.43 +// Also see: +// https://google.github.io/filament/Filament.md.html#materialsystem/specularbrdf/geometricshadowing(specularg) +// 4.4.2 Geometric Shadowing (specular G) float V_GGX( float nl, float nv, float alphaRough ) { +#if 1 + // Note: When roughness is zero, has discontuinity in the bottom hemisphere float rough2 = alphaRough * alphaRough; float ggxv = nl * sqrt(nv * nv * (1.0 - rough2) + rough2); float ggxl = nv * sqrt(nl * nl * (1.0 - rough2) + rough2); + float ggx = ggxv + ggxl; if (ggx > 0.0) { return 0.5 / ggx; } return 0.0; +#else + // See: smithVisibility_GGXCorrelated, V_SmithCorrelated, etc. + float rough2 = alphaRough * alphaRough; + float ggxv = nl * sqrt(nv * (nv - rough2 * nv) + rough2); + float ggxl = nv * sqrt(nl * (nl - rough2 * nl) + rough2); + return 0.5 / (ggxv + ggxl); +#endif + } // NOTE: Assumes a hard-coded IOR = 1.5 -- cgit v1.2.3