diff options
author | Rider Linden <rider@lindenlab.com> | 2019-02-22 15:05:13 -0800 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2019-02-22 15:05:13 -0800 |
commit | 0aa46bb013e888d437054bfb31efe5fa1136d1ba (patch) | |
tree | cf36b48b801a57c8c1f6691e7112980d8f9ab1c8 /indra/newview/app_settings/shaders | |
parent | 8382cc2f2c2944e8a2a47e30dc22b1eb99ce34cb (diff) | |
parent | 8bebb385fe1f7df22c7fd040eceaaf1b3bcbef75 (diff) |
Merge
Diffstat (limited to 'indra/newview/app_settings/shaders')
3 files changed, 39 insertions, 30 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index c8f4d7c570..251e60c59e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -202,7 +202,8 @@ void main() #endif #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - vec3 gamma_diff = linear_to_srgb(diffcol.rgb); + vec3 gamma_diff = diffcol.rgb; + diffcol.rgb = srgb_to_linear(diffcol.rgb); #endif #if HAS_SPECULAR_MAP @@ -280,20 +281,17 @@ void main() final_da = min(final_da, 1.0f); final_da = pow(final_da, display_gamma); - col.rgb = (col * 0.5) + amblit; + col.rgb = amblit; float ambient = min(abs(final_da), 1.0); ambient *= 0.5; ambient *= ambient; ambient = (1.0-ambient); - col.rgb *= ambient; - - col.rgb = col.rgb + (final_da * sunlit); - + col.rgb *= min(ambient, max(shadow,0.3)); + col.rgb += (final_da * sunlit); col.rgb *= gamma_diff.rgb; - float glare = 0.0; if (spec.a > 0.0) // specular reflection @@ -315,6 +313,7 @@ void main() col += spec_contrib; } +vec3 post_spec = col.rgb; col = mix(col.rgb, diffcol.rgb, diffuse.a); @@ -337,6 +336,8 @@ void main() col = atmosFragLighting(col, additive, atten); col = scaleSoftClipFrag(col); +vec3 post_atmo= col.rgb; + vec3 npos = normalize(-pos.xyz); vec3 light = vec3(0,0,0); @@ -353,18 +354,24 @@ void main() col.rgb += light.rgb; +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; diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl index 5cc24475e3..ad96c84de8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl @@ -49,8 +49,8 @@ uniform int sun_up_factor; float pcfShadow(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul, vec2 pos_screen, vec3 light_dir) { stc.xyz /= stc.w; - stc.z += shadow_bias * bias_mul* 2.0; - stc.x = floor(stc.x*shadow_res.x + fract(stc.y*pos_screen.y*pos_screen.x))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here + stc.z += shadow_bias * bias_mul * 2.0; + stc.x = floor(stc.x*shadow_res.x + fract(stc.y*shadow_res.y))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here float cs = shadow2D(shadowMap, stc.xyz).x; float shadow = cs * 4.0; @@ -90,7 +90,9 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) dp_directional_light = clamp(dp_directional_light, 0.0, 1.0); vec3 shadow_pos = pos.xyz; - vec3 offset = abs(light_dir.xyz) * (1.0 - dp_directional_light* 0.8); + + vec3 offset = light_dir.xyz * (1.0 - dp_directional_light); + shadow_pos += offset * shadow_offset; vec4 spos = vec4(shadow_pos.xyz, 1.0); @@ -109,7 +111,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) float w = 1.0; w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap3, norm, lpos, 4.0, pos_screen, light_dir)*w; + shadow += pcfShadow(shadowMap3, norm, lpos, 1.0, pos_screen, light_dir)*w; weight += w; shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); } @@ -121,7 +123,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) float w = 1.0; w -= max(spos.z-far_split.y, 0.0)/transition_domain.y; w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap2, norm, lpos, 2.0, pos_screen, light_dir)*w; + shadow += pcfShadow(shadowMap2, norm, lpos, 1.0, pos_screen, light_dir)*w; weight += w; } @@ -153,6 +155,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) { return 1.0f; // lit beyond the far split... } + shadow = min(dp_directional_light,shadow); return shadow; } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 8bc9add5cf..7fd4d7e248 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -90,17 +90,16 @@ void main() vec4 norm = texture2DRect(normalMap, tc); float envIntensity = norm.z; norm.xyz = getNorm(tc); // unpack norm - - float da_sun = dot(norm.xyz, sun_dir.xyz); - float da_moon = dot(norm.xyz, moon_dir.xyz); - float da = (sun_up_factor == 1) ? da_sun : da_moon; - da = clamp(da, 0.0, 1.0); - da = pow(da, global_gamma + 0.3); + vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; + + float da = dot(norm.xyz, light_dir.xyz); + da = clamp(da, 0.0, 1.0); vec4 diffuse = texture2DRect(diffuseRect, tc); vec3 col; + float scol = 1.0; float bloom = 0.0; { vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); @@ -108,9 +107,13 @@ void main() vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; scol_ambocc = pow(scol_ambocc, vec2(global_gamma + 0.3)); - float scol = max(scol_ambocc.r, diffuse.a); + scol = max(scol_ambocc.r, diffuse.a); float ambocc = scol_ambocc.g; + float final_da = da; + final_da = min(final_da, scol); + final_da = pow(final_da, global_gamma + 0.3); + vec3 sunlit; vec3 amblit; vec3 additive; @@ -118,18 +121,17 @@ void main() calcFragAtmospherics(pos.xyz, ambocc, sunlit, amblit, additive, atten); - float ambient = da; - + float ambient = min(da, 1.0); ambient *= 0.5; ambient *= ambient; - ambient = (1.0-ambient); - - col.rgb = amblit; - col.rgb *= min(ambient, max(scol, 0.5)); + ambient = min(1.0 - ambient,max(scol,0.3)); - col += sunlit * da * scol; + vec3 sun_contrib = sunlit * final_da; - col *= diffuse.rgb; + col.rgb = amblit; + col.rgb *= ambient; + col.rgb += sun_contrib; + col.rgb *= diffuse.rgb; vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); @@ -165,9 +167,6 @@ void main() col = fogged.rgb; bloom = fogged.a; #endif - -//col.rgb = vec3(scol); -//col.rgb = vec3(da * scol); } frag_color.rgb = col; frag_color.a = bloom; |