From 93dfd8173047bcbcce142fc196e64acbfd115c82 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 28 Jun 2022 15:43:12 -0700 Subject: SL-17274: PBR: Fix reflection --- .../shaders/class3/deferred/softenLightF.glsl | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'indra/newview/app_settings') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index aa146b4bcc..e50d3604c7 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -126,9 +126,6 @@ vec4 applyWaterFogView(vec3 pos, vec4 color); uniform vec3 view_dir; // PBR -#define getDiffuseLightPBR(n) ambenv -#define getSpecularPBR(reflection) glossenv - // Approximate Environment BRDF vec2 getGGXApprox( vec2 uv ) { @@ -196,9 +193,6 @@ void main() vec3 ambenv; vec3 glossenv; vec3 legacyenv; - sampleReflectionProbes(ambenv, glossenv, legacyenv, pos.xyz, norm.xyz, spec.a, envIntensity); - - amblit = max(ambenv, amblit); bool hasPBR = GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR); if (hasPBR) @@ -262,8 +256,13 @@ void main() vec3 kSpec = reflect0 + fresnelR*pow(1.0 - dotNV, 5.0); // Reference: getIBLRadianceGGX - vec3 reflection = normalize(reflect(-v,n)); - vec3 specLight = getSpecularPBR(reflection); + // https://forum.substance3d.com/index.php?topic=3243.0 + // Glossiness + // This map is the inverse of the roughness map. + vec3 irradiance = vec3(0); + vec3 specLight = vec3(0); + float gloss = 1.0 - perceptualRough; + sampleReflectionProbes(irradiance, specLight, legacyenv, pos.xyz, norm.xyz, gloss, 0.0); #if HAS_IBL kSpec = mix( kSpec, iridescenceFresnel, iridescenceFactor); #endif @@ -271,7 +270,6 @@ void main() colorSpec += specWeight * specLight * FssEssGGX; // Reference: getIBLRadianceLambertian - vec3 irradiance = getDiffuseLightPBR(n); vec3 FssEssLambert = specWeight * kSpec * vScaleBias.x + vScaleBias.y; // NOTE: Very similar to FssEssRadiance but with extra specWeight term float Ems = (1.0 - vScaleBias.x + vScaleBias.y); vec3 avg = specWeight * (reflect0 + (1.0 - reflect0) / 21.0); @@ -382,6 +380,9 @@ void main() } else { + sampleReflectionProbes(ambenv, glossenv, legacyenv, pos.xyz, norm.xyz, spec.a, envIntensity); + + amblit = max(ambenv, amblit); color.rgb = amblit*ambocc; //float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); -- cgit v1.2.3