diff options
Diffstat (limited to 'indra/newview/app_settings/shaders')
11 files changed, 50 insertions, 22 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index aa61e10c7f..8797f89e4c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -387,7 +387,7 @@ vec3 pbrIbl(vec3 diffuseColor, { // retrieve a scale and bias to F0. See [1], Figure 3 vec2 brdf = BRDF(clamp(nv, 0, 1), 1.0-perceptualRough); - vec3 diffuseLight = irradiance; + vec3 diffuseLight = irradiance*1.25; //magic 1.25 to balance with legacy materials vec3 specularLight = radiance; vec3 diffuse = diffuseLight * diffuseColor; @@ -563,7 +563,7 @@ vec3 pbrBaseLight(vec3 diffuseColor, vec3 specularColor, float metallic, vec3 v, vec3 ibl_spec; color += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, perceptualRoughness, ibl_spec); - color += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm, v, normalize(light_dir), specContrib) * sunlit * 2.75 * scol; + color += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm, v, normalize(light_dir), specContrib) * sunlit * 3.9 * scol; //magic number to balance with legacy materials specContrib *= sunlit * 2.75 * scol; specContrib += ibl_spec; diff --git a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl index 17e24a2bf2..3c51a8e44c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl @@ -36,11 +36,8 @@ VARYING vec2 vary_texcoord0; void main() { - float shadow = 1.0; - - vec4 color = diffuseLookup(vary_texcoord0.xy)*vertex_color; - color.rgb = fullbrightAtmosTransport(color.rgb); - - frag_color = max(color, vec4(0)); + // NOTE: when this shader is used, only alpha is being written to + float a = diffuseLookup(vary_texcoord0.xy).a*vertex_color.a; + frag_color = vec4(0, 0, 0, a); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 11532135dd..5515d8e2a3 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -42,6 +42,7 @@ vec4 applyWaterFogView(vec3 pos, vec4 color); #endif vec3 srgb_to_linear(vec3 cs); +vec3 legacy_adjust_fullbright(vec3 c); vec3 legacy_adjust(vec3 c); vec3 linear_to_srgb(vec3 cl); vec3 fullbrightAtmosTransport(vec3 light); @@ -90,8 +91,8 @@ void main() #ifndef IS_HUD color.rgb = legacy_adjust(color.rgb); color.rgb = srgb_to_linear(color.rgb); + color.rgb = legacy_adjust_fullbright(color.rgb); color.rgb = fullbrightAtmosTransport(color.rgb); - #endif frag_color = max(color, vec4(0)); diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl index 62d134188c..4fa9ae3633 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl @@ -91,7 +91,7 @@ void main() vary_LightNormPosDot = rel_pos_lightnorm_dot; // Initialize temp variables - vec3 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + vec3 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color * 0.7; //magic 0.7 to match legacy color // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes diff --git a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl index 3cca84ca14..35f2395ef1 100644 --- a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl @@ -23,6 +23,8 @@ * $/LicenseInfo$ */ + uniform sampler2D exposureMap; + vec3 srgb_to_linear(vec3 cs) { vec3 low_range = cs / vec3(12.92); @@ -83,12 +85,32 @@ vec3 hsv2rgb(vec3 c) return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } -vec3 legacy_adjust_no_brighten(vec3 c) +const mat3 inv_ACESOutputMat = mat3(0.643038, 0.0592687, 0.0059619, 0.311187, 0.931436, 0.063929, 0.0457755, 0.00929492, 0.930118 ); + +const mat3 inv_ACESInputMat = mat3( 1.76474, -0.147028, -0.0363368, -0.675778, 1.16025, -0.162436, -0.0889633, -0.0132237, 1.19877 ); + +vec3 inv_RRTAndODTFit(vec3 x) { - vec3 desat = rgb2hsv(c.rgb); - desat.g *= 0.75; - desat.rgb = hsv2rgb(desat); - return desat; + float A = 0.0245786; + float B = 0.000090537; + float C = 0.983729; + float D = 0.4329510; + float E = 0.238081; + + return (A - D * x)/(2.0 * (C * x - 1.0)) - sqrt(pow(D * x - A, vec3(2.0)) - 4.0 * (C * x - 1.0) * (B + E * x))/(2.0 * (C * x - 1.0)); +} + +// experimental inverse of ACES Hill tonemapping +vec3 inv_toneMapACES_Hill(vec3 color) +{ + color = inv_ACESOutputMat * color; + + // Apply RRT and ODT + color = inv_RRTAndODTFit(color); + + color = inv_ACESInputMat * color; + + return color; } vec3 legacy_adjust(vec3 c) @@ -100,6 +122,13 @@ vec3 legacy_adjust(vec3 c) return desat; } +vec3 legacy_adjust_fullbright(vec3 c) +{ + float exp_scale = texture(exposureMap, vec2(0.5, 0.5)).r; + return c / exp_scale * 1.34; +} + + vec3 legacy_adjust_post(vec3 c) { return c; diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl index d3fa03b02a..cd7c005162 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl @@ -148,7 +148,7 @@ vec3 calcPointLightOrSpotLight(vec3 diffuseColor, vec3 specularColor, // spot*spot => GL_SPOT_EXPONENT=2 float spot_atten = spot*spot; - vec3 intensity = spot_atten * dist_atten * lightColor * 3.0; + vec3 intensity = spot_atten * dist_atten * lightColor * 3.9; //magic number to balance with legacy materials vec3 speccol; color = intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv, speccol); diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl index 22db9dce03..4e0933f922 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl @@ -50,6 +50,7 @@ uniform float sun_moon_glow_factor; float getAmbientClamp() { return 1.0f; } vec3 srgb_to_linear(vec3 col); +vec3 legacy_adjust(vec3 col); // return colors in sRGB space void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, @@ -63,8 +64,8 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou vec3 rel_pos_norm = normalize(rel_pos); float rel_pos_len = length(rel_pos); - vec3 sunlight = (sun_up_factor == 1) ? sunlight_color: moonlight_color; - + vec3 sunlight = (sun_up_factor == 1) ? sunlight_color: moonlight_color * 0.7; // magic 0.7 to match legacy color + // sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes vec3 light_atten = (blue_density + vec3(haze_density * 0.25)) * (density_multiplier * max_y); diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl index 5a2924afe5..2da177ea7e 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl @@ -124,7 +124,7 @@ void main() float dist_atten = calcLegacyDistanceAttenuation(dist, falloff); - vec3 intensity = dist_atten * lightColor * 3.0; + vec3 intensity = dist_atten * lightColor * 3.9; final_color += intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv); } diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl index 33e5b2346c..33715d4d87 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl @@ -173,7 +173,7 @@ void main() dlit = getProjectedLightDiffuseColor( l_dist, proj_tc.xy ); - vec3 intensity = dist_atten * dlit * 3.0 * shadow; // Legacy attenuation + vec3 intensity = dist_atten * dlit * 3.9 * shadow; // Legacy attenuation, magic number to balance with legacy materials final_color += intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, normalize(lv)); } diff --git a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl index 471e5e7fd3..7724a6cac9 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl @@ -113,7 +113,7 @@ void main() vec3 specularColor = mix(f0, baseColor.rgb, metallic); - vec3 intensity = dist_atten * color * 3.0; // Legacy attenuation + vec3 intensity = dist_atten * color * 3.9; // Legacy attenuation, magic number to balance with legacy materials final_color += intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, normalize(lv)); } else diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl index 3d06bb27a5..f2ab585716 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl @@ -180,7 +180,7 @@ void main() dlit = getProjectedLightDiffuseColor( l_dist, proj_tc.xy ); - vec3 intensity = dist_atten * dlit * 3.0 * shadow; // Legacy attenuation + vec3 intensity = dist_atten * dlit * 3.9 * shadow; // Legacy attenuation final_color += intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, normalize(lv)); } |