summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings
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
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')
-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
-rwxr-xr-xindra/newview/app_settings/shaders/class2/deferred/alphaV.glsl22
-rwxr-xr-xindra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl12
-rwxr-xr-xindra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl12
6 files changed, 107 insertions, 9 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)
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
index 13c6ffc607..fc60998ec3 100755
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
@@ -85,6 +85,26 @@ uniform vec3 light_diffuse[8];
uniform vec3 sun_dir;
+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;
+}
+
vec3 calcDirectionalLight(vec3 n, vec3 l)
{
float a = max(dot(n,l),0.0);
@@ -183,7 +203,7 @@ void main()
//vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.));
vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a);
- vec3 dff = pow(diffuse_color.rgb, vec3(2.2f,2.2f,2.2f));
+ vec3 dff = srgb_to_linear(diffuse_color.rgb);
vary_pointlight_col = dff;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index 14f6afc8c2..0aac9d77de 100755
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -85,9 +85,19 @@ 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));
+}
+
vec4 correctWithGamma(vec4 col)
{
- return vec4(pow(col.rgb, vec3(2.2)), col.a);
+ return vec4(srgb_to_linear(col.rgb), col.a);
}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
index 6e0218cb9c..17c0d26f6d 100755
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -85,9 +85,19 @@ 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));
+}
+
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)