diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl')
-rwxr-xr-x | indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 6e05091b57..06447261b4 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -78,6 +78,26 @@ vec3 vary_AtmosAttenuation; uniform mat4 inv_proj; uniform vec2 screen_res; +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; +} + vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -326,7 +346,7 @@ void main() vec4 diffuse = texture2DRect(diffuseRect, tc); //convert to gamma space - diffuse.rgb = pow(diffuse.rgb, vec3(1.0/2.2)); + diffuse.rgb = linear_to_srgb(diffuse.rgb); vec3 col; float bloom = 0.0; @@ -392,7 +412,7 @@ void main() col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); } - col = pow(col, vec3(2.2)); + col = srgb_to_linear(col); //col = vec3(1,0,1); //col.g = envIntensity; |