summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1
diff options
context:
space:
mode:
authorJonathan "Geenz" Goodman <geenz@geenzo.com>2023-04-20 14:11:54 -0700
committerJonathan "Geenz" Goodman <geenz@geenzo.com>2023-04-20 14:11:54 -0700
commit972a85270f8806d6a094f87c3689303f8e2e8a84 (patch)
treeca8a7a04cc74f8f1c0722604a7d809f1be50a3c2 /indra/newview/app_settings/shaders/class1
parentfc4bc08c73f6266ec0fd006dd21fc72d30141c85 (diff)
parent4b224286fe97de7399d0b72066d7646c65faabb6 (diff)
Merge branch 'DRTVWR-559' into DRTVWR-583
Diffstat (limited to 'indra/newview/app_settings/shaders/class1')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl9
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/moonF.glsl5
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskSkinnedV.glsl66
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl18
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/skyV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/srgbF.glsl39
8 files changed, 60 insertions, 86 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/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl
index fabc61eb5e..573b522068 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl
@@ -30,7 +30,6 @@
out vec4 frag_data[4];
uniform vec4 color;
-uniform vec3 moonlight_color;
uniform vec3 moon_dir;
uniform float moon_brightness;
uniform sampler2D diffuseMap;
@@ -53,11 +52,7 @@ void main()
discard;
}
-
- c.rgb *= moonlight_color.rgb;
c.rgb *= moon_brightness;
-
- c.rgb *= fade;
c.a *= fade;
frag_data[0] = vec4(0);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskSkinnedV.glsl
deleted file mode 100644
index 61c9e60744..0000000000
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskSkinnedV.glsl
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * @file shadowAlphaMaskSkinnedV.glsl
- *
- * $LicenseInfo:firstyear=2021&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2011, 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$
- */
-
-uniform mat4 texture_matrix0;
-uniform mat4 modelview_matrix;
-uniform mat4 projection_matrix;
-uniform float shadow_target_width;
-
-ATTRIBUTE vec3 position;
-ATTRIBUTE vec4 diffuse_color;
-ATTRIBUTE vec2 texcoord0;
-
-VARYING vec4 post_pos;
-VARYING float target_pos_x;
-VARYING vec4 vertex_color;
-VARYING vec2 vary_texcoord0;
-
-void passTextureIndex();
-
-mat4 getObjectSkinnedTransform();
-
-void main()
-{
- //transform vertex
- vec4 pre_pos = vec4(position.xyz, 1.0);
-
- mat4 mat = getObjectSkinnedTransform();
-
- mat = modelview_matrix * mat;
-
- vec4 pos = mat * pre_pos;
- pos = projection_matrix * pos;
-
- target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x;
-
- post_pos = pos;
-
- gl_Position = pos;
-
- passTextureIndex();
-
- vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
- vertex_color = diffuse_color;
-}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl
index 40f8fc9894..2249a7f239 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl
@@ -24,7 +24,12 @@
*/
uniform mat4 texture_matrix0;
+#if defined(HAS_SKIN)
+uniform mat4 modelview_matrix;
+uniform mat4 projection_matrix;
+#else
uniform mat4 modelview_projection_matrix;
+#endif
uniform float shadow_target_width;
ATTRIBUTE vec3 position;
@@ -38,11 +43,24 @@ VARYING vec2 vary_texcoord0;
void passTextureIndex();
+#if defined(HAS_SKIN)
+mat4 getObjectSkinnedTransform();
+#endif
+
void main()
{
//transform vertex
+#if defined(HAS_SKIN)
+ vec4 pre_pos = vec4(position.xyz, 1.0);
+ mat4 mat = getObjectSkinnedTransform();
+ mat = modelview_matrix * mat;
+ vec4 pos = mat * pre_pos;
+ pos = projection_matrix * pos;
+#else
vec4 pre_pos = vec4(position.xyz, 1.0);
vec4 pos = modelview_projection_matrix * pre_pos;
+#endif
+
target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x;
post_pos = pos;
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;