diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl')
-rw-r--r-- | indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 2f3efaa94a..409b46218b 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -25,9 +25,6 @@ #define FLT_MAX 3.402823466e+38 -#define REFMAP_COUNT 256 -#define REF_SAMPLE_COUNT 64 //maximum number of samples to consider - out vec4 frag_color; uniform sampler2D diffuseRect; @@ -47,9 +44,14 @@ uniform sampler2D lightFunc; uniform float blur_size; uniform float blur_fidelity; +#if defined(HAS_SSAO) +uniform float ssao_irradiance_scale; +uniform float ssao_irradiance_max; +#endif + // Inputs uniform mat3 env_mat; - +uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; uniform vec3 moon_dir; uniform int sun_up_factor; @@ -115,6 +117,16 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, vec3 l); //surface point to light +void adjustIrradiance(inout vec3 irradiance, vec3 amblit_linear, float ambocc) +{ + // use sky settings ambient or irradiance map sample, whichever is brighter + irradiance = max(amblit_linear, irradiance); + +#if defined(HAS_SSAO) + irradiance = mix(ssao_effect_mat * min(irradiance.rgb*ssao_irradiance_scale, vec3(ssao_irradiance_max)), irradiance.rgb, ambocc); +#endif +} + void main() { vec2 tc = vary_fragcoord.xy; @@ -176,7 +188,7 @@ void main() vec3 orm = texture(specularRect, tc).rgb; float perceptualRoughness = orm.g; float metallic = orm.b; - float ao = orm.r * ambocc; + float ao = orm.r; vec3 colorEmissive = texture(emissiveRect, tc).rgb; // PBR IBL @@ -184,16 +196,13 @@ void main() sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, norm.xyz, gloss); - // Take maximium of legacy ambient vs irradiance sample as irradiance - // NOTE: ao is applied in pbrIbl (see pbrBaseLight), do not apply here - irradiance = max(amblit_linear,irradiance); + adjustIrradiance(irradiance, amblit_linear, ambocc); vec3 diffuseColor; vec3 specularColor; calcDiffuseSpecular(baseColor.rgb, metallic, diffuseColor, specularColor); vec3 v = -normalize(pos.xyz); - color = vec3(1,0,1); color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten); if (do_atmospherics) @@ -206,17 +215,15 @@ void main() //should only be true of WL sky, just port over base color value color = texture(emissiveRect, tc).rgb; color = srgb_to_linear(color); - if (sun_up_factor > 0) - { - color *= sky_hdr_scale + 1.0; - } + color *= sky_hdr_scale; } else { // legacy shaders are still writng sRGB to gbuffer baseColor.rgb = legacy_adjust(baseColor.rgb); - + baseColor.rgb = srgb_to_linear(baseColor.rgb); + spec.rgb = srgb_to_linear(spec.rgb); float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0); @@ -227,11 +234,10 @@ void main() sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, norm.xyz, spec.a, envIntensity); - // use sky settings ambient or irradiance map sample, whichever is brighter - irradiance = max(amblit_linear, irradiance); + adjustIrradiance(irradiance, amblit_linear, ambocc); // apply lambertian IBL only (see pbrIbl) - color.rgb = irradiance * ambocc; + color.rgb = irradiance; vec3 sun_contrib = min(da, scol) * sunlit_linear; color.rgb += sun_contrib; |