summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class2/deferred
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class2/deferred')
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl67
1 files changed, 43 insertions, 24 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