summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings
diff options
context:
space:
mode:
authorJonathan "Geenz" Goodman <geenz@geenzo.com>2024-03-06 17:56:16 -0800
committerJonathan "Geenz" Goodman <geenz@geenzo.com>2024-03-06 17:56:16 -0800
commit1fc45a50ff15e6f31a4554da83256b7f59b1af15 (patch)
treeb65f155530ebc130443582ca0fedda284833b02d /indra/newview/app_settings
parent47cd3cb0ad03c91f118fd20fea8d8924759fd2b7 (diff)
#681 Add probe blending for mirrors.
Diffstat (limited to 'indra/newview/app_settings')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl43
3 files changed, 26 insertions, 24 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl
index c83a6be85d..57c0a6024f 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl
@@ -133,6 +133,7 @@ uniform vec4 minimum_alphas; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlpha
#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3
in vec4[2] vary_coords;
#endif
+in vec3 vary_position;
in vec3 vary_normal;
in vec3 vary_tangent;
flat in float vary_sign;
@@ -140,11 +141,14 @@ in vec4 vary_texcoord0;
in vec4 vary_texcoord1;
vec2 encode_normal(vec3 n);
+void mirrorClip(vec3 position);
float terrain_mix(TerrainMix tm, vec4 tms4);
void main()
{
+ // Make sure we clip the terrain if we're in a mirror.
+ mirrorClip(vary_position);
#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3
TerrainCoord terrain_texcoord = vary_coords;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl
index dbb9404219..489fc26e3f 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl
@@ -25,6 +25,7 @@
uniform mat3 normal_matrix;
uniform mat4 texture_matrix0;
+uniform mat4 modelview_matrix;
uniform mat4 modelview_projection_matrix;
in vec3 position;
@@ -42,6 +43,7 @@ out vec3 vary_tangent;
flat out float vary_sign;
out vec4 vary_texcoord0;
out vec4 vary_texcoord1;
+out vec3 vary_position;
// *HACK: tangent_space_transform should use texture_normal_transform, or maybe
// we shouldn't use tangent_space_transform at all. See the call to
@@ -55,6 +57,7 @@ void main()
{
//transform vertex
gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+ vary_position = (modelview_matrix*vec4(position.xyz, 1.0)).xyz;
vec3 n = normal_matrix * normal;
vary_vertex_normal = normal;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
index 257299258e..4f2475b101 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
@@ -48,6 +48,7 @@ layout (std140) uniform ReflectionProbes
/// box[0..2] - plane 0 .. 2 in [A,B,C,D] notation
// box[3][0..2] - plane thickness
mat4 refBox[MAX_REFMAP_COUNT];
+ mat4 heroBox;
// list of bounding spheres for reflection probes sorted by distance to camera (closest first)
vec4 refSphere[MAX_REFMAP_COUNT];
// extra parameters
@@ -56,6 +57,7 @@ layout (std140) uniform ReflectionProbes
// z - fade in
// w - znear
vec4 refParams[MAX_REFMAP_COUNT];
+ vec4 heroSphere;
// index of cube map in reflectionProbes for a corresponding reflection probe
// e.g. cube map channel of refSphere[2] is stored in refIndex[2]
// refIndex.x - cubemap channel in reflectionProbes
@@ -71,6 +73,10 @@ layout (std140) uniform ReflectionProbes
// number of reflection probes present in refSphere
int refmapCount;
+
+ int heroShape;
+ int heroMipCount;
+ int heroProbeCount;
};
// Inputs
@@ -682,48 +688,37 @@ vec3 sampleProbeAmbient(vec3 pos, vec3 dir, vec3 amblit)
return col[1]+col[0];
}
-
#if defined(HERO_PROBES)
uniform vec4 clipPlane;
-
uniform samplerCubeArray heroProbes;
-layout (std140) uniform HeroProbeData
-{
- mat4 heroBox[1];
- vec4 heroSphere[1];
- uint heroShape[1];
- int heroMipCount;
- int heroProbeCount;
-};
-
void tapHeroProbe(inout vec3 glossenv, vec3 pos, vec3 norm, float glossiness)
{
float clipDist = dot(pos.xyz, clipPlane.xyz) + clipPlane.w;
float w = 0;
float dw = 0;
- if (heroShape[0] < 1)
+ float falloffMult = 10;
+ vec3 refnormpersp = reflect(pos.xyz, norm.xyz);
+ if (heroShape < 1)
{
float d = 0;
- boxIntersect(pos, norm, heroBox[0], d, 1.0);
+ boxIntersect(pos, norm, heroBox, d, 1.0);
- w = max(d, 0.001);
+ w = max(d, 0);
}
else
{
- float r = heroSphere[0].w;
+ float r = heroSphere.w;
- w = sphereWeight(pos, norm, heroSphere[0].xyz, r, vec4(1), dw);
- }
-
- {
- vec3 refnormpersp = reflect(pos.xyz, norm.xyz);
- if (dot(refnormpersp.xyz, clipPlane.xyz) > 0.0)
- {
- glossenv = mix(glossenv, textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0-glossiness)*heroMipCount).xyz, w);
- }
+ w = sphereWeight(pos, refnormpersp, heroSphere.xyz, r, vec4(1), dw);
}
+
+ clipDist = clipDist * 0.95 + 0.05;
+ clipDist = clamp(clipDist * falloffMult, 0, 1);
+ w = clamp(w * falloffMult * clipDist, 0, 1);
+
+ glossenv = mix(glossenv, textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0-glossiness)*heroMipCount).xyz, w);
}
#else