summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class3
diff options
context:
space:
mode:
authorJonathan "Geenz" Goodman <geenz@geenzo.com>2023-10-16 08:45:48 -0700
committerJonathan "Geenz" Goodman <geenz@geenzo.com>2023-10-16 08:45:48 -0700
commite841c73a9972fc184487c061e8a80add3a18aff1 (patch)
tree2af618b6c72cc19f3b5a08f4901087b8229aa04a /indra/newview/app_settings/shaders/class3
parente612d70fad8c6ec9335c109223211d516ebdf6f4 (diff)
Tons of masking changes and tweaks.
We now support masking mirrors in the GBuffer. We also now support the concept of one arbitrary clip plane. DRTVWR-583
Diffstat (limited to 'indra/newview/app_settings/shaders/class3')
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/materialF.glsl30
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl6
2 files changed, 31 insertions, 5 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
index 319f2f25b7..af49e76984 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
@@ -51,6 +51,23 @@ vec3 linear_to_srgb(vec3 cs);
vec3 legacy_adjust(vec3 c);
vec3 legacy_adjust_fullbright(vec3 c);
+uniform vec4 clipPlane;
+uniform float clipSign;
+uniform float mirror_flag;
+void applyClip(vec3 pos)
+{
+ float funnyClip = 0;
+ if (mirror_flag > 0)
+ {
+ if ((dot(pos.xyz, clipPlane.xyz) + clipPlane.w) > 0.0)
+ {
+ discard;
+ }
+ }
+}
+
+in vec3 vary_position;
+
#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)
out vec4 frag_color;
@@ -72,12 +89,12 @@ uniform vec4 morphFactor;
uniform vec3 camPosLocal;
uniform mat3 env_mat;
+uniform float is_mirror;
+
uniform vec3 sun_dir;
uniform vec3 moon_dir;
in vec2 vary_fragcoord;
-in vec3 vary_position;
-
uniform mat4 proj_mat;
uniform mat4 inv_proj;
uniform vec2 screen_res;
@@ -291,6 +308,7 @@ float getShadow(vec3 pos, vec3 norm)
void main()
{
+ applyClip(vary_position);
waterClip();
// diffcol == diffuse map combined with vertex color
@@ -419,9 +437,15 @@ void main()
#else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer
// deferred path // See: C++: addDeferredAttachment(), shader: softenLightF.glsl
+
+ float flag = GBUFFER_FLAG_HAS_ATMOS;
+
+ if (mirror_flag > 0)
+ flag = 1;
+
frag_data[0] = vec4(diffcol.rgb, emissive); // gbuffer is sRGB for legacy materials
frag_data[1] = vec4(spec.rgb, glossiness); // XYZ = Specular color. W = Specular exponent.
- frag_data[2] = vec4(encode_normal(norm), env, GBUFFER_FLAG_HAS_ATMOS);; // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog)
+ frag_data[2] = vec4(encode_normal(norm), env, flag);; // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog)
frag_data[3] = vec4(0);
#endif
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 20a5ad66b6..d42388ae78 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -191,7 +191,7 @@ void main()
vec3 irradiance = vec3(0);
vec3 radiance = vec3(0);
- if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
+ if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR) || GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_MIRROR))
{
vec3 orm = texture(specularRect, tc).rgb;
float perceptualRoughness = orm.g;
@@ -214,7 +214,9 @@ void main()
color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten);
vec3 refnormpersp = reflect(pos.xyz, norm.xyz);
- color = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0 - gloss) * 11).xyz * specularColor;
+
+ if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_MIRROR))
+ color = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0 - gloss) * 11).xyz * specularColor;
if (do_atmospherics)
{