diff options
author | Jonathan "Geenz" Goodman <geenz@geenzo.com> | 2023-06-11 20:56:02 -0700 |
---|---|---|
committer | Jonathan "Geenz" Goodman <geenz@geenzo.com> | 2023-06-11 20:56:02 -0700 |
commit | ffac2df6caedf48f30b3913386ea6e4c82ae5a0b (patch) | |
tree | c5e5a0541b318551cc04b6b7108f8f9025c6b72d /indra/newview/app_settings | |
parent | 47e311d6e8b9996de3e0a1ac75c13724ce7735aa (diff) | |
parent | 1ebfc1876ec3383067a2399218037a33601b04d5 (diff) |
Merge branch 'DRTVWR-559' into DRTVWR-583-glossy-ssr
Diffstat (limited to 'indra/newview/app_settings')
27 files changed, 180 insertions, 208 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 533a3361e6..c90c9c543c 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9116,6 +9116,28 @@ <key>Value</key> <real>500.0</real> </map> + <key>RenderSSAOIrradianceScale</key> + <map> + <key>Comment</key> + <string>Scaling factor for irradiance input to SSAO</string> + <key>Persist</key> + <integer>0</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>0.6</real> + </map> + <key>RenderSSAOIrradianceMax</key> + <map> + <key>Comment</key> + <string>Max factor for irradiance input to SSAO</string> + <key>Persist</key> + <integer>0</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>0.18</real> + </map> <key>RenderSSAOMaxScale</key> <map> <key>Comment</key> @@ -10468,17 +10490,6 @@ <key>Value</key> <integer>1</integer> </map> - <key>RenderReflectionProbeCount</key> - <map> - <key>Comment</key> - <string>Number of reflection probes (maximum is 256, requires restart)</string> - <key>Persist</key> - <integer>1</integer> - <key>Type</key> - <string>S32</string> - <key>Value</key> - <integer>256</integer> - </map> <key>RenderReflectionProbeResolution</key> <map> <key>Comment</key> @@ -10588,40 +10599,29 @@ <key>Type</key> <string>F32</string> <key>Value</key> - <real>1.25</real> - </map> - <key>RenderReflectionProbeMaxLocalLightAmbiance</key> - <map> - <key>Comment</key> - <string>Maximum effective probe ambiance for local lights</string> - <key>Persist</key> - <integer>0</integer> - <key>Type</key> - <string>F32</string> - <key>Value</key> - <real>4.0</real> + <real>1.0</real> </map> - <key>RenderDynamicExposureMin</key> + <key>RenderSkyAutoAdjustLegacy</key> <map> <key>Comment</key> - <string>Minimum dynamic exposure amount</string> + <string>If true, automatically adjust legacy skies (those without a probe ambiance value) to take advantage of probes and HDR.</string> <key>Persist</key> - <integer>0</integer> + <integer>1</integer> <key>Type</key> - <string>F32</string> + <string>Boolean</string> <key>Value</key> - <real>0.6</real> + <integer>1</integer> </map> - <key>RenderDynamicExposureMax</key> + <key>RenderReflectionProbeMaxLocalLightAmbiance</key> <map> <key>Comment</key> - <string>Maximum dynamic exposure amount</string> + <string>Maximum effective probe ambiance for local lights</string> <key>Persist</key> <integer>0</integer> <key>Type</key> <string>F32</string> <key>Value</key> - <real>1.5</real> + <real>4.0</real> </map> <key>RenderDynamicExposureCoefficient</key> <map> diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index 55e45ce0af..c8eaba6418 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*1.25; //magic 1.25 to balance with legacy materials + vec3 diffuseLight = irradiance; 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 * 3.9 * scol; //magic number to balance with legacy materials + color += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm, v, normalize(light_dir), specContrib) * sunlit * 3.0 * 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/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 385cd51969..b752307d13 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -44,7 +44,7 @@ vec3 legacy_adjust_fullbright(vec3 c); vec3 legacy_adjust(vec3 c); vec3 linear_to_srgb(vec3 cl); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); -void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao); +void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); #ifdef HAS_ALPHA_MASK uniform float minimum_alpha; @@ -85,7 +85,7 @@ void main() vec3 amblit; vec3 additive; vec3 atten; - calcAtmosphericVars(pos.xyz, vec3(0), 1.0, sunlit, amblit, additive, atten, false); + calcAtmosphericVars(pos.xyz, vec3(0), 1.0, sunlit, amblit, additive, atten); #endif #ifdef WATER_FOG diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl index ee425f97fc..c8afacf9bb 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl @@ -47,6 +47,6 @@ void main() tc.y -= 0.1; // HACK - nudge exposure sample down a little bit to favor ground over sky vec3 c = texture(diffuseRect, tc).rgb + texture(emissiveRect, tc).rgb; float L = lum(c); - frag_color = vec4(L); + frag_color = vec4(max(L, 0.0)); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl index e9515a9187..6b960fae33 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl @@ -71,6 +71,7 @@ flat out float vary_sign; out vec3 vary_normal; vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); +vec3 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); void main() @@ -102,9 +103,11 @@ void main() vec3 t = normal_matrix * tangent.xyz; #endif //HAS_SKIN - vary_tangent = normalize(t); + n = normalize(n); + + vary_tangent = normalize(tangent_space_transform(vec4(t, tangent.w), n, texture_normal_transform, texture_matrix0)); vary_sign = tangent.w; - vary_normal = normalize(n); + vary_normal = n; vertex_color = diffuse_color; diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl index e2c23ac8f0..160ae7a215 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl @@ -61,6 +61,7 @@ flat out float vary_sign; out vec3 vary_normal; vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); +vec3 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); void main() { @@ -91,9 +92,11 @@ void main() vec3 t = normal_matrix * tangent.xyz; #endif - vary_tangent = normalize(t); + n = normalize(n); + + vary_tangent = normalize(tangent_space_transform(vec4(t, tangent.w), n, texture_normal_transform, texture_matrix0)); vary_sign = tangent.w; - vary_normal = normalize(n); + vary_normal = n; vertex_color = diffuse_color; } @@ -107,8 +110,6 @@ uniform mat4 modelview_projection_matrix; uniform mat4 texture_matrix0; uniform vec4[2] texture_base_color_transform; -uniform vec4[2] texture_normal_transform; -uniform vec4[2] texture_metallic_roughness_transform; uniform vec4[2] texture_emissive_transform; in vec3 position; diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index a32296369c..53e4f02314 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -102,16 +102,12 @@ vec3 toneMap(vec3 color) { #ifndef NO_POST float exp_scale = texture(exposureMap, vec2(0.5,0.5)).r; - + color *= exposure * exp_scale; color = toneMapACES_Hill(color); -#else - color *= 0.6; #endif - color = linear_to_srgb(color); - return color; } @@ -158,10 +154,10 @@ float noise(vec2 x) { vec3 legacyGamma(vec3 color) { - color = 1. - clamp(color, vec3(0.), vec3(1.)); - color = 1. - pow(color, vec3(gamma)); // s/b inverted already CPU-side + vec3 c = 1. - clamp(color, vec3(0.), vec3(1.)); + c = 1. - pow(c, vec3(gamma)); // s/b inverted already CPU-side - return color; + return c; } void main() @@ -169,12 +165,14 @@ void main() //this is the one of the rare spots where diffuseRect contains linear color values (not sRGB) vec4 diff = texture(diffuseRect, vary_fragcoord); - diff.rgb = toneMap(diff.rgb); - #ifdef LEGACY_GAMMA -#ifndef NO_POST + diff.rgb = linear_to_srgb(diff.rgb); diff.rgb = legacyGamma(diff.rgb); +#else +#ifndef NO_POST + diff.rgb = toneMap(diff.rgb); #endif + diff.rgb = linear_to_srgb(diff.rgb); #endif vec2 tc = vary_fragcoord.xy*screen_res*4.0; diff --git a/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl b/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl index 71f7ec52c4..636dfed4ba 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl @@ -76,3 +76,47 @@ vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl return texcoord; } + +// Take the rotation only from both transforms and apply to the tangent. This +// accounts for the change of the topology of the normal texture when a texture +// rotation is applied to it. +// *HACK: Assume the imported GLTF model did not have both normal texture +// transforms and tangent vertices. The use of this function is inconsistent +// with the GLTF sample viewer when that is the case. See getNormalInfo in +// https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Viewer/47a191931461a6f2e14de48d6da0f0eb6ec2d147/source/Renderer/shaders/material_info.glsl +// We may want to account for this case during GLTF model import. +// -Cosmic,2023-06-06 +vec3 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform, mat4 sl_animation_transform) +{ + vec2 weights = vec2(0, 1); + + // Apply texture animation first to avoid shearing and other artifacts (rotation only) + mat2 sl_rot_scale; + sl_rot_scale[0][0] = sl_animation_transform[0][0]; + sl_rot_scale[0][1] = sl_animation_transform[0][1]; + sl_rot_scale[1][0] = sl_animation_transform[1][0]; + sl_rot_scale[1][1] = sl_animation_transform[1][1]; + weights = sl_rot_scale * weights; + // Remove scale + weights = normalize(weights); + + // Convert to left-handed coordinate system + weights.y = -weights.y; + + // Apply KHR_texture_transform (rotation only) + float khr_rotation = khr_gltf_transform[0].z; + mat2 khr_rotation_mat = mat2( + cos(khr_rotation),-sin(khr_rotation), + sin(khr_rotation), cos(khr_rotation) + ); + weights = khr_rotation_mat * weights; + + // Convert back to right-handed coordinate system + weights.y = -weights.y; + + // Similar to the MikkTSpace-compatible method of extracting the binormal + // from the normal and tangent, as seen in the fragment shader + vec3 vertex_binormal = vertex_tangent.w * cross(vertex_normal, vertex_tangent.xyz); + + return (weights.x * vertex_binormal.xyz) + (weights.y * vertex_tangent.xyz); +} diff --git a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl index 689c345b2c..31b02377da 100644 --- a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl @@ -113,18 +113,31 @@ vec3 inv_toneMapACES_Hill(vec3 color) return color; } +// adjust legacy colors to back out tonemapping and exposure +// NOTE: obsolete now that setting probe ambiance to zero removes tonemapping and exposure, but keeping for a minute +// while that change goes through testing - davep 6/1/2023 +#define LEGACY_ADJUST 0 + vec3 legacy_adjust(vec3 c) { +#if LEGACY_ADJUST vec3 desat = rgb2hsv(c.rgb); desat.g *= 1.0-(1.0-desat.b)*0.5; desat.b += (1.0-desat.b)*0.1f; desat.rgb = hsv2rgb(desat); return desat; +#else + return c; +#endif } vec3 legacy_adjust_fullbright(vec3 c) { - float exp_scale = texture(exposureMap, vec2(0.5, 0.5)).r; +#if LEGACY_ADJUST + float exp_scale = clamp(texture(exposureMap, vec2(0.5, 0.5)).r, 0.01, 10.0); return c / exp_scale * 1.34; //magic 1.34 arrived at by binary search for a value that reproduces midpoint grey consistenty +#else + return c; +#endif } diff --git a/indra/newview/app_settings/shaders/class1/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class1/lighting/sumLightsV.glsl index 0c3ea4231e..75a327d3d7 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/sumLightsV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/sumLightsV.glsl @@ -38,15 +38,7 @@ vec4 sumLights(vec3 pos, vec3 norm, vec4 color) col.a = color.a; col.rgb = light_diffuse[1].rgb * calcDirectionalLight(norm, light_position[1].xyz); - col.rgb = scaleDownLight(col.rgb); - -#if defined(LOCAL_LIGHT_KILL) - col.rgb = vec3(0); -#endif - -#if !defined(SUNLIGHT_KILL) - col.rgb += atmosAffectDirectionalLight(calcDirectionalLight(norm, light_position[0].xyz)); -#endif + col.rgb += light_diffuse[1].rgb * sqrt(calcDirectionalLight(norm, -light_position[1].xyz)*0.5+0.25); col.rgb = min(col.rgb*color.rgb, 1.0); return col; diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl index e314555ef9..48cf234aa0 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl @@ -30,7 +30,7 @@ vec3 scaleSoftClipFrag(vec3 light); vec3 srgb_to_linear(vec3 col); vec3 linear_to_srgb(vec3 col); -uniform int sun_up_factor; +uniform float sky_hdr_scale; vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten) { @@ -38,7 +38,7 @@ vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten) additive = srgb_to_linear(additive*2.0); // magic 1.25 here is to match the default RenderSkyHDRScale -- this parameter needs to be plumbed into sky settings or something // so it's available to all shaders that call atmosFragLighting instead of just softenLightF.glsl - additive *= sun_up_factor*1.25 + 1.0; + additive *= sky_hdr_scale; light += additive; return light; } diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl index 4e0933f922..437fa0a6d5 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl @@ -25,27 +25,21 @@ uniform vec3 lightnorm; uniform vec3 sunlight_color; -uniform vec3 sunlight_linear; uniform vec3 moonlight_color; -uniform vec3 moonlight_linear; uniform int sun_up_factor; uniform vec3 ambient_color; -uniform vec3 ambient_linear; uniform vec3 blue_horizon; -uniform vec3 blue_horizon_linear; uniform vec3 blue_density; -uniform vec3 blue_density_linear; uniform float haze_horizon; uniform float haze_density; -uniform float haze_density_linear; uniform float cloud_shadow; uniform float density_multiplier; uniform float distance_multiplier; uniform float max_y; uniform vec3 glow; uniform float scene_light_strength; -uniform mat3 ssao_effect_mat; uniform float sun_moon_glow_factor; +uniform float sky_hdr_scale; float getAmbientClamp() { return 1.0f; } @@ -54,7 +48,7 @@ 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, - out vec3 atten, bool use_ao) + out vec3 atten) { vec3 rel_pos = inPositionEye; @@ -64,7 +58,7 @@ 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 * 0.7; // magic 0.7 to match legacy color + vec3 sunlight = (sun_up_factor == 1) ? sunlight_color: moonlight_color; // sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes @@ -117,20 +111,6 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou // increase ambient when there are more clouds vec3 tmpAmbient = amb_color + (vec3(1.) - amb_color) * cloud_shadow * 0.5; - /* decrease value and saturation (that in HSV, not HSL) for occluded areas - * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html - * // The following line of code performs the equivalent of: - * float ambAlpha = tmpAmbient.a; - * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis - * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue); - * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, - * ambAlpha); - */ - if (use_ao) - { - tmpAmbient = mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor); - } - // Similar/Shared Algorithms: // indra\llinventory\llsettingssky.cpp -- LLSettingsSky::calculateLightSettings() // indra\newview\app_settings\shaders\class1\windlight\atmosphericsFuncs.glsl -- calcAtmosphericVars() @@ -141,7 +121,7 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou // brightness of surface both sunlight and ambient sunlit = sunlight.rgb; - amblit = vec3(1,0,1); //should no longer be used, filled in by calcAtmosphericVarsLinear + amblit = tmpAmbient; additive *= vec3(1.0 - combined_haze); } @@ -164,15 +144,16 @@ float ambientLighting(vec3 norm, vec3 light_dir) void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten) { - calcAtmosphericVars(inPositionEye, light_dir, 1.0, sunlit, amblit, additive, atten, false); + calcAtmosphericVars(inPositionEye, light_dir, 1.0, sunlit, amblit, additive, atten); - // multiply by 2 to get same colors as when the "scaleSoftClip" implementation was doubling color values + // multiply to get similar colors as when the "scaleSoftClip" implementation was doubling color values // (allows for mixing of light sources other than sunlight e.g. reflection probes) - sunlit *= 2.0; - - // squash ambient to approximate whatever weirdness legacy atmospherics were doing - amblit = ambient_color; // * (1.0+sun_up_factor*0.3); + sunlit *= 1.5; + amblit *= 0.5; + + // override amblit with ambient_color if sky probe ambiance is not zero + amblit = mix(amblit, ambient_color, clamp(sky_hdr_scale-1.0, 0.0, 1.0)); - amblit *= ambientLighting(norm, light_dir); amblit = srgb_to_linear(amblit); + amblit *= ambientLighting(norm, light_dir); } diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersF.glsl index 800d08047a..800d08047a 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersF.glsl diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl index 6ecbfaecb1..6ecbfaecb1 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl index 3773f191e8..cc3617ba61 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl @@ -38,7 +38,7 @@ void setPositionEye(vec3 v); vec3 getAdditiveColor(); -void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao); +void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); void calcAtmospherics(vec3 inPositionEye) { vec3 P = inPositionEye; @@ -48,7 +48,7 @@ void calcAtmospherics(vec3 inPositionEye) { vec3 tmpaddlit = vec3(1); vec3 tmpattenlit = vec3(1); vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; - calcAtmosphericVars(inPositionEye, light_dir, 1, tmpsunlit, tmpamblit, tmpaddlit, tmpattenlit, false); + calcAtmosphericVars(inPositionEye, light_dir, 1, tmpsunlit, tmpamblit, tmpaddlit, tmpattenlit); setSunlitColor(tmpsunlit); setAmblitColor(tmpamblit); setAdditiveColor(tmpaddlit); diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl index 34669a6796..34669a6796 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl index 1b854d80b3..1b854d80b3 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsWaterF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterF.glsl index 7a6741fe0e..7a6741fe0e 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterF.glsl diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsWaterV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterV.glsl index 23c3aed4d8..23c3aed4d8 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsWaterV.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterV.glsl diff --git a/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl b/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl index 027bfb866f..027bfb866f 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index ae8cd97b18..cd57b47eae 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -274,6 +274,10 @@ void main() color.rgb = atmosFragLightingLinear(color.rgb, additive, atten); +#ifdef WATER_FOG + color = applyWaterFogViewLinear(pos.xyz, color, sunlit_linear); +#endif // WATER_FOG + vec4 light = vec4(0,0,0,0); #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diffuse_linear.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w); @@ -291,11 +295,6 @@ void main() color.rgb += light.rgb; #endif // !defined(LOCAL_LIGHT_KILL) - -#ifdef WATER_FOG - color = applyWaterFogViewLinear(pos.xyz, color, sunlit_linear); -#endif // WATER_FOG - #endif // #else // FOR_IMPOSTOR #ifdef IS_HUD diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl index 7b7b4a040c..d678973515 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl @@ -84,6 +84,10 @@ vec3 linear_to_srgb(vec3 c); void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); vec3 atmosFragLightingLinear(vec3 color, vec3 additive, vec3 atten); +#ifdef WATER_FOG +vec4 applyWaterFogViewLinear(vec3 pos, vec4 color, vec3 sunlit); +#endif + void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float nh, out float nl, out float nv, out float vh, out float lightDist); float calcLegacyDistanceAttenuation(float distance, float falloff); float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); @@ -148,7 +152,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.9; //magic number to balance with legacy materials + vec3 intensity = spot_atten * dist_atten * lightColor * 3.0; //magic number to balance with legacy materials vec3 speccol; color = intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv, speccol); @@ -237,6 +241,11 @@ void main() color.rgb = atmosFragLightingLinear(color.rgb, additive, atten); +#ifdef WATER_FOG + vec4 temp = applyWaterFogViewLinear(pos, vec4(color, 0.0), sunlit_linear); + color = temp.rgb; +#endif + vec3 light = vec3(0); // Punctual lights @@ -258,7 +267,7 @@ void main() glare = min(glare, 1.0); a = max(a, glare); - frag_color = vec4(color.rgb,a); + frag_color = max(vec4(color.rgb,a), vec4(0)); } #else @@ -311,7 +320,7 @@ void main() float a = basecolor.a*vertex_color.a; color += colorEmissive; color = linear_to_srgb(color); - frag_color = vec4(color.rgb,a); + frag_color = max(vec4(color.rgb,a), vec4(0)); } #endif diff --git a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl index 1c79748b49..0d77e88831 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl @@ -42,7 +42,7 @@ uniform samplerCube environmentMap; vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); vec3 legacy_adjust_fullbright(vec3 c); vec3 legacy_adjust(vec3 c); -void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao); +void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); vec3 linear_to_srgb(vec3 c); vec3 srgb_to_linear(vec3 c); @@ -71,7 +71,7 @@ void main() vec3 additive; vec3 atten; vec3 pos = vary_position; - calcAtmosphericVars(pos.xyz, vec3(0), 1.0, sunlit, amblit, additive, atten, false); + calcAtmosphericVars(pos.xyz, vec3(0), 1.0, sunlit, amblit, additive, atten); float env_intensity = vertex_color.a; diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index 77e3b92385..5fb5647d35 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -38,7 +38,7 @@ uniform float emissive_brightness; // fullbright flag, 1.0 == fullbright, 0.0 o uniform int sun_up_factor; #ifdef WATER_FOG -vec4 applyWaterFogView(vec3 pos, vec4 color); +vec4 applyWaterFogViewLinear(vec3 pos, vec4 color, vec3 sunlit); #endif vec3 atmosFragLightingLinear(vec3 l, vec3 additive, vec3 atten); @@ -49,6 +49,7 @@ void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float vec3 srgb_to_linear(vec3 cs); vec3 linear_to_srgb(vec3 cs); vec3 legacy_adjust(vec3 c); +vec3 legacy_adjust_fullbright(vec3 c); #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) @@ -396,7 +397,7 @@ void main() } #endif - color = mix(color.rgb, diffcol.rgb, emissive); + color = mix(color.rgb, legacy_adjust_fullbright(diffcol.rgb), emissive); if (env > 0.0) { // add environmentmap @@ -410,6 +411,11 @@ void main() color.rgb = atmosFragLightingLinear(color.rgb, additive, atten); +#ifdef WATER_FOG + vec4 temp = applyWaterFogViewLinear(pos, vec4(color, 0.0), sunlit_linear); + color = temp.rgb; +#endif + vec3 npos = normalize(-pos.xyz); vec3 light = vec3(0, 0, 0); @@ -430,11 +436,6 @@ void main() glare = min(glare, 1.0); float al = max(diffcol.a, glare) * vertex_color.a; -#ifdef WATER_FOG - vec4 temp = applyWaterFogView(pos, vec4(color, 0.0)); - color = temp.rgb; -#endif - frag_color = max(vec4(color, al), vec4(0)); #else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 2f3efaa94a..409b46218b 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -25,9 +25,6 @@ #define FLT_MAX 3.402823466e+38 -#define REFMAP_COUNT 256 -#define REF_SAMPLE_COUNT 64 //maximum number of samples to consider - out vec4 frag_color; uniform sampler2D diffuseRect; @@ -47,9 +44,14 @@ uniform sampler2D lightFunc; uniform float blur_size; uniform float blur_fidelity; +#if defined(HAS_SSAO) +uniform float ssao_irradiance_scale; +uniform float ssao_irradiance_max; +#endif + // Inputs uniform mat3 env_mat; - +uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; uniform vec3 moon_dir; uniform int sun_up_factor; @@ -115,6 +117,16 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, vec3 l); //surface point to light +void adjustIrradiance(inout vec3 irradiance, vec3 amblit_linear, float ambocc) +{ + // use sky settings ambient or irradiance map sample, whichever is brighter + irradiance = max(amblit_linear, irradiance); + +#if defined(HAS_SSAO) + irradiance = mix(ssao_effect_mat * min(irradiance.rgb*ssao_irradiance_scale, vec3(ssao_irradiance_max)), irradiance.rgb, ambocc); +#endif +} + void main() { vec2 tc = vary_fragcoord.xy; @@ -176,7 +188,7 @@ void main() vec3 orm = texture(specularRect, tc).rgb; float perceptualRoughness = orm.g; float metallic = orm.b; - float ao = orm.r * ambocc; + float ao = orm.r; vec3 colorEmissive = texture(emissiveRect, tc).rgb; // PBR IBL @@ -184,16 +196,13 @@ void main() sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, norm.xyz, gloss); - // Take maximium of legacy ambient vs irradiance sample as irradiance - // NOTE: ao is applied in pbrIbl (see pbrBaseLight), do not apply here - irradiance = max(amblit_linear,irradiance); + adjustIrradiance(irradiance, amblit_linear, ambocc); vec3 diffuseColor; vec3 specularColor; calcDiffuseSpecular(baseColor.rgb, metallic, diffuseColor, specularColor); vec3 v = -normalize(pos.xyz); - color = vec3(1,0,1); color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten); if (do_atmospherics) @@ -206,17 +215,15 @@ void main() //should only be true of WL sky, just port over base color value color = texture(emissiveRect, tc).rgb; color = srgb_to_linear(color); - if (sun_up_factor > 0) - { - color *= sky_hdr_scale + 1.0; - } + color *= sky_hdr_scale; } else { // legacy shaders are still writng sRGB to gbuffer baseColor.rgb = legacy_adjust(baseColor.rgb); - + baseColor.rgb = srgb_to_linear(baseColor.rgb); + spec.rgb = srgb_to_linear(spec.rgb); float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0); @@ -227,11 +234,10 @@ void main() sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, norm.xyz, spec.a, envIntensity); - // use sky settings ambient or irradiance map sample, whichever is brighter - irradiance = max(amblit_linear, irradiance); + adjustIrradiance(irradiance, amblit_linear, ambocc); // apply lambertian IBL only (see pbrIbl) - color.rgb = irradiance * ambocc; + color.rgb = irradiance; vec3 sun_contrib = min(da, scol) * sunlit_linear; color.rgb += sun_contrib; diff --git a/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl b/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl index 30ad493331..77bbbabfae 100644 --- a/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl +++ b/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl @@ -23,21 +23,13 @@ * $/LicenseInfo$ */ - - -// All lights, no specular highlights -vec3 atmosAmbient(); +// used for preview renders only vec4 sumLights(vec3 pos, vec3 norm, vec4 color); -float getAmbientClamp(); vec4 calcLighting(vec3 pos, vec3 norm, vec4 color) { vec4 c = sumLights(pos, norm, color); -#if !defined(AMBIENT_KILL) - c.rgb += atmosAmbient() * color.rgb * getAmbientClamp(); -#endif - return c; } diff --git a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl deleted file mode 100644 index 4b663dd5b2..0000000000 --- a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @file class3\lighting\sumLightsV.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - - -float calcDirectionalLight(vec3 n, vec3 l); -float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight); - -vec3 atmosAffectDirectionalLight(float lightIntensity); -vec3 scaleDownLight(vec3 light); - -uniform vec4 light_position[8]; -uniform vec3 light_direction[8]; -uniform vec4 light_attenuation[8]; -uniform vec3 light_diffuse[8]; - -vec4 sumLights(vec3 pos, vec3 norm, vec4 color) -{ - vec4 col = vec4(0.0, 0.0, 0.0, color.a); - - // Collect normal lights (need to be divided by two, as we later multiply by 2) - - // Collect normal lights - col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z); - col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z); - col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z); - col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z); - col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z); - col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z); - col.rgb += light_diffuse[1].rgb*calcDirectionalLight(norm, light_position[1].xyz); - col.rgb = scaleDownLight(col.rgb); - -#if defined(LOCAL_LIGHT_KILL) - col.rgb = vec3(0); -#endif - - // Add windlight lights -#if !defined(SUNLIGHT_KILL) - col.rgb += atmosAffectDirectionalLight(calcDirectionalLight(norm, light_position[0].xyz)); -#endif - - col.rgb = min(col.rgb*color.rgb, 1.0); - - return col; -} - |