summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class2
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class2')
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl67
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl12
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl19
3 files changed, 56 insertions, 42 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index af199fd78c..fa81317f3f 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -1,5 +1,5 @@
/**
- * @file softenLightF.glsl
+ * @file class2/deferred/softenLightF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -72,17 +72,43 @@ VARYING vec2 vary_fragcoord;
uniform mat4 inv_proj;
uniform vec2 screen_res;
+uniform int no_atmo;
+
vec3 srgb_to_linear(vec3 cs);
vec3 linear_to_srgb(vec3 cl);
vec3 decode_normal (vec2 enc);
-vec3 atmosFragAmbient(vec3 l, vec3 ambient);
-vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten);
-vec3 scaleFragSoftClip(vec3 l);
-vec3 atmosFragAffectDirectionalLight(float intensity, vec3 sunlit);
void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten);
-vec3 fullbrightFragAtmosTransport(vec3 l, vec3 additive, vec3 atten);
-vec3 fullbrightScaleSoftClipFrag(vec3 l, vec3 atten);
+vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten);
+vec3 fullbrightScaleSoftClipFrag(vec3 l);
+vec3 scaleSoftClipFrag(vec3 l);
+
+vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten) {
+ if (no_atmo == 0)
+ {
+ light *= atten.r;
+ light += additive * 2.0;
+ }
+ return light;
+}
+
+vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) {
+ if (no_atmo == 1)
+ {
+ return light;
+ }
+ float brightness = dot(light.rgb, vec3(0.33333));
+ return mix(atmosTransportFrag(light.rgb, additive, atten), light.rgb + additive.rgb, brightness * brightness);
+}
+
+vec3 fullbrightShinyAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) {
+ if (no_atmo == 1)
+ {
+ return light;
+ }
+ float brightness = dot(light.rgb, vec3(0.33333));
+ return mix(atmosTransportFrag(light.rgb, additive, atten), (light.rgb + additive.rgb) * (2.0 - brightness), brightness * brightness);
+}
vec4 getPosition_d(vec2 pos_screen, float depth)
{
@@ -121,7 +147,6 @@ void main()
float light_gamma = 1.0/1.3;
da = pow(da, light_gamma);
-
vec4 diffuse = texture2DRect(diffuseRect, tc);
//convert to gamma space
@@ -136,27 +161,23 @@ void main()
scol_ambocc = pow(scol_ambocc, vec2(light_gamma));
float scol = max(scol_ambocc.r, diffuse.a);
-
-
-
float ambocc = scol_ambocc.g;
- vec3 sunlit;
- vec3 amblit;
- vec3 additive;
- vec3 atten;
+ vec3 sunlit;
+ vec3 amblit;
+ vec3 additive;
+ vec3 atten;
calcFragAtmospherics(pos.xyz, ambocc, sunlit, amblit, additive, atten);
-
- col = atmosFragAmbient(vec3(0), amblit);
+
float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0);
ambient *= 0.5;
ambient *= ambient;
ambient = (1.0-ambient);
- col.rgb *= ambient;
+ col.rgb = ambient * amblit;
- col += atmosFragAffectDirectionalLight(max(min(da, scol), 0.0), sunlit);
+ col += sunlit * max(min(da, scol), 0.0);
col *= diffuse.rgb;
@@ -173,7 +194,6 @@ void main()
bloom = dot(spec_contrib, spec_contrib) / 6;
col += spec_contrib;
}
-
col = mix(col, diffuse.rgb, diffuse.a);
@@ -186,13 +206,12 @@ void main()
if (norm.w < 0.5)
{
- vec3 add = additive;
- col = mix(atmosFragLighting(col, add, atten), fullbrightFragAtmosTransport(col, atten, add), diffuse.a);
- col = mix(scaleFragSoftClip(col), fullbrightScaleSoftClipFrag(col, atten), diffuse.a);
+ col = mix(atmosFragLighting(col, additive, atten), fullbrightAtmosTransportFrag(col, additive, atten), diffuse.a);
+ col = mix(scaleSoftClipFrag(col), fullbrightScaleSoftClipFrag(col), diffuse.a);
}
#ifdef WATER_FOG
- vec4 fogged = applyWaterFogView(pos,vec4(col, bloom));
+ vec4 fogged = applyWaterFogView(pos.xyz,vec4(col, bloom));
col = fogged.rgb;
bloom = fogged.a;
#endif
diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl
index 20c4d82ded..89bdbfc0e6 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl
@@ -43,17 +43,7 @@ uniform float scene_light_strength;
uniform mat3 ssao_effect_mat;
uniform int no_atmo;
-vec3 scaleFragSoftClip(vec3 light)
-{
- if (no_atmo == 1)
- {
- return light;
- }
- //soft clip effect:
- light = 1. - clamp(light, vec3(0.), vec3(1.));
- light = 1. - pow(light, gamma.xxx);
- return light;
-}
+vec3 scaleSoftClipFrag(vec3 light);
vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten)
{
diff --git a/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl b/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl
index f2764b72c3..187876acf7 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl
@@ -30,8 +30,8 @@ uniform int no_atmo;
vec3 getAtmosAttenuation();
-/// Soft clips the light with a gamma correction
-vec3 scaleSoftClip(vec3 light) {
+vec3 scaleSoftClipFrag(vec3 light)
+{
if (no_atmo == 1)
{
return light;
@@ -39,16 +39,21 @@ vec3 scaleSoftClip(vec3 light) {
//soft clip effect:
light = 1. - clamp(light, vec3(0.), vec3(1.));
light = 1. - pow(light, gamma.xxx);
-
return light;
}
-vec3 fullbrightScaleSoftClipFrag(vec3 light, vec3 atten)
+vec3 scaleSoftClip(vec3 light)
+{
+ return scaleSoftClipFrag(light);
+}
+
+vec3 fullbrightScaleSoftClipFrag(vec3 light)
{
- return (no_atmo == 1) ? light : mix(scaleSoftClip(light.rgb), light.rgb, atten);
+ return scaleSoftClipFrag(light.rgb);
}
-vec3 fullbrightScaleSoftClip(vec3 light) {
- return (no_atmo == 1) ? light : fullbrightScaleSoftClipFrag(light.rgb, getAtmosAttenuation());
+vec3 fullbrightScaleSoftClip(vec3 light)
+{
+ return fullbrightScaleSoftClipFrag(light.rgb);
}