summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class3
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class3')
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/materialF.glsl15
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl40
-rw-r--r--indra/newview/app_settings/shaders/class3/lighting/lightV.glsl10
-rw-r--r--indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl67
5 files changed, 34 insertions, 102 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl
index 1c79748b49..0d77e88831 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl
@@ -42,7 +42,7 @@ uniform samplerCube environmentMap;
vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten);
vec3 legacy_adjust_fullbright(vec3 c);
vec3 legacy_adjust(vec3 c);
-void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao);
+void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten);
vec3 linear_to_srgb(vec3 c);
vec3 srgb_to_linear(vec3 c);
@@ -71,7 +71,7 @@ void main()
vec3 additive;
vec3 atten;
vec3 pos = vary_position;
- calcAtmosphericVars(pos.xyz, vec3(0), 1.0, sunlit, amblit, additive, atten, false);
+ calcAtmosphericVars(pos.xyz, vec3(0), 1.0, sunlit, amblit, additive, atten);
float env_intensity = vertex_color.a;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
index 77e3b92385..5fb5647d35 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
@@ -38,7 +38,7 @@ uniform float emissive_brightness; // fullbright flag, 1.0 == fullbright, 0.0 o
uniform int sun_up_factor;
#ifdef WATER_FOG
-vec4 applyWaterFogView(vec3 pos, vec4 color);
+vec4 applyWaterFogViewLinear(vec3 pos, vec4 color, vec3 sunlit);
#endif
vec3 atmosFragLightingLinear(vec3 l, vec3 additive, vec3 atten);
@@ -49,6 +49,7 @@ void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float
vec3 srgb_to_linear(vec3 cs);
vec3 linear_to_srgb(vec3 cs);
vec3 legacy_adjust(vec3 c);
+vec3 legacy_adjust_fullbright(vec3 c);
#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)
@@ -396,7 +397,7 @@ void main()
}
#endif
- color = mix(color.rgb, diffcol.rgb, emissive);
+ color = mix(color.rgb, legacy_adjust_fullbright(diffcol.rgb), emissive);
if (env > 0.0)
{ // add environmentmap
@@ -410,6 +411,11 @@ void main()
color.rgb = atmosFragLightingLinear(color.rgb, additive, atten);
+#ifdef WATER_FOG
+ vec4 temp = applyWaterFogViewLinear(pos, vec4(color, 0.0), sunlit_linear);
+ color = temp.rgb;
+#endif
+
vec3 npos = normalize(-pos.xyz);
vec3 light = vec3(0, 0, 0);
@@ -430,11 +436,6 @@ void main()
glare = min(glare, 1.0);
float al = max(diffcol.a, glare) * vertex_color.a;
-#ifdef WATER_FOG
- vec4 temp = applyWaterFogView(pos, vec4(color, 0.0));
- color = temp.rgb;
-#endif
-
frag_color = max(vec4(color, al), vec4(0));
#else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer
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;
diff --git a/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl b/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl
index 30ad493331..77bbbabfae 100644
--- a/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl
+++ b/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl
@@ -23,21 +23,13 @@
* $/LicenseInfo$
*/
-
-
-// All lights, no specular highlights
-vec3 atmosAmbient();
+// used for preview renders only
vec4 sumLights(vec3 pos, vec3 norm, vec4 color);
-float getAmbientClamp();
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color)
{
vec4 c = sumLights(pos, norm, color);
-#if !defined(AMBIENT_KILL)
- c.rgb += atmosAmbient() * color.rgb * getAmbientClamp();
-#endif
-
return c;
}
diff --git a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
deleted file mode 100644
index 4b663dd5b2..0000000000
--- a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * @file class3\lighting\sumLightsV.glsl
- *
- * $LicenseInfo:firstyear=2005&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2005, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-
-float calcDirectionalLight(vec3 n, vec3 l);
-float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight);
-
-vec3 atmosAffectDirectionalLight(float lightIntensity);
-vec3 scaleDownLight(vec3 light);
-
-uniform vec4 light_position[8];
-uniform vec3 light_direction[8];
-uniform vec4 light_attenuation[8];
-uniform vec3 light_diffuse[8];
-
-vec4 sumLights(vec3 pos, vec3 norm, vec4 color)
-{
- vec4 col = vec4(0.0, 0.0, 0.0, color.a);
-
- // Collect normal lights (need to be divided by two, as we later multiply by 2)
-
- // Collect normal lights
- col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z);
- col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z);
- col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z);
- col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z);
- col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z);
- col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z);
- col.rgb += light_diffuse[1].rgb*calcDirectionalLight(norm, light_position[1].xyz);
- col.rgb = scaleDownLight(col.rgb);
-
-#if defined(LOCAL_LIGHT_KILL)
- col.rgb = vec3(0);
-#endif
-
- // Add windlight lights
-#if !defined(SUNLIGHT_KILL)
- col.rgb += atmosAffectDirectionalLight(calcDirectionalLight(norm, light_position[0].xyz));
-#endif
-
- col.rgb = min(col.rgb*color.rgb, 1.0);
-
- return col;
-}
-