summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl9
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl96
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl21
-rw-r--r--indra/newview/llreflectionmap.cpp2
7 files changed, 115 insertions, 23 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
index 49f85af53b..50bf497605 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
@@ -370,9 +370,7 @@ vec3 pbrIbl(vec3 diffuseColor,
vec3 diffuse = diffuseLight * diffuseColor;
vec3 specular = specularLight * (specularColor * brdf.x + brdf.y);
- //specular *= 1.5;
-
- return (diffuse + specular) * ao;
+ return (diffuse + specular) * ao * 0.5; //reduce by half to place in appropriate color space for atmospherics
}
// Encapsulate the various inputs used by the various functions in the shading equation
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
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
index de18251dc4..a1125cc1dd 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
@@ -551,7 +551,7 @@ void applyGlossEnv(inout vec3 color, vec3 glossenv, vec4 spec, vec3 pos, vec3 no
fresnel *= spec.a;
glossenv *= spec.rgb*fresnel;
glossenv *= vec3(1.0) - color; // fake energy conservation
- color.rgb += glossenv;
+ color.rgb += glossenv*0.5;
}
void applyLegacyEnv(inout vec3 color, vec3 legacyenv, vec4 spec, vec3 pos, vec3 norm, float envIntensity)
@@ -562,6 +562,6 @@ void applyGlossEnv(inout vec3 color, vec3 glossenv, vec4 spec, vec3 pos, vec3 no
fresnel *= fresnel;
fresnel = min(fresnel+envIntensity, 1.0);
reflected_color *= (envIntensity*fresnel);
- color = mix(color.rgb, reflected_color, envIntensity);
+ color = mix(color.rgb, reflected_color*0.5, envIntensity);
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index c7ec1ddde9..1795f3fd1a 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -140,8 +140,7 @@ void main()
vec3 glossenv;
vec3 legacyenv;
- bool hasPBR = GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR);
- if (hasPBR)
+ if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
{
norm.xyz = getNorm(tc);
vec3 orm = texture2DRect(specularRect, tc).rgb;
@@ -157,7 +156,7 @@ void main()
vec3 radiance = vec3(0);
sampleReflectionProbes(irradiance, radiance, pos.xyz, norm.xyz, gloss);
- irradiance = max(amblit*ao,irradiance);
+ irradiance = max(amblit*2.0*ao,irradiance);
vec3 f0 = vec3(0.04);
vec3 baseColor = diffuse.rgb;
@@ -170,13 +169,19 @@ void main()
vec3 v = -normalize(pos.xyz);
float NdotV = clamp(abs(dot(norm.xyz, v)), 0.001, 1.0);
- color.rgb += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, perceptualRoughness);
color.rgb += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm.xyz, v, normalize(light_dir)) * sunlit*2.75 * scol;
color.rgb += colorEmissive;
+
+ color.rgb += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, perceptualRoughness);
color = atmosFragLightingLinear(color, additive, atten);
color = scaleSoftClipFragLinear(color);
}
+ else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS))
+ {
+ //should only be true of WL sky, just port over diffuse value
+ color = srgb_to_linear(diffuse.rgb);
+ }
else
{
// legacy shaders are still writng sRGB to gbuffer
@@ -223,12 +228,10 @@ void main()
if (envIntensity > 0.0)
{ // add environment map
applyLegacyEnv(color, legacyenv, spec, pos.xyz, norm.xyz, envIntensity);
- }
- if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS))
- {
- color = mix(atmosFragLightingLinear(color, additive, atten), fullbrightAtmosTransportFragLinear(color, additive, atten), diffuse.a);
- color = scaleSoftClipFragLinear(color);
}
+
+ color = mix(atmosFragLightingLinear(color, additive, atten), fullbrightAtmosTransportFragLinear(color, additive, atten), diffuse.a);
+ color = scaleSoftClipFragLinear(color);
}
#ifdef WATER_FOG
diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp
index d9dd1e9381..9bf1174742 100644
--- a/indra/newview/llreflectionmap.cpp
+++ b/indra/newview/llreflectionmap.cpp
@@ -43,7 +43,7 @@ void LLReflectionMap::update(U32 resolution, U32 face)
mLastUpdateTime = gFrameTimeSeconds;
llassert(mCubeArray.notNull());
llassert(mCubeIndex != -1);
- llassert(LLPipeline::sRenderDeferred);
+ //llassert(LLPipeline::sRenderDeferred);
// make sure we don't walk off the edge of the render target
while (resolution > gPipeline.mRT->deferredScreen.getWidth() ||