diff options
Diffstat (limited to 'indra/newview/app_settings/shaders')
8 files changed, 116 insertions, 26 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl index 5ca210863e..3a7552d23e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl @@ -114,7 +114,7 @@ void main()      float rel_pos_len  = length(rel_pos);  	// Initialize temp variables -	vec3 sunlight = sunlight_color; +	vec3 sunlight = sunlight_color*2.0;  	vec3 light_atten;  	// Sunlight attenuation effect (hue and brightness) due to atmosphere diff --git a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl new file mode 100644 index 0000000000..ff37f9e4b3 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl @@ -0,0 +1,92 @@ +/**  + * @file exposureF.glsl + * + * $LicenseInfo:firstyear=2023&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2023, 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$ + */ +  +#extension GL_ARB_texture_rectangle : enable + +/*[EXTRA_CODE_HERE]*/ + +out vec4 frag_color; + +uniform sampler2D diffuseRect; +uniform sampler2D emissiveRect; +uniform sampler2D exposureMap; + +uniform float dt; +uniform vec2 noiseVec; + +// calculate luminance the same way LLColor4::calcHSL does +float lum(vec3 col) +{ +    float mx = max(max(col.r, col.g), col.b); +    float mn = min(min(col.r, col.g), col.b); +    return (mx + mn) * 0.5; +} + +void main()  +{ +    float step = 1.0/32.0; + +    float start = step; +    float end = 1.0-step; + +    float w = 0.0; + +    vec3 col; + +    vec2 nz = noiseVec * step * 0.5; + +    for (float x = start; x <= end; x += step) +    { +        for (float y = start; y <= end; y += step) +        { +            vec2 tc = vec2(x,y) + nz; +            vec3 c = texture(diffuseRect, tc).rgb + texture(emissiveRect, tc).rgb; +            float L = max(lum(c), 0.25); + +            float d = length(vec2(0.5)-tc); +            d = 1.0-d; +            d *= d; +            d *= d; +            d *= d; +            L *= d; + +            w += L; + +            col += c * L; +        } +    } + +    col /= w; + +    float L = lum(col); + +    float s = clamp(0.1/L, 0.5, 2.0); + +    float prev = texture(exposureMap, vec2(0.5,0.5)).r; +    s = mix(prev, s, min(dt*2.0, 0.04)); + +    frag_color = vec4(s, s, s, dt); +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 87324bca7f..4ac1ff9368 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -35,6 +35,7 @@ out vec4 frag_color;  uniform sampler2D diffuseRect;  uniform sampler2D emissiveRect; +uniform sampler2D exposureMap;  uniform vec2 screen_res;  VARYING vec2 vary_fragcoord; @@ -107,7 +108,9 @@ uniform float gamma;  vec3 toneMap(vec3 color)  { -    color *= exposure; +    float exp_scale = texture(exposureMap, vec2(0.5,0.5)).r; + +    color *= exposure * exp_scale;  #ifdef TONEMAP_ACES_NARKOWICZ      color = toneMapACES_Narkowicz(color); @@ -190,6 +193,9 @@ void main()      vec3 nz = vec3(noise(seed.rg), noise(seed.gb), noise(seed.rb));      diff.rgb += nz*0.003;      //diff.rgb = nz; + +    //float exp_sample = texture(exposureMap, vec2(0.5,0.5)).r; +    //diff.g = exp_sample;      frag_color = diff;  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl index 4d24b4de9a..8b4cac3e64 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl @@ -33,6 +33,6 @@ void main()  {  	//transform vertex  	vec4 pos = vec4(position.xyz, 1.0); -	gl_Position = pos;	 +	gl_Position = pos;  	vary_fragcoord = (pos.xy*0.5+0.5);  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl index 1424b57d6f..fc6291d438 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl @@ -32,8 +32,8 @@ ATTRIBUTE vec3 position;  ///////////////////////////////////////////////////////////////////////////////  // Output parameters -VARYING vec3 vary_HazeColor; -VARYING float vary_LightNormPosDot; +out vec3 vary_HazeColor; +out float vary_LightNormPosDot;  // Inputs  uniform vec3 camPosLocal; @@ -56,6 +56,8 @@ uniform float max_y;  uniform vec3  glow;  uniform float sun_moon_glow_factor; +uniform int cube_snapshot; +  // NOTE: Keep these in sync!  //       indra\newview\app_settings\shaders\class1\deferred\skyV.glsl  //       indra\newview\app_settings\shaders\class1\deferred\cloudsV.glsl @@ -89,8 +91,8 @@ void main()      vary_LightNormPosDot = rel_pos_lightnorm_dot;      // Initialize temp variables -    vec3 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; - +    vec3 sunlight = (sun_up_factor == 1) ? sunlight_color*2.0 : moonlight_color*0.75; +          // Sunlight attenuation effect (hue and brightness) due to atmosphere      // this is used later for sunlight modulation at various altitudes      vec3 light_atten = (blue_density + vec3(haze_density * 0.25)) * (density_multiplier * max_y); diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index ef35bf3fd7..e7322c14fb 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -79,7 +79,6 @@ vec3 srgb_to_linear(vec3 c);  vec3 linear_to_srgb(vec3 c);  vec2 encode_normal (vec3 n); -vec3 scaleSoftClipFragLinear(vec3 l);  vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten);  void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); @@ -279,7 +278,6 @@ void main()      color.rgb = linear_to_srgb(color.rgb);      color.rgb = atmosFragLightingLinear(color.rgb, additive, atten); -    color.rgb = scaleSoftClipFragLinear(color.rgb);      color.rgb = srgb_to_linear(color.rgb);      vec4 light = vec4(0,0,0,0); diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl index 55e1411be2..0d3dbf85e2 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl @@ -62,7 +62,8 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou      vec3  rel_pos_norm = normalize(rel_pos);      float rel_pos_len  = length(rel_pos); -    vec3  sunlight     = (sun_up_factor == 1) ? sunlight_color : moonlight_color; +    float scale = 2.0; +    vec3  sunlight     = (sun_up_factor == 1) ? sunlight_color * scale: moonlight_color*0.75;      // sunlight attenuation effect (hue and brightness) due to atmosphere      // this is used later for sunlight modulation at various altitudes @@ -140,7 +141,7 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou      // fudge sunlit and amblit to get consistent lighting compared to legacy      // midday before PBR was a thing -    sunlit = sunlight.rgb * 0.7; +    sunlit = sunlight.rgb / scale;      amblit = tmpAmbient.rgb * 0.25;      additive *= vec3(1.0 - combined_haze); diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index bd06a680f5..7a5676e0ab 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -29,9 +29,6 @@  float tapScreenSpaceReflection(int totalSamples, vec2 tc, vec3 viewPos, vec3 n, inout vec4 collectedColor, sampler2D source);  #endif -#define REFMAP_COUNT 256 -#define REF_SAMPLE_COUNT 64 //maximum number of samples to consider -  uniform samplerCubeArray   reflectionProbes;  uniform samplerCubeArray   irradianceProbes;  uniform sampler2D sceneMap; @@ -95,6 +92,7 @@ bool shouldSampleProbe(int i, vec3 pos)              return false;          } +        // never allow automatic probes to encroach on box probes          sample_automatic = false;      }      else @@ -429,25 +427,19 @@ void boxIntersectDebug(vec3 origin, vec3 pos, int i, inout vec4 col)  //  dir - normal to be weighted  //  origin - center of sphere probe  //  r - radius of probe influence volume -// min_da - minimum angular attenuation coefficient  // i - index of probe in refSphere  // dw - distance weight -float sphereWeight(vec3 pos, vec3 dir, vec3 origin, float r, float min_da, int i, out float dw) +float sphereWeight(vec3 pos, vec3 dir, vec3 origin, float r, int i, out float dw)  {      float r1 = r * 0.5; // 50% of radius (outer sphere to start interpolating down)      vec3 delta = pos.xyz - origin;      float d2 = max(length(delta), 0.001); -    float r2 = r1; //r1 * r1; - -    //float atten = 1.0 - max(d2 - r2, 0.0) / max((rr - r2), 0.001); -    float atten = 1.0 - max(d2 - r2, 0.0) / max((r - r2), 0.001); +    float atten = 1.0 - max(d2 - r1, 0.0) / max((r - r1), 0.001);      float w = 1.0 / d2;      dw = w * atten * max(r, 1.0)*4; -    atten *= max(dot(normalize(-delta), dir), min_da); -      w *= atten;      return w; @@ -484,7 +476,7 @@ vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out float dw, float lod, vec3 c,          refIndex[i].w < 1 ? 4096.0*4096.0 : // <== effectively disable parallax correction for automatically placed probes to keep from bombing the world with obvious spheres                  rr); -        w = sphereWeight(pos, dir, refSphere[i].xyz, r, 0.25, i, dw); +        w = sphereWeight(pos, dir, refSphere[i].xyz, r, i, dw);      }      v -= c; @@ -524,7 +516,7 @@ vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, out float dw, vec3 c, int          refIndex[i].w < 1 ? 4096.0*4096.0 : // <== effectively disable parallax correction for automatically placed probes to keep from bombing the world with obvious spheres                  rr); -        w = sphereWeight(pos, dir, refSphere[i].xyz, r, 0.001, i, dw); +        w = sphereWeight(pos, dir, refSphere[i].xyz, r, i, dw);      }      v -= c; @@ -562,7 +554,6 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod)          float dw = 0;          vec3 refcol; -                  {              refcol = tapRefMap(pos, dir, w, dw, lod, refSphere[i].xyz, i); @@ -735,7 +726,7 @@ void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout      vec3 refnormpersp = reflect(pos.xyz, norm.xyz);      ambenv = sampleProbeAmbient(pos, norm); -     +      if (glossiness > 0.0)      {          float lod = (1.0-glossiness)*reflection_lods;  | 
