diff options
author | Runitai Linden <davep@lindenlab.com> | 2020-03-25 15:29:11 -0500 |
---|---|---|
committer | Runitai Linden <davep@lindenlab.com> | 2020-03-25 15:29:11 -0500 |
commit | 9e0cf3edaab99cc1c427e590c179d6dd604f4567 (patch) | |
tree | b52d632ea981df12fb635d3d2c92405d92057899 /indra/newview/app_settings/shaders/class2 | |
parent | 20e5ad48ec1a9c6fa4902fa34b6b53f0a7fc5858 (diff) |
Fix for class2/softenLightF.glsl not matching class1/softenLightF.glsl
Diffstat (limited to 'indra/newview/app_settings/shaders/class2')
-rw-r--r-- | indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 105 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class2/windlight/transportF.glsl | 4 |
2 files changed, 44 insertions, 65 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 0658b3ede5..b0dff0c628 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -22,7 +22,7 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - + #extension GL_ARB_texture_rectangle : enable #extension GL_ARB_shader_texture_lod : enable @@ -80,63 +80,55 @@ void main() vec4 pos = getPositionWithDepth(tc, depth); vec4 norm = texture2DRect(normalMap, tc); float envIntensity = norm.z; - norm.xyz = getNorm(tc); // unpack norm - - vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; + norm.xyz = getNorm(tc); + + vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; + float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0); + float light_gamma = 1.0/1.3; + da = pow(da, light_gamma); + + vec4 diffuse = texture2DRect(diffuseRect, tc); + + vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); - float scol = 1.0; vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; + scol_ambocc = pow(scol_ambocc, vec2(light_gamma)); - float da = clamp(dot(normalize(norm.xyz), light_dir.xyz), 0.0, 1.0); - da = pow(da, 1.0/1.3); - vec4 diffuse_srgb = texture2DRect(diffuseRect, tc); - vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a); + float scol = max(scol_ambocc.r, diffuse.a); - // clamping to alpha value kills underwater shadows... - //scol = max(scol_ambocc.r, diffuse_linear.a); - scol = scol_ambocc.r; + float ambocc = scol_ambocc.g; - vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); vec3 color = vec3(0); float bloom = 0.0; { - float ambocc = scol_ambocc.g; - vec3 sunlit; vec3 amblit; vec3 additive; vec3 atten; calcAtmosphericVars(pos.xyz, light_dir, ambocc, sunlit, amblit, additive, atten, true); - + + color.rgb = amblit; + float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); ambient *= 0.5; ambient *= ambient; ambient = (1.0 - ambient); - vec3 sun_contrib = min(scol, da) * sunlit; - -#if !defined(AMBIENT_KILL) - color.rgb = amblit; color.rgb *= ambient; -#endif -vec3 post_ambient = color.rgb; + vec3 sun_contrib = min(da, scol) * sunlit; -#if !defined(SUNLIGHT_KILL) color.rgb += sun_contrib; -#endif - -vec3 post_sunlight = color.rgb; - - color.rgb *= diffuse_srgb.rgb; -vec3 post_diffuse = color.rgb; + color.rgb *= diffuse.rgb; vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); if (spec.a > 0.0) // specular reflection { + +#if 1 //EEP vec3 npos = -normalize(pos.xyz); //vec3 ref = dot(pos+lv, norm); @@ -149,73 +141,60 @@ vec3 post_diffuse = color.rgb; float gtdenom = 2 * nh; float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); - + if (nh > 0.0) { float scontrib = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); vec3 sp = sun_contrib*scontrib / 6.0; sp = clamp(sp, vec3(0), vec3(1)); bloom += dot(sp, sp) / 4.0; -#if !defined(SUNLIGHT_KILL) color += sp * spec.rgb; -#endif } +#else //PRODUCTION + float sa = dot(refnormpersp, light_dir.xyz); + vec3 dumbshiny = sunlit*(texture2D(lightFunc, vec2(sa, spec.a)).r); + + // add the two types of shiny together + vec3 spec_contrib = dumbshiny * spec.rgb; + bloom = dot(spec_contrib, spec_contrib) / 6; + color.rgb += spec_contrib; +#endif + } - vec3 post_spec = color.rgb; - - color.rgb = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a); + color.rgb = mix(color.rgb, diffuse.rgb, diffuse.a); if (envIntensity > 0.0) { //add environmentmap vec3 env_vec = env_mat * refnormpersp; vec3 reflected_color = textureCube(environmentMap, env_vec).rgb; -#if !defined(SUNLIGHT_KILL) - color = mix(color.rgb, reflected_color, envIntensity*0.75); // MAGIC NUMBER SL-12574; ALM: On, Quality >= High -#endif + color = mix(color.rgb, reflected_color, envIntensity); } - -vec3 post_env = color.rgb; - + if (norm.w < 0.5) { -#if !defined(SUNLIGHT_KILL) - vec3 p = normalize(pos.xyz); - color = mix(atmosFragLighting(color, additive, atten), fullbrightAtmosTransportFrag(color, additive, atten), diffuse_srgb.a); - color = mix(scaleSoftClipFrag(color), fullbrightScaleSoftClip(color), diffuse_srgb.a); -#endif + color = mix(atmosFragLighting(color, additive, atten), fullbrightAtmosTransportFrag(color, additive, atten), diffuse.a); + color = mix(scaleSoftClipFrag(color), fullbrightScaleSoftClip(color), diffuse.a); } -vec3 post_atmo = color.rgb; - #ifdef WATER_FOG vec4 fogged = applyWaterFogView(pos.xyz,vec4(color, bloom)); color = fogged.rgb; bloom = fogged.a; #endif -// srgb colorspace debuggables -//color.rgb = amblit; -//color.rgb = sunlit; -//color.rgb = post_ambient; -//color.rgb = sun_contrib; -//color.rgb = post_sunlight; -//color.rgb = diffuse_srgb.rgb; -//color.rgb = post_diffuse; -//color.rgb = post_spec; -//color.rgb = post_env; -//color.rgb = post_atmo; - } // linear debuggables //color.rgb = vec3(final_da); //color.rgb = vec3(ambient); //color.rgb = vec3(scol); -//color.rgb = diffuse_linear.rgb; +//color.rgb = diffuse_srgb.rgb; - //output linear RGB as lights are summed up in linear space and then gamma corrected prior to the - //post deferred passes + // convert to linear as fullscreen lights need to sum in linear colorspace + // and will be gamma (re)corrected downstream... + frag_color.rgb = srgb_to_linear(color.rgb); frag_color.a = bloom; } + diff --git a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl index b0cf9b0002..b53a2e237f 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl @@ -46,8 +46,8 @@ vec3 atmosTransport(vec3 light) vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) { - float brightness = dot(light.rgb * 0.5, vec3(0.3333)) + 0.1; - return mix(atmosTransport(light.rgb), light.rgb + additive, brightness * brightness); + float brightness = dot(light.rgb * 0.5, vec3(0.3333)) + 0.1; + return mix(atmosTransportFrag(light.rgb, additive, atten), light.rgb + additive, brightness * brightness); } vec3 fullbrightAtmosTransport(vec3 light) |