summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2013-09-18 18:24:16 -0700
committerGraham Linden <graham@lindenlab.com>2013-09-18 18:24:16 -0700
commit95e34d86b9d86b3b3c7d3c39620e35b06f8fa9cf (patch)
tree5a2652bef97f1bb2d76c0b86482cebe2b2505a79 /indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
parent93503a05ec905ef2a8df39802fdc3475c961f3bc (diff)
parentad777b46d0fe5d790e43efb1771e9f64f3ad3dfb (diff)
The unbearable lightness of being norspec
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl')
-rwxr-xr-xindra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl39
1 files changed, 38 insertions, 1 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index e9e6ba9935..8d8a6c9dde 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -85,9 +85,46 @@ vec3 decode_normal (vec2 enc)
return n;
}
+vec3 srgb_to_linear(vec3 cs)
+{
+ vec3 low_range = cs / vec3(12.92);
+ vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4));
+ bvec3 lte = lessThanEqual(cs,vec3(0.04045));
+
+#ifdef OLD_SELECT
+ vec3 result;
+ result.r = lte.r ? low_range.r : high_range.r;
+ result.g = lte.g ? low_range.g : high_range.g;
+ result.b = lte.b ? low_range.b : high_range.b;
+ return result;
+#else
+ return mix(high_range, low_range, lte);
+#endif
+
+}
+
+vec3 linear_to_srgb(vec3 cl)
+{
+ cl = clamp(cl, vec3(0), vec3(1));
+ vec3 low_range = cl * 12.92;
+ vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055;
+ bvec3 lt = lessThan(cl,vec3(0.0031308));
+
+#ifdef OLD_SELECT
+ vec3 result;
+ result.r = lt.r ? low_range.r : high_range.r;
+ result.g = lt.g ? low_range.g : high_range.g;
+ result.b = lt.b ? low_range.b : high_range.b;
+ return result;
+#else
+ return mix(high_range, low_range, lt);
+#endif
+
+}
+
vec4 correctWithGamma(vec4 col)
{
- return vec4(pow(col.rgb, vec3(2.2)), col.a);
+ return vec4(srgb_to_linear(col.rgb), col.a);
}
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)