diff options
author | Graham Linden <graham@lindenlab.com> | 2019-04-26 16:02:21 -0700 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2019-04-26 16:02:21 -0700 |
commit | f133be068a4aa23c02c47348f5c7d4a28e1d5c37 (patch) | |
tree | 948e7fc0ed5fc01acb466f137e088a0d87ca6b64 /indra/newview/app_settings/shaders/class2/deferred | |
parent | 9d314074c9e3c898436321bdb90d3bf0d10c0079 (diff) |
Lighting WIP
Consistency across class2/3/ALM lighting.
Diffstat (limited to 'indra/newview/app_settings/shaders/class2/deferred')
3 files changed, 18 insertions, 28 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 7ccc91f73c..a82d738ec2 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -71,15 +71,8 @@ uniform vec2 screen_res; uniform mat4 inv_proj; -vec3 srgb_to_linear(vec3 cs); - vec3 getNorm(vec2 pos_screen); - -vec4 correctWithGamma(vec4 col) -{ - return vec4(srgb_to_linear(col.rgb), col.a); -} - +vec3 scaleDownLight(vec3 light); vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); @@ -220,14 +213,14 @@ void main() col = dlit*lit*diff_tex*shadow; // unshadowed for consistency between forward and deferred? - amb_da += (da*0.5+0.5)/* *(1.0-shadow) */ *proj_ambiance; + amb_da += (da*0.5+0.5) * (1.0-shadow) * proj_ambiance; } //float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0); vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod); - // unshadowed for consistency between forward and deferred? - amb_da += (da*da*0.5+0.5) /* *(1.0-shadow) */ * proj_ambiance; + // use unshadowed for consistency between forward and deferred? + amb_da += (da*da*0.5+0.5) * (1.0-shadow) * proj_ambiance; amb_da *= dist_atten * noise; amb_da = min(amb_da, 1.0-lit); @@ -259,10 +252,6 @@ void main() col += speccol; } } - - - - if (envIntensity > 0.0) { @@ -296,6 +285,8 @@ void main() //not sure why, but this line prevents MATBUG-194 col = max(col, vec3(0.0)); + col = scaleDownLight(col); + frag_color.rgb = col; frag_color.a = 0.0; } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 2d5d1c1b50..06a76668ba 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -73,6 +73,8 @@ vec3 scaleSoftClipFrag(vec3 l); void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); float getAmbientClamp(); vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten); +vec3 linear_to_srgb(vec3 c); +vec3 srgb_to_linear(vec3 c); vec4 getPositionWithDepth(vec2 pos_screen, float depth); vec4 getPosition(vec2 pos_screen); @@ -99,14 +101,14 @@ void main() float da = dot(normalize(norm.xyz), light_dir.xyz); da = clamp(da, -1.0, 1.0); - vec4 diffuse = texture2DRect(diffuseRect, tc); - + vec4 gamma_diff = texture2DRect(diffuseRect, tc); + vec4 diffuse = gamma_diff; + diffuse.rgb = srgb_to_linear(diffuse.rgb); + scol = max(scol_ambocc.r, diffuse.a); - //scol = pow(scol, light_gamma); float final_da = da; final_da = clamp(final_da, 0.0, 1.0); - //final_da = pow(final_da, light_gamma); vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); vec3 col; @@ -138,7 +140,7 @@ vec3 post_ambient = col.rgb; vec3 post_sunlight = col.rgb; - col.rgb *= diffuse.rgb; + col.rgb *= gamma_diff.rgb; vec3 post_diffuse = col.rgb; @@ -169,7 +171,7 @@ vec3 post_diffuse = col.rgb; } } - col.rgb += diffuse.a * diffuse.rgb; + col.rgb += diffuse.a * gamma_diff.rgb; if (envIntensity > 0.0) { //add environmentmap diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 2844cc8574..cd3b33eecc 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -71,13 +71,8 @@ uniform vec2 screen_res; uniform mat4 inv_proj; -vec3 srgb_to_linear(vec3 cs); vec3 getNorm(vec2 pos_screen); - -vec4 correctWithGamma(vec4 col) -{ - return vec4(srgb_to_linear(col.rgb), col.a); -} +vec3 scaleDownLight(vec3 c); vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { @@ -218,7 +213,7 @@ void main() col = dlit*lit*diff_tex*shadow; - amb_da += (da*0.5+0.5) /* * (1.0-shadow) */ * proj_ambiance; + amb_da += (da*0.5+0.5) * (1.0-shadow) * proj_ambiance; } //float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0); @@ -293,6 +288,8 @@ void main() //not sure why, but this line prevents MATBUG-194 col = max(col, vec3(0.0)); + col = scaleDownLight(col); + frag_color.rgb = col; frag_color.a = 0.0; } |