summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class2/windlight
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class2/windlight')
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl28
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersF.glsl46
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl16
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl141
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsWaterF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsWaterV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl123
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl25
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl40
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/skyF.glsl16
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/skyV.glsl65
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/transportF.glsl35
14 files changed, 277 insertions, 270 deletions
diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl
index fea3cbf69b..ee9c990b12 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl
@@ -1,5 +1,5 @@
/**
- * @file atmosphericsF.glsl
+ * @file class2\wl\atmosphericsF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -22,23 +22,25 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
-
-
-
-//////////////////////////////////////////////////////////
-// The fragment shader for the terrain atmospherics
-//////////////////////////////////////////////////////////
vec3 getAdditiveColor();
vec3 getAtmosAttenuation();
+vec3 scaleSoftClipFrag(vec3 light);
-uniform sampler2D cloudMap;
-uniform vec4 cloud_pos_density1;
+uniform int no_atmo;
-vec3 atmosLighting(vec3 light)
+vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten)
{
- light *= getAtmosAttenuation().r;
- light += getAdditiveColor();
- return (2.0 * light);
+ if (no_atmo == 1)
+ {
+ return light;
+ }
+ light *= atten.r;
+ light += additive;
+ return light * 2.0;
}
+vec3 atmosLighting(vec3 light)
+{
+ return atmosFragLighting(light, getAdditiveColor(), getAtmosAttenuation());
+}
diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersF.glsl
new file mode 100644
index 0000000000..5788871744
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersF.glsl
@@ -0,0 +1,46 @@
+/**
+ * @file class2\wl\atmosphericsHelpersV.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$
+ */
+
+// Output variables
+
+uniform float scene_light_strength;
+uniform int no_atmo;
+
+vec3 atmosFragAmbient(vec3 light, vec3 amblit)
+{
+ if (no_atmo == 1) return light;
+ return amblit + light / 2.0;
+}
+
+vec3 atmosFragAffectDirectionalLight(float lightIntensity, vec3 sunlit)
+{
+ return sunlit * lightIntensity;
+}
+
+vec3 scaleDownLightFrag(vec3 light)
+{
+ return (light / scene_light_strength );
+}
+
diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl
index 62a034ce05..9c42b84eca 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl
@@ -1,5 +1,5 @@
/**
- * @file atmosphericsHelpersV.glsl
+ * @file class2\wl\atmosphericsHelpersV.glsl
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -33,29 +33,31 @@ vec3 getAtmosAttenuation();
vec3 getPositionEye();
uniform float scene_light_strength;
+uniform int no_atmo;
-vec3 atmosAmbient(vec3 light)
+vec3 atmosAmbient()
{
- return getAmblitColor() + light / 2.0;
+ if (no_atmo == 1) return vec3(0.16);
+ return getAmblitColor();
}
vec3 atmosAffectDirectionalLight(float lightIntensity)
{
- return getSunlitColor() * lightIntensity;
+ return getSunlitColor() * lightIntensity;
}
vec3 atmosGetDiffuseSunlightColor()
{
- return getSunlitColor();
+ return getSunlitColor();
}
vec3 scaleDownLight(vec3 light)
{
- return (light / scene_light_strength );
+ return (light / scene_light_strength );
}
vec3 scaleUpLight(vec3 light)
{
- return (light * scene_light_strength);
+ return (light * scene_light_strength);
}
diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl
index d174805cc0..4c418e414f 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl
@@ -1,5 +1,5 @@
/**
- * @file atmosphericsV.glsl
+ * @file class2\wl\atmosphericsV.glsl
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -22,10 +22,14 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
-
-
// VARYING param funcs
+
+
+uniform vec3 sun_dir;
+uniform vec3 moon_dir;
+uniform int sun_up_factor;
+
void setSunlitColor(vec3 v);
void setAmblitColor(vec3 v);
void setAdditiveColor(vec3 v);
@@ -34,124 +38,19 @@ void setPositionEye(vec3 v);
vec3 getAdditiveColor();
-//VARYING vec4 vary_CloudUVs;
-//VARYING float vary_CloudDensity;
-
-// Inputs
-uniform vec4 morphFactor;
-uniform vec3 camPosLocal;
-//uniform vec4 camPosWorld;
-
-uniform vec4 lightnorm;
-uniform vec4 sunlight_color;
-uniform vec4 ambient;
-uniform vec4 blue_horizon;
-uniform vec4 blue_density;
-uniform float haze_horizon;
-uniform float haze_density;
-uniform float cloud_shadow;
-uniform float density_multiplier;
-uniform float distance_multiplier;
-uniform float max_y;
-uniform vec4 glow;
+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 calcAtmospherics(vec3 inPositionEye) {
-
- vec3 P = inPositionEye;
- setPositionEye(P);
-
- //(TERRAIN) limit altitude
- if (P.y > max_y) P *= (max_y / P.y);
- if (P.y < -max_y) P *= (-max_y / P.y);
-
- vec3 tmpLightnorm = lightnorm.xyz;
-
- vec3 Pn = normalize(P);
- float Plen = length(P);
-
- vec4 temp1 = vec4(0);
- vec3 temp2 = vec3(0);
- vec4 blue_weight;
- vec4 haze_weight;
- vec4 sunlight = sunlight_color;
- vec4 light_atten;
-
- //sunlight attenuation effect (hue and brightness) due to atmosphere
- //this is used later for sunlight modulation at various altitudes
- light_atten = (blue_density + vec4(haze_density * 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
-
- temp1 = blue_density + vec4(haze_density);
- blue_weight = blue_density / temp1;
- haze_weight = vec4(haze_density) / temp1;
-
- //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain)
- temp2.y = max(0.0, tmpLightnorm.y);
- temp2.y = 1. / temp2.y;
- sunlight *= exp( - light_atten * temp2.y);
-
- // main atmospheric scattering line integral
- temp2.z = Plen * density_multiplier;
-
- // Transparency (-> temp1)
- // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati
- // compiler gets confused.
- temp1 = exp(-temp1 * temp2.z * distance_multiplier);
-
- //final atmosphere attenuation factor
- setAtmosAttenuation(temp1.rgb);
- //vary_AtmosAttenuation = distance_multiplier / 10000.;
- //vary_AtmosAttenuation = density_multiplier * 100.;
- //vary_AtmosAttenuation = vec4(Plen / 100000., 0., 0., 1.);
-
- //compute haze glow
- //(can use temp2.x as temp because we haven't used it yet)
- temp2.x = dot(Pn, tmpLightnorm.xyz);
- temp2.x = 1. - temp2.x;
- //temp2.x is 0 at the sun and increases away from sun
- temp2.x = max(temp2.x, .03); //was glow.y
- //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot)
- temp2.x *= glow.x;
- //higher glow.x gives dimmer glow (because next step is 1 / "angle")
- temp2.x = pow(temp2.x, glow.z);
- //glow.z should be negative, so we're doing a sort of (1 / "angle") function
-
- //add "minimum anti-solar illumination"
- temp2.x += .25;
-
-
- //increase ambient when there are more clouds
- vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5;
-
- //haze color
- setAdditiveColor(
- vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient)
- + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x
- + tmpAmbient)));
-
- //brightness of surface both sunlight and ambient
- setSunlitColor(vec3(sunlight * .5));
- setAmblitColor(vec3(tmpAmbient * .25));
- setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1));
-
- // vary_SunlitColor = vec3(0);
- // vary_AmblitColor = vec3(0);
- // vary_AdditiveColor = vec4(Pn, 1.0);
-
- /*
- const float cloudShadowScale = 100.;
- // Get cloud uvs for shadowing
- vec3 cloudPos = inPositionEye + camPosWorld - cloudShadowScale / 2.;
- vary_CloudUVs.xy = cloudPos.xz / cloudShadowScale;
-
- // We can take uv1 and multiply it by (TerrainSpan / CloudSpan)
-// cloudUVs *= (((worldMaxZ - worldMinZ) * 20) /40000.);
- vary_CloudUVs *= (10000./40000.);
-
- // Offset by sun vector * (CloudAltitude / CloudSpan)
- vary_CloudUVs.x += tmpLightnorm.x / tmpLightnorm.y * (3000./40000.);
- vary_CloudUVs.y += tmpLightnorm.z / tmpLightnorm.y * (3000./40000.);
- */
+ vec3 P = inPositionEye;
+ setPositionEye(P);
+ vec3 tmpsunlit = vec3(1);
+ vec3 tmpamblit = vec3(1);
+ vec3 tmpaddlit = vec3(1);
+ vec3 tmpattenlit = vec3(1);
+ vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
+ calcAtmosphericVars(inPositionEye, light_dir, 1, tmpsunlit, tmpamblit, tmpaddlit, tmpattenlit, false);
+ setSunlitColor(tmpsunlit);
+ setAmblitColor(tmpamblit);
+ setAdditiveColor(tmpaddlit);
+ setAtmosAttenuation(tmpattenlit);
}
-
diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl
index 765b0927c3..d758f85d71 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl
@@ -1,5 +1,5 @@
/**
- * @file atmosphericVars.glsl
+ * @file class2\wl\atmosphericVars.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -24,7 +24,6 @@
*/
-VARYING vec3 vary_SunlitColor;
VARYING vec3 vary_AdditiveColor;
VARYING vec3 vary_AtmosAttenuation;
@@ -32,14 +31,17 @@ vec3 getSunlitColor()
{
return vec3(0,0,0);
}
+
vec3 getAmblitColor()
{
return vec3(0,0,0);
}
+
vec3 getAdditiveColor()
{
return vary_AdditiveColor;
}
+
vec3 getAtmosAttenuation()
{
return vec3(vary_AtmosAttenuation);
diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl
index 99dbee15ee..31109aed31 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl
@@ -1,5 +1,5 @@
/**
- * @file atmosphericVars.glsl
+ * @file class2\wl\atmosphericVars.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsWaterF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsWaterF.glsl
index 163ef26444..22e16b7e0f 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsWaterF.glsl
@@ -1,5 +1,5 @@
/**
- * @file atmosphericVarsWaterF.glsl
+ * @file class2\wl\atmosphericVarsWaterF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsWaterV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsWaterV.glsl
index 553f6752e6..0f2a3ee527 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsWaterV.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsWaterV.glsl
@@ -1,5 +1,5 @@
/**
- * @file atmosphericVarsWaterV.glsl
+ * @file class2\wl\atmosphericVarsWaterV.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl
index 96c70651b1..75bf8730df 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl
@@ -1,5 +1,5 @@
/**
- * @file WLCloudsF.glsl
+ * @file class2\wl\cloudsF.glsl
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -22,11 +22,13 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
-
+
+/*[EXTRA_CODE_HERE]*/
+
#ifdef DEFINE_GL_FRAGCOLOR
-out vec4 frag_color;
+out vec4 frag_data[3];
#else
-#define frag_color gl_FragColor
+#define frag_data gl_FragData
#endif
/////////////////////////////////////////////////////////////////////////
@@ -36,69 +38,96 @@ out vec4 frag_color;
VARYING vec4 vary_CloudColorSun;
VARYING vec4 vary_CloudColorAmbient;
VARYING float vary_CloudDensity;
-VARYING vec2 vary_texcoord0;
-VARYING vec2 vary_texcoord1;
-VARYING vec2 vary_texcoord2;
-VARYING vec2 vary_texcoord3;
uniform sampler2D cloud_noise_texture;
+uniform sampler2D cloud_noise_texture_next;
+uniform float blend_factor;
uniform vec4 cloud_pos_density1;
uniform vec4 cloud_pos_density2;
-uniform vec4 gamma;
+uniform float cloud_scale;
+uniform float cloud_variance;
+
+VARYING vec2 vary_texcoord0;
+VARYING vec2 vary_texcoord1;
+VARYING vec2 vary_texcoord2;
+VARYING vec2 vary_texcoord3;
+VARYING float altitude_blend_factor;
/// Soft clips the light with a gamma correction
-vec3 scaleSoftClip(vec3 light) {
- //soft clip effect:
- light = 1. - clamp(light, vec3(0.), vec3(1.));
- light = 1. - pow(light, gamma.xxx);
+vec3 scaleSoftClip(vec3 light);
- return light;
+vec4 cloudNoise(vec2 uv)
+{
+ vec4 a = texture2D(cloud_noise_texture, uv);
+ vec4 b = texture2D(cloud_noise_texture_next, uv);
+ vec4 cloud_noise_sample = mix(a, b, blend_factor);
+ return cloud_noise_sample;
}
void main()
{
- // Set variables
- vec2 uv1 = vary_texcoord0.xy;
- vec2 uv2 = vary_texcoord1.xy;
+ // Set variables
+ vec2 uv1 = vary_texcoord0.xy;
+ vec2 uv2 = vary_texcoord1.xy;
+
+ vec4 cloudColorSun = vary_CloudColorSun;
+ vec4 cloudColorAmbient = vary_CloudColorAmbient;
+ float cloudDensity = vary_CloudDensity;
+ vec2 uv3 = vary_texcoord2.xy;
+ vec2 uv4 = vary_texcoord3.xy;
+
+ if (cloud_scale < 0.001)
+ {
+ discard;
+ }
+
+ vec2 disturbance = vec2(cloudNoise(uv1 / 8.0f).x, cloudNoise((uv3 + uv1) / 16.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f);
+ vec2 disturbance2 = vec2(cloudNoise((uv1 + uv3) / 4.0f).x, cloudNoise((uv4 + uv2) / 8.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f);
+
+ // Offset texture coords
+ uv1 += cloud_pos_density1.xy + (disturbance * 0.2); //large texture, visible density
+ uv2 += cloud_pos_density1.xy; //large texture, self shadow
+ uv3 += cloud_pos_density2.xy; //small texture, visible density
+ uv4 += cloud_pos_density2.xy; //small texture, self shadow
+
+ float density_variance = min(1.0, (disturbance.x* 2.0 + disturbance.y* 2.0 + disturbance2.x + disturbance2.y) * 4.0);
- vec4 cloudColorSun = vary_CloudColorSun;
- vec4 cloudColorAmbient = vary_CloudColorAmbient;
- float cloudDensity = vary_CloudDensity;
- vec2 uv3 = vary_texcoord2.xy;
- vec2 uv4 = vary_texcoord3.xy;
+ cloudDensity *= 1.0 - (density_variance * density_variance);
- // Offset texture coords
- uv1 += cloud_pos_density1.xy; //large texture, visible density
- uv2 += cloud_pos_density1.xy; //large texture, self shadow
- uv3 += cloud_pos_density2.xy; //small texture, visible density
- uv4 += cloud_pos_density2.xy; //small texture, self shadow
+ // Compute alpha1, the main cloud opacity
+ float alpha1 = (cloudNoise(uv1).x - 0.5) + (cloudNoise(uv3).x - 0.5) * cloud_pos_density2.z;
+ alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10 * cloud_pos_density1.z, 1.);
- // Compute alpha1, the main cloud opacity
- float alpha1 = (texture2D(cloud_noise_texture, uv1).x - 0.5) + (texture2D(cloud_noise_texture, uv3).x - 0.5) * cloud_pos_density2.z;
- alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10. * cloud_pos_density1.z, 1.);
+ // And smooth
+ alpha1 = 1. - alpha1 * alpha1;
+ alpha1 = 1. - alpha1 * alpha1;
- // And smooth
- alpha1 = 1. - alpha1 * alpha1;
- alpha1 = 1. - alpha1 * alpha1;
+ alpha1 *= altitude_blend_factor;
+ //if (alpha1 < 0.001f)
+ //{
+ // discard;
+ //}
- // Compute alpha2, for self shadowing effect
- // (1 - alpha2) will later be used as percentage of incoming sunlight
- float alpha2 = (texture2D(cloud_noise_texture, uv2).x - 0.5);
- alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.);
+ // Compute alpha2, for self shadowing effect
+ // (1 - alpha2) will later be used as percentage of incoming sunlight
+ float alpha2 = (cloudNoise(uv2).x - 0.5);
+ alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.);
- // And smooth
- alpha2 = 1. - alpha2;
- alpha2 = 1. - alpha2 * alpha2;
+ // And smooth
+ alpha2 = 1. - alpha2;
+ alpha2 = 1. - alpha2 * alpha2;
- // Combine
- vec4 color;
- color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient);
- color *= 2.;
+ // Combine
+ vec4 color;
+ color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient);
+ color.rgb *= 2.;
+ color.rgb = scaleSoftClip(color.rgb);
- /// Gamma correct for WL (soft clip effect).
- frag_color.rgb = scaleSoftClip(color.rgb);
- frag_color.a = alpha1;
+ /// Gamma correct for WL (soft clip effect).
+ frag_data[0] = vec4(color.rgb, alpha1);
+ frag_data[1] = vec4(0.0,0.0,0.0,0.0);
+ frag_data[2] = vec4(0,0,0,1);
}
diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
index c1dd45cd67..2c1475d547 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
@@ -1,5 +1,5 @@
/**
- * @file WLCloudsV.glsl
+ * @file class2\wl\cloudsV.glsl
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -40,13 +40,16 @@ VARYING vec2 vary_texcoord0;
VARYING vec2 vary_texcoord1;
VARYING vec2 vary_texcoord2;
VARYING vec2 vary_texcoord3;
+VARYING float altitude_blend_factor;
// Inputs
uniform vec3 camPosLocal;
uniform vec4 lightnorm;
uniform vec4 sunlight_color;
-uniform vec4 ambient;
+uniform vec4 moonlight_color;
+uniform int sun_up_factor;
+uniform vec4 ambient_color;
uniform vec4 blue_horizon;
uniform vec4 blue_density;
uniform float haze_horizon;
@@ -57,6 +60,7 @@ uniform float density_multiplier;
uniform float max_y;
uniform vec4 glow;
+uniform float sun_moon_glow_factor;
uniform vec4 cloud_color;
@@ -73,6 +77,9 @@ void main()
// Get relative position
vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0);
+ // fade clouds beyond a certain point so the bottom of the sky dome doesn't look silly at high altitude
+ altitude_blend_factor = clamp((P.y + 512.0) / max_y, 0.0, 1.0);
+
// Set altitude
if (P.y > 0.)
{
@@ -92,16 +99,18 @@ void main()
vec4 temp2 = vec4(0.);
vec4 blue_weight;
vec4 haze_weight;
+ //vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color;
vec4 sunlight = sunlight_color;
vec4 light_atten;
+ float dens_mul = density_multiplier;
// Sunlight attenuation effect (hue and brightness) due to atmosphere
// this is used later for sunlight modulation at various altitudes
- light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y);
+ light_atten = (blue_density + vec4(haze_density * 0.25)) * (dens_mul * max_y);
// Calculate relative weights
- temp1 = blue_density + haze_density;
+ temp1 = abs(blue_density) + vec4(abs(haze_density));
blue_weight = blue_density / temp1;
haze_weight = haze_density / temp1;
@@ -111,7 +120,7 @@ void main()
sunlight *= exp( - light_atten * temp2.y);
// Distance
- temp2.z = Plen * density_multiplier;
+ temp2.z = Plen * dens_mul;
// Transparency (-> temp1)
// ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati
@@ -130,11 +139,13 @@ void main()
temp2.x = pow(temp2.x, glow.z);
// glow.z should be negative, so we're doing a sort of (1 / "angle") function
+ temp2.x *= sun_moon_glow_factor;
+
// Add "minimum anti-solar illumination"
temp2.x += .25;
// Increase ambient when there are more clouds
- vec4 tmpAmbient = ambient;
+ vec4 tmpAmbient = ambient_color;
tmpAmbient += (1. - tmpAmbient) * cloud_shadow * 0.5;
// Dim sunlight by cloud shadow percentage
@@ -146,8 +157,6 @@ void main()
);
// CLOUDS
-
- sunlight = sunlight_color;
temp2.y = max(0., lightnorm.y * 2.);
temp2.y = 1. / temp2.y;
sunlight *= exp( - light_atten * temp2.y);
diff --git a/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl b/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl
index 478373d729..68db7fcbb1 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl
@@ -1,5 +1,5 @@
/**
- * @file gammaF.glsl
+ * @file class2\wl\gammaF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -22,23 +22,37 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
-
-
-
-uniform vec4 gamma;
+uniform float gamma;
+uniform int no_atmo;
vec3 getAtmosAttenuation();
+vec3 getAdditiveColor();
-/// Soft clips the light with a gamma correction
-vec3 scaleSoftClip(vec3 light) {
- //soft clip effect:
- light = 1. - clamp(light, vec3(0.), vec3(1.));
- light = 1. - pow(light, gamma.xxx);
+vec3 scaleSoftClipFrag(vec3 light)
+{
+ if (no_atmo == 1)
+ {
+ return light;
+ }
+ //soft clip effect:
+ light = 1. - clamp(light, vec3(0.), vec3(1.));
+ light = 1. - pow(light, vec3(gamma)); // s/b inverted already CPU-side
+ return light;
+}
+
+vec3 scaleSoftClip(vec3 light)
+{
+ return scaleSoftClipFrag(light);
+}
- return light;
+vec3 fullbrightScaleSoftClipFrag(vec3 light, vec3 add, vec3 atten)
+{
+ //return mix(scaleSoftClipFrag(light.rgb), add, atten);
+ return scaleSoftClipFrag(light.rgb);
}
-vec3 fullbrightScaleSoftClip(vec3 light) {
- return mix(scaleSoftClip(light.rgb), light.rgb, getAtmosAttenuation());
+vec3 fullbrightScaleSoftClip(vec3 light)
+{
+ return fullbrightScaleSoftClipFrag(light, getAdditiveColor(), getAtmosAttenuation());
}
diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl
index e2a2367626..7146349453 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl
@@ -1,5 +1,5 @@
/**
- * @file WLSkyF.glsl
+ * @file class2/windlight/skyF.glsl
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -35,17 +35,8 @@ out vec4 frag_color;
VARYING vec4 vary_HazeColor;
-uniform sampler2D cloud_noise_texture;
-uniform vec4 gamma;
-
/// Soft clips the light with a gamma correction
-vec3 scaleSoftClip(vec3 light) {
- //soft clip effect:
- light = 1. - clamp(light, vec3(0.), vec3(1.));
- light = 1. - pow(light, gamma.xxx);
-
- return light;
-}
+vec3 scaleSoftClip(vec3 light);
void main()
{
@@ -56,8 +47,7 @@ void main()
vec4 color;
color = vary_HazeColor;
- color *= 2.;
-
+ color.rgb *= 2.;
/// Gamma correct for WL (soft clip effect).
frag_color.rgb = scaleSoftClip(color.rgb);
frag_color.a = 1.0;
diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl
index 3788ddaf2d..0d141342ce 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl
@@ -1,5 +1,5 @@
/**
- * @file WLSkyV.glsl
+ * @file class2\wl\skyV.glsl
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -39,7 +39,9 @@ uniform vec3 camPosLocal;
uniform vec4 lightnorm;
uniform vec4 sunlight_color;
-uniform vec4 ambient;
+uniform vec4 moonlight_color;
+uniform int sun_up_factor;
+uniform vec4 ambient_color;
uniform vec4 blue_horizon;
uniform vec4 blue_density;
uniform float haze_horizon;
@@ -47,9 +49,11 @@ uniform float haze_density;
uniform float cloud_shadow;
uniform float density_multiplier;
+uniform float distance_multiplier;
uniform float max_y;
uniform vec4 glow;
+uniform float sun_moon_glow_factor;
uniform vec4 cloud_color;
@@ -57,11 +61,12 @@ void main()
{
// World / view / projection
- gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+ vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
+ gl_Position = pos;
+
// Get relative position
vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0);
- //vec3 P = position.xyz + vec3(0,50,0);
// Set altitude
if (P.y > 0.)
@@ -75,38 +80,40 @@ void main()
// Can normalize then
vec3 Pn = normalize(P);
- float Plen = length(P);
+
+ float Plen = length(P);
// Initialize temp variables
vec4 temp1 = vec4(0.);
vec4 temp2 = vec4(0.);
vec4 blue_weight;
vec4 haze_weight;
- vec4 sunlight = sunlight_color;
+ vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color;
vec4 light_atten;
+ float dens_mul = density_multiplier;
+
// Sunlight attenuation effect (hue and brightness) due to atmosphere
// this is used later for sunlight modulation at various altitudes
- light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y);
+ light_atten = (blue_density + vec4(haze_density * 0.25)) * (dens_mul * max_y);
// Calculate relative weights
- temp1 = blue_density + haze_density;
+ temp1 = abs(blue_density) + vec4(abs(haze_density));
blue_weight = blue_density / temp1;
haze_weight = haze_density / temp1;
// Compute sunlight from P & lightnorm (for long rays like sky)
- temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y );
- temp2.y = 1. / temp2.y;
- sunlight *= exp( - light_atten * temp2.y);
+ temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y );
+ temp2.y = 1. / temp2.y;
+ sunlight *= exp( - light_atten * temp2.y);
// Distance
- temp2.z = Plen * density_multiplier;
+ temp2.z = Plen * dens_mul;
// Transparency (-> temp1)
- // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati
- // compiler gets confused.
- temp1 = exp(-temp1 * temp2.z);
-
+ // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati
+ // compiler gets confused.
+ temp1 = exp(-temp1 * temp2.z);
// Compute haze glow
temp2.x = dot(Pn, lightnorm.xyz);
@@ -122,35 +129,33 @@ void main()
// Add "minimum anti-solar illumination"
temp2.x += .25;
+ vec4 color = ( blue_horizon * blue_weight * (sunlight + ambient_color)
+ + (haze_horizon * haze_weight) * (sunlight * temp2.x + ambient_color)
+ );
- // Haze color above cloud
- vary_HazeColor = ( blue_horizon * blue_weight * (sunlight + ambient)
- + (haze_horizon * haze_weight) * (sunlight * temp2.x + ambient)
- );
+ // Final atmosphere additive
+ color *= (1. - temp1);
// Increase ambient when there are more clouds
- vec4 tmpAmbient = ambient;
- tmpAmbient += (1. - tmpAmbient) * cloud_shadow * 0.5;
+ vec4 tmpAmbient = ambient_color;
+ tmpAmbient += max(vec4(0), (1. - ambient_color)) * cloud_shadow * 0.5;
// Dim sunlight by cloud shadow percentage
- sunlight *= (1. - cloud_shadow);
+ sunlight *= max(0.0, (1. - cloud_shadow));
// Haze color below cloud
vec4 additiveColorBelowCloud = ( blue_horizon * blue_weight * (sunlight + tmpAmbient)
+ (haze_horizon * haze_weight) * (sunlight * temp2.x + tmpAmbient)
);
- // Final atmosphere additive
- vary_HazeColor *= (1. - temp1);
-
// Attenuate cloud color by atmosphere
temp1 = sqrt(temp1); //less atmos opacity (more transparency) below clouds
// At horizon, blend high altitude sky color towards the darker color below the clouds
- vary_HazeColor += (additiveColorBelowCloud - vary_HazeColor) * (1. - sqrt(temp1));
-
- // won't compile on mac without this being set
- //vary_AtmosAttenuation = vec3(0.0,0.0,0.0);
+ color += (additiveColorBelowCloud - color) * (1. - sqrt(temp1));
+
+ // Haze color above cloud
+ vary_HazeColor = color;
}
diff --git a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl
index 8a8e4cb0f6..b53a2e237f 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl
@@ -1,5 +1,5 @@
/**
- * @file transportF.glsl
+ * @file class2\wl\transportF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -30,24 +30,33 @@
vec3 getAdditiveColor();
vec3 getAtmosAttenuation();
-uniform sampler2D cloudMap;
-uniform vec4 cloud_pos_density1;
+uniform int no_atmo;
-vec3 atmosTransport(vec3 light) {
- light *= getAtmosAttenuation().r;
- light += getAdditiveColor() * 2.0;
+vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten)
+{
+ light *= atten.r;
+ light += additive * 2.0;
return light;
}
-vec3 fullbrightAtmosTransport(vec3 light) {
- float brightness = dot(light.rgb, vec3(0.33333));
-
- return mix(atmosTransport(light.rgb), light.rgb + getAdditiveColor().rgb, brightness * brightness);
+vec3 atmosTransport(vec3 light)
+{
+ return atmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation());
}
-vec3 fullbrightShinyAtmosTransport(vec3 light) {
- float brightness = dot(light.rgb, vec3(0.33333));
+vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten)
+{
+ float brightness = dot(light.rgb * 0.5, vec3(0.3333)) + 0.1;
+ return mix(atmosTransportFrag(light.rgb, additive, atten), light.rgb + additive, brightness * brightness);
+}
- return mix(atmosTransport(light.rgb), (light.rgb + getAdditiveColor().rgb) * (2.0 - brightness), brightness * brightness);
+vec3 fullbrightAtmosTransport(vec3 light)
+{
+ return fullbrightAtmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation());
}
+vec3 fullbrightShinyAtmosTransport(vec3 light)
+{
+ float brightness = dot(light.rgb, vec3(0.33333));
+ return mix(atmosTransport(light.rgb), (light.rgb + getAdditiveColor().rgb) * (2.0 - brightness), brightness * brightness);
+}