diff options
author | Graham Linden <graham@lindenlab.com> | 2019-02-22 17:03:11 -0800 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2019-02-22 17:03:11 -0800 |
commit | bc86ad9523460ae883ea840d7b11c9de542a14aa (patch) | |
tree | a2325e2740e561665ef8ae0b621b8c7705f9836f | |
parent | 930e4456f12b60865bd8706611f36aeed8525722 (diff) |
SL-5186
Add ambiance handling to the light loop in the forward incarnation of materialF
and tweak alphaF to match lighing of material alpha-blend objects and non-ALM rendering.
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 10 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/materialF.glsl | 37 |
2 files changed, 23 insertions, 24 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 1ba10fa8b7..948a195b7a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -60,7 +60,7 @@ VARYING vec4 vertex_color; uniform mat4 inv_proj; uniform vec2 screen_res; - +uniform int sun_up_factor; uniform vec4 light_position[8]; uniform vec3 light_direction[8]; uniform vec4 light_attenuation[8]; @@ -173,13 +173,13 @@ void main() vec2 abnormal = encode_normal(norm.xyz); - float sun_da = dot(norm.xyz, sun_dir.xyz); - float moon_da = dot(norm.xyz, moon_dir.xyz); + vec3 light_dir = (sun_up_factor == 1) ? sun_dir: moon_dir; + float da = dot(norm.xyz, light_dir.xyz); - float final_da = max(sun_da, moon_da); + float final_da = da; final_da = min(final_da, shadow); final_da = clamp(final_da, 0.0f, 1.0f); - final_da = pow(final_da, display_gamma); + final_da = pow(final_da, 1.0/display_gamma); vec4 color = vec4(0,0,0,0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 251e60c59e..6dcfaddd44 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -32,6 +32,7 @@ uniform float emissive_brightness; uniform float display_gamma; +uniform int sun_up_factor; #ifdef WATER_FOG vec4 applyWaterFogView(vec3 pos, vec4 color); @@ -77,10 +78,10 @@ uniform vec2 screen_res; uniform vec4 light_position[8]; uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; +uniform vec4 light_attenuation[8]; uniform vec3 light_diffuse[8]; -vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spec, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, inout float glare) +vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spec, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, inout float glare, float ambiance) { //get light vector vec3 lv = lp.xyz-v; @@ -114,6 +115,12 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe col = light_col*lit*diffuse; + float amb_da = (da*da*0.5 + 0.25) * ambiance; + amb_da *= dist_atten; + amb_da = min(amb_da, 1.0f - lit); + + col.rgb += amb_da * light_col * diffuse; + if (spec.a > 0.0) { //vec3 ref = dot(pos+lv, norm); @@ -203,7 +210,6 @@ void main() #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) vec3 gamma_diff = diffcol.rgb; - diffcol.rgb = srgb_to_linear(diffcol.rgb); #endif #if HAS_SPECULAR_MAP @@ -271,15 +277,14 @@ void main() vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); - float sun_da = dot(norm.xyz, sun_dir.xyz); - float moon_da = dot(norm.xyz, moon_dir.xyz); + vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; + float da = dot(norm.xyz, light_dir.xyz); - float final_da = max(sun_da,moon_da); + float final_da = da; final_da = min(final_da, shadow); //final_da = max(final_da, diffuse.a); final_da = max(final_da, 0.0f); final_da = min(final_da, 1.0f); - final_da = pow(final_da, display_gamma); col.rgb = amblit; @@ -289,8 +294,9 @@ void main() ambient = (1.0-ambient); col.rgb *= min(ambient, max(shadow,0.3)); + col.rgb += (final_da * sunlit); - col.rgb *= gamma_diff.rgb; + col.rgb *= diffuse.rgb; float glare = 0.0; @@ -315,7 +321,7 @@ void main() vec3 post_spec = col.rgb; - col = mix(col.rgb, diffcol.rgb, diffuse.a); + col = mix(col.rgb, diffuse.rgb, diffuse.a); if (envIntensity > 0.0) { @@ -333,8 +339,8 @@ vec3 post_spec = col.rgb; glare += cur_glare; } - col = atmosFragLighting(col, additive, atten); - col = scaleSoftClipFrag(col); + //col = atmosFragLighting(col, additive, atten); + //col = scaleSoftClipFrag(col); vec3 post_atmo= col.rgb; @@ -342,7 +348,7 @@ vec3 post_atmo= col.rgb; vec3 light = vec3(0,0,0); - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare, light_attenuation[i].w); LIGHT_LOOP(1) LIGHT_LOOP(2) @@ -359,19 +365,12 @@ vec3 post_lighting = col.rgb; glare = min(glare, 1.0); float al = max(diffcol.a,glare)*vertex_color.a; - //convert to gamma space for display on screen - col.rgb = linear_to_srgb(col.rgb); - -vec3 post_srgb = col.rgb; - #ifdef WATER_FOG vec4 temp = applyWaterFogView(pos, vec4(col.rgb, al)); col.rgb = temp.rgb; al = temp.a; #endif -//col.rgb = post_lighting; - frag_color.rgb = col.rgb; frag_color.a = al; |