diff options
author | Graham Linden <graham@lindenlab.com> | 2013-07-25 09:36:13 -0700 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2013-07-25 09:36:13 -0700 |
commit | f357269c38a8627aeb67c82c5ee34b49336e0d8b (patch) | |
tree | 1bc688e9548a02799d5c90817193f1a851c74edc /indra/newview/app_settings/shaders/class2/deferred | |
parent | 24cef8d36b13c02ec06c58cc66d9bce040891069 (diff) |
NORSPEC-325 WIP restore gamma (uncorrected) attenuation and unify sRGB conversion in one place
Diffstat (limited to 'indra/newview/app_settings/shaders/class2/deferred')
3 files changed, 16 insertions, 56 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 4af0970726..6d1cedee39 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -68,6 +68,9 @@ uniform vec2 screen_res; uniform mat4 inv_proj; +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); + vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -85,22 +88,11 @@ 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(srgb_to_linear(col.rgb), col.a); } - vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); @@ -207,7 +199,7 @@ void main() proj_tc.xyz /= proj_tc.w; - float fa = falloff; + float fa = falloff+1.0; float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index fa67c4ecea..db2faa65d7 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -78,35 +78,8 @@ 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*/ - - vec3 low_range = cs / vec3(12.92); - - if (((cs.r + cs.g + cs.b) / 3) <= 0.04045) - return low_range; - - 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*/ - - cl = clamp(cl, vec3(0), vec3(1)); - - if ((cl.r+cl.g+cl.b) < 0.0031308) - return 12.92 * cl; - - return 1.055 * pow(cl, vec3(0.41666)) - 0.055; -} +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); vec2 encode_normal(vec3 n) { @@ -395,8 +368,8 @@ void main() float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); - //float light_gamma = 1.0/1.3; - //da = pow(da, light_gamma); + float light_gamma = 1.0/1.3; + da = pow(da, light_gamma); vec4 diffuse = texture2DRect(diffuseRect, tc); @@ -410,10 +383,12 @@ void main() vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; - //scol_ambocc = pow(scol_ambocc, vec2(light_gamma)); + scol_ambocc = pow(scol_ambocc, vec2(light_gamma)); float scol = max(scol_ambocc.r, diffuse.a); + + float ambocc = scol_ambocc.g; calcAtmospherics(pos.xyz, ambocc); @@ -430,7 +405,6 @@ void main() col *= diffuse.rgb; - vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); if (spec.a > 0.0) // specular reflection @@ -456,7 +430,8 @@ void main() vec3 refcol = textureCube(environmentMap, env_vec).rgb; - col = mix(col.rgb, refcol, envIntensity); + col = mix(col.rgb, refcol, + envIntensity); } diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 544a0a6730..cfb483ab54 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -85,15 +85,8 @@ 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 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); vec4 correctWithGamma(vec4 col) { @@ -204,7 +197,7 @@ void main() proj_tc.xyz /= proj_tc.w; - float fa = falloff; + float fa = falloff+1.0; float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; |