summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2013-07-03 10:56:10 -0700
committerGraham Linden <graham@lindenlab.com>2013-07-03 10:56:10 -0700
commitd2855f9eecdfb80dca6c5a8b496ef9fe1b746843 (patch)
tree886cf209dcd99d249e7e53651bbcb340288177cf /indra/newview/app_settings/shaders/class1
parent37c9fcb3dac80a41c88bba8fbd992bf08b3d2ac7 (diff)
NORSPEC-293 better fix incorporating srgb_to_linear curve and applying texture gamma corrections to spot inputs
Diffstat (limited to 'indra/newview/app_settings/shaders/class1')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl24
-rwxr-xr-xindra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl24
-rwxr-xr-xindra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl22
3 files changed, 64 insertions, 6 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl
index 5aa31b96df..3d93583e1e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightAlphaMaskF.glsl
@@ -41,6 +41,26 @@ VARYING vec2 vary_texcoord0;
vec3 fullbrightAtmosTransport(vec3 light);
vec3 fullbrightScaleSoftClip(vec3 light);
+vec3 srgb_to_linear(vec3 cs)
+{
+
+/* { cs / 12.92, cs <= 0.04045
+ cl = {
+ { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/
+
+ return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4));
+}
+
+vec3 linear_to_srgb(vec3 cl)
+{
+ /*{ 0.0, 0 <= cl
+ { 12.92 * c, 0 < cl < 0.0031308
+ cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1
+ { 1.0, cl >= 1*/
+
+ return 1.055 * pow(cl, vec3(0.41666)) - 0.055;
+}
+
uniform float minimum_alpha;
void main()
@@ -56,13 +76,13 @@ void main()
discard;
}
- color.rgb = pow(color.rgb,vec3(2.2f,2.2f,2.2f));
+ color.rgb = srgb_to_linear(color.rgb);
color.rgb *= vertex_color.rgb;
color.rgb = fullbrightAtmosTransport(color.rgb);
color.rgb = fullbrightScaleSoftClip(color.rgb);
- color.rgb = pow(color.rgb, vec3(1.0/2.2));
+ color.rgb = linear_to_srgb(color.rgb);
frag_color.rgb = color.rgb;
frag_color.a = color.a;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
index 5bdb3115d9..ec25f52ef5 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
@@ -41,6 +41,25 @@ VARYING vec2 vary_texcoord0;
vec3 fullbrightAtmosTransport(vec3 light);
vec3 fullbrightScaleSoftClip(vec3 light);
+vec3 srgb_to_linear(vec3 cs)
+{
+
+/* { cs / 12.92, cs <= 0.04045
+ cl = {
+ { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/
+
+ return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4));
+}
+
+vec3 linear_to_srgb(vec3 cl)
+{
+ /*{ 0.0, 0 <= cl
+ { 12.92 * c, 0 < cl < 0.0031308
+ cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1
+ { 1.0, cl >= 1*/
+
+ return 1.055 * pow(cl, vec3(0.41666)) - 0.055;
+}
void main()
{
@@ -50,14 +69,13 @@ void main()
vec4 color = texture2D(diffuseMap, vary_texcoord0.xy);
#endif
- color.rgb = pow(color.rgb,vec3(2.2f,2.2f,2.2f));
+ color.rgb = srgb_to_linear(color.rgb);
color.rgb *= vertex_color.rgb;
color.rgb = fullbrightAtmosTransport(color.rgb);
color.rgb = fullbrightScaleSoftClip(color.rgb);
- // NORSPEC-293
- //color.rgb = pow(color.rgb, vec3(1.0/2.2));
+ color.rgb = linear_to_srgb(color.rgb);
frag_color.rgb = color.rgb;
frag_color.a = color.a;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index 045d1a00cd..61262c9eb5 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -82,9 +82,29 @@ vec3 decode_normal (vec2 enc)
return n;
}
+vec3 srgb_to_linear(vec3 cs)
+{
+
+/* { cs / 12.92, cs <= 0.04045
+ cl = {
+ { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/
+
+ return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4));
+}
+
+vec3 linear_to_srgb(vec3 cl)
+{
+ /*{ 0.0, 0 <= cl
+ { 12.92 * c, 0 < cl < 0.0031308
+ cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1
+ { 1.0, cl >= 1*/
+
+ return 1.055 * pow(cl, vec3(0.41666)) - 0.055;
+}
+
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)