diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class2')
3 files changed, 99 insertions, 8 deletions
| diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl index 93c51ba313..e6cb8f37c7 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl @@ -196,7 +196,7 @@ void main()      vec3  irradiance = vec3(0);      vec3  radiance  = vec3(0);      sampleReflectionProbes(irradiance, radiance, pos.xyz, norm.xyz, gloss); -    irradiance       = max(amblit,irradiance); +    irradiance       = max(amblit*2.0,irradiance);      vec3 f0 = vec3(0.04); @@ -212,6 +212,9 @@ void main()      color += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm.xyz, v, light_dir) * sunlit*2.75 * scol;      color += colorEmissive; +    color = atmosFragLightingLinear(color, additive, atten); +    color  = scaleSoftClipFragLinear(color); +      vec3 light = vec3(0);      // Punctual lights @@ -227,8 +230,6 @@ void main()      color.rgb += light.rgb; -    color = atmosFragLightingLinear(color, additive, atten); -    color  = scaleSoftClipFragLinear(color); - +          frag_color = vec4(color.rgb,albedo.a * vertex_color.a);  } diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl index e578f618da..20b1e3513e 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl @@ -52,7 +52,7 @@ vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten)      light *= atten.r;      light += additive; -    return light; +    return light*2.0;  }  vec3 atmosLighting(vec3 light) diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl index e7e1938a11..516550be1c 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl @@ -22,15 +22,24 @@   * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA   * $/LicenseInfo$   */ + +vec3 srgb_to_linear(vec3 col); +  uniform vec4  lightnorm;  uniform vec4  sunlight_color; +vec3 sunlight_linear = srgb_to_linear(sunlight_color.rgb);  uniform vec4  moonlight_color; +vec3 moonlight_linear = srgb_to_linear(moonlight_color.rgb);  uniform int   sun_up_factor;  uniform vec4  ambient_color; +vec3 ambient_linear = srgb_to_linear(ambient_color.rgb);  uniform vec4  blue_horizon; +vec3 blue_horizon_linear = srgb_to_linear(blue_horizon.rgb);  uniform vec4  blue_density; +vec3 blue_density_linear = srgb_to_linear(blue_density.rgb);  uniform float haze_horizon;  uniform float haze_density; +vec3 haze_density_linear = srgb_to_linear(vec3(haze_density));  uniform float cloud_shadow;  uniform float density_multiplier;  uniform float distance_multiplier; @@ -41,8 +50,6 @@ uniform mat3  ssao_effect_mat;  uniform int   no_atmo;  uniform float sun_moon_glow_factor; -vec3 srgb_to_linear(vec3 col); -  float getAmbientClamp() { return 1.0f; }  // return colors in sRGB space @@ -136,13 +143,96 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou      additive *= vec3(1.0 - combined_haze);  } + + +  // return colors in linear space  void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive,                           out vec3 atten, bool use_ao)  { -    calcAtmosphericVars(inPositionEye, light_dir, ambFactor, sunlit, amblit, additive, atten, use_ao); +#if 0 +    calcAtmosphericVars(inPositionEye, light_dir, 1.0, sunlit, amblit, additive, atten, false);      sunlit = srgb_to_linear(sunlit)*2.25;      amblit = srgb_to_linear(amblit)*0.15;      additive = srgb_to_linear(additive);      atten = srgb_to_linear(atten); +#else +    vec3 rel_pos = inPositionEye; + +    //(TERRAIN) limit altitude +    if (abs(rel_pos.y) > max_y) rel_pos *= (max_y / rel_pos.y); + +    vec3  rel_pos_norm = normalize(rel_pos); +    float rel_pos_len  = length(rel_pos); +    vec3  sunlight     = (sun_up_factor == 1) ? sunlight_linear : moonlight_linear; + +    // sunlight attenuation effect (hue and brightness) due to atmosphere +    // this is used later for sunlight modulation at various altitudes +    vec3 light_atten = (blue_density_linear + (haze_density_linear * 0.25)) * (density_multiplier * max_y); +    // I had thought blue_density and haze_density should have equal weighting, +    // but attenuation due to haze_density tends to seem too strong + +     +    vec3 combined_haze_linear = blue_density_linear + haze_density_linear; +    vec3 combined_haze = blue_density.rgb + vec3(haze_density); +    vec3 blue_weight   = blue_density_linear / combined_haze_linear; +    vec3 haze_weight   = haze_density_linear / combined_haze_linear; + +    //(TERRAIN) compute sunlight from lightnorm y component. Factor is roughly cosecant(sun elevation) (for short rays like terrain) +    float above_horizon_factor = 1.0 / max(1e-6, lightnorm.y); +    sunlight *= exp(-light_atten * above_horizon_factor);  // for sun [horizon..overhead] this maps to an exp curve [0..1] + +    // main atmospheric scattering line integral +    float density_dist = rel_pos_len * density_multiplier; + +    // Transparency (-> combined_haze) +    // ATI Bugfix -- can't store combined_haze*density_dist*distance_multiplier in a variable because the ati +    // compiler gets confused. +    combined_haze = exp(-combined_haze * density_dist * distance_multiplier); +    combined_haze_linear = exp(-combined_haze_linear * density_dist * distance_multiplier); +    // final atmosphere attenuation factor +    atten = combined_haze.rgb; + +    // compute haze glow +    float haze_glow = dot(rel_pos_norm, lightnorm.xyz); + +    // dampen sun additive contrib when not facing it... +    // SL-13539: This "if" clause causes an "additive" white artifact at roughly 77 degreees. +    //    if (length(light_dir) > 0.01) +    haze_glow *= max(0.0f, dot(light_dir, rel_pos_norm)); + +    haze_glow = 1. - haze_glow; +    // haze_glow is 0 at the sun and increases away from sun +    haze_glow = max(haze_glow, .001);  // set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) +    haze_glow *= glow.x; +    // higher glow.x gives dimmer glow (because next step is 1 / "angle") +    haze_glow = pow(haze_glow, glow.z); +    // glow.z should be negative, so we're doing a sort of (1 / "angle") function + +    // add "minimum anti-solar illumination" +    haze_glow += .25; + +    haze_glow *= sun_moon_glow_factor; + +    vec3 amb_color = ambient_linear; + +    // increase ambient when there are more clouds +    vec3 tmpAmbient = amb_color + (vec3(1.) - amb_color) * cloud_shadow * 0.5; + +    // Similar/Shared Algorithms: +    //     indra\llinventory\llsettingssky.cpp                                        -- LLSettingsSky::calculateLightSettings() +    //     indra\newview\app_settings\shaders\class1\windlight\atmosphericsFuncs.glsl -- calcAtmosphericVars() +    // haze color +    vec3 cs = sunlight.rgb * (1. - cloud_shadow); +    additive = (blue_horizon_linear.rgb * blue_weight.rgb) * (cs + tmpAmbient.rgb) + (haze_horizon * haze_weight.rgb) * (cs * haze_glow + tmpAmbient.rgb); + +    // brightness of surface both sunlight and ambient +    sunlit = sunlight.rgb; +    amblit = tmpAmbient.rgb; +    additive *= vec3(1.0 - combined_haze_linear); + +    sunlit *= 0.8; +    amblit *= 0.05; +    additive *= 0.25; +#endif  } | 
