summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan "Geenz" Goodman <geenz@geenzo.com>2023-06-14 05:35:34 -0700
committerJonathan "Geenz" Goodman <geenz@geenzo.com>2023-06-14 05:35:34 -0700
commit3581c81328f4a34f62ca867f3052115ef590a6b6 (patch)
tree8683f4e331f200c54fe5d1b87f2921a45cf3f7af
parentffac2df6caedf48f30b3913386ea6e4c82ae5a0b (diff)
More performance addressing. Ditch glossy SSR on semi-transparent surfaces.
SL-19784
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/materialF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl34
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl8
8 files changed, 46 insertions, 22 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
index cd57b47eae..da5f997429 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
@@ -85,7 +85,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen);
float getAmbientClamp();
void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv,
- vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity);
+ vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent);
vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance)
{
@@ -251,7 +251,7 @@ void main()
vec3 irradiance;
vec3 glossenv;
vec3 legacyenv;
- sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, frag, pos.xyz, norm.xyz, 0.0, 0.0);
+ sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, frag, pos.xyz, norm.xyz, 0.0, 0.0, true);
float da = dot(norm.xyz, light_dir.xyz);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
index d678973515..e8db856b1f 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
@@ -92,7 +92,7 @@ void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float
float calcLegacyDistanceAttenuation(float distance, float falloff);
float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen);
void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv,
- vec2 tc, vec3 pos, vec3 norm, float glossiness);
+ vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent);
void waterClip(vec3 pos);
@@ -224,7 +224,7 @@ void main()
float gloss = 1.0 - perceptualRoughness;
vec3 irradiance = vec3(0);
vec3 radiance = vec3(0);
- sampleReflectionProbes(irradiance, radiance, vary_position.xy*0.5+0.5, pos.xyz, norm.xyz, gloss);
+ sampleReflectionProbes(irradiance, radiance, vary_position.xy*0.5+0.5, pos.xyz, norm.xyz, gloss, true);
// 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,irradiance);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl
index 60134a7f72..719319004d 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl
@@ -34,7 +34,7 @@ uniform mat3 env_mat;
vec3 srgb_to_linear(vec3 c);
void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv,
- vec2 tc, vec3 pos, vec3 norm, float glossiness)
+ vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent)
{
ambenv = vec3(reflection_probe_ambiance * 0.25);
@@ -46,7 +46,7 @@ void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv,
void sampleReflectionProbesWater(inout vec3 ambenv, inout vec3 glossenv,
vec2 tc, vec3 pos, vec3 norm, float glossiness)
{
- sampleReflectionProbes(ambenv, glossenv, tc, pos, norm, glossiness);
+ sampleReflectionProbes(ambenv, glossenv, tc, pos, norm, glossiness, true);
}
vec4 sampleReflectionProbesDebug(vec3 pos)
@@ -56,7 +56,7 @@ vec4 sampleReflectionProbesDebug(vec3 pos)
}
void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv,
- vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity)
+ vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent)
{
ambenv = vec3(reflection_probe_ambiance * 0.25);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl
index 0d77e88831..1537714bb7 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl
@@ -49,7 +49,7 @@ vec3 srgb_to_linear(vec3 c);
// reflection probe interface
void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv,
- vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity);
+ vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent);
void applyLegacyEnv(inout vec3 color, vec3 legacyenv, vec4 spec, vec3 pos, vec3 norm, float envIntensity);
@@ -80,7 +80,7 @@ void main()
vec3 legacyenv;
vec3 norm = normalize(vary_texcoord1.xyz);
vec4 spec = vec4(0,0,0,0);
- sampleReflectionProbesLegacy(ambenv, glossenv, legacyenv, vec2(0), pos.xyz, norm.xyz, spec.a, env_intensity);
+ sampleReflectionProbesLegacy(ambenv, glossenv, legacyenv, vec2(0), pos.xyz, norm.xyz, spec.a, env_intensity, false);
color.rgb = legacy_adjust(color.rgb);
color.rgb = srgb_to_linear(color.rgb);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
index 5fb5647d35..815069bb6a 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
@@ -60,7 +60,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen);
#endif
void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv,
- vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity);
+ vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent);
void applyGlossEnv(inout vec3 color, vec3 glossenv, vec4 spec, vec3 pos, vec3 norm);
void applyLegacyEnv(inout vec3 color, vec3 legacyenv, vec4 spec, vec3 pos, vec3 norm, float envIntensity);
@@ -339,7 +339,7 @@ void main()
vec3 ambenv;
vec3 glossenv;
vec3 legacyenv;
- sampleReflectionProbesLegacy(ambenv, glossenv, legacyenv, pos.xy*0.5+0.5, pos.xyz, norm.xyz, glossiness, env);
+ sampleReflectionProbesLegacy(ambenv, glossenv, legacyenv, pos.xy*0.5+0.5, pos.xyz, norm.xyz, glossiness, env, true);
// use sky settings ambient or irradiance map sample, whichever is brighter
color = max(amblit_linear, ambenv);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
index 53e15bd1a1..6a3a80a779 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
@@ -35,6 +35,8 @@ uniform sampler2D sceneMap;
uniform int cube_snapshot;
uniform float max_probe_lod;
+uniform bool transparent_surface;
+
#define MAX_REFMAP_COUNT 256 // must match LL_MAX_REFLECTION_PROBE_COUNT
layout (std140) uniform ReflectionProbes
@@ -671,7 +673,7 @@ vec3 sampleProbeAmbient(vec3 pos, vec3 dir)
}
void doProbeSample(inout vec3 ambenv, inout vec3 glossenv,
- vec2 tc, vec3 pos, vec3 norm, float glossiness)
+ vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent)
{
// TODO - don't hard code lods
float reflection_lods = max_probe_lod;
@@ -687,7 +689,16 @@ void doProbeSample(inout vec3 ambenv, inout vec3 glossenv,
if (cube_snapshot != 1 && glossiness >= 0.9)
{
vec4 ssr = vec4(0);
- float w = tapScreenSpaceReflection(1, tc, pos, norm, ssr, sceneMap, glossiness);
+ if (transparent)
+ {
+ tapScreenSpaceReflection(1, tc, pos, norm, ssr, sceneMap, 1);
+ ssr.a *= glossiness;
+ }
+ else
+ {
+ tapScreenSpaceReflection(1, tc, pos, norm, ssr, sceneMap, glossiness);
+ }
+
glossenv = mix(glossenv, ssr.rgb, ssr.a);
}
@@ -695,10 +706,10 @@ void doProbeSample(inout vec3 ambenv, inout vec3 glossenv,
}
void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv,
- vec2 tc, vec3 pos, vec3 norm, float glossiness)
+ vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent)
{
preProbeSample(pos);
- doProbeSample(ambenv, glossenv, tc, pos, norm, glossiness);
+ doProbeSample(ambenv, glossenv, tc, pos, norm, glossiness, transparent);
}
void sampleReflectionProbesWater(inout vec3 ambenv, inout vec3 glossenv,
@@ -711,7 +722,7 @@ void sampleReflectionProbesWater(inout vec3 ambenv, inout vec3 glossenv,
// always include void probe on water
probeIndex[probeInfluences++] = 0;
- doProbeSample(ambenv, glossenv, tc, pos, norm, glossiness);
+ doProbeSample(ambenv, glossenv, tc, pos, norm, glossiness, true);
// fudge factor to get PBR water at a similar luminance ot legacy water
glossenv *= 0.4;
@@ -766,7 +777,7 @@ vec4 sampleReflectionProbesDebug(vec3 pos)
}
void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv,
- vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity)
+ vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent)
{
float reflection_lods = max_probe_lod;
preProbeSample(pos);
@@ -790,7 +801,16 @@ void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout
if (cube_snapshot != 1)
{
vec4 ssr = vec4(0);
- float w = tapScreenSpaceReflection(1, tc, pos, norm, ssr, sceneMap, glossiness);
+
+ if (transparent)
+ {
+ tapScreenSpaceReflection(1, tc, pos, norm, ssr, sceneMap, 1);
+ ssr.a *= glossiness;
+ }
+ else
+ {
+ tapScreenSpaceReflection(1, tc, pos, norm, ssr, sceneMap, glossiness);
+ }
glossenv = mix(glossenv, ssr.rgb, ssr.a);
legacyenv = mix(legacyenv, ssr.rgb, ssr.a);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl
index d291196059..1b822d6a21 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl
@@ -310,6 +310,10 @@ vec3 getPoissonSample(int i) {
float tapScreenSpaceReflection(int totalSamples, vec2 tc, vec3 viewPos, vec3 n, inout vec4 collectedColor, sampler2D source, float glossiness)
{
+#ifdef TRANSPARENT_SURFACE
+collectedColor = vec4(1, 0, 1, 1);
+ return 0;
+#endif
collectedColor = vec4(0);
int hits = 0;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 409b46218b..4ef003e0cb 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -69,9 +69,9 @@ vec3 scaleSoftClipFragLinear(vec3 l);
// reflection probe interface
void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv,
- vec2 tc, vec3 pos, vec3 norm, float glossiness);
+ vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent);
void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv,
- vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity);
+ vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent);
void applyGlossEnv(inout vec3 color, vec3 glossenv, vec4 spec, vec3 pos, vec3 norm);
void applyLegacyEnv(inout vec3 color, vec3 legacyenv, vec4 spec, vec3 pos, vec3 norm, float envIntensity);
float getDepth(vec2 pos_screen);
@@ -194,7 +194,7 @@ void main()
// PBR IBL
float gloss = 1.0 - perceptualRoughness;
- sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, norm.xyz, gloss);
+ sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, norm.xyz, gloss, false);
adjustIrradiance(irradiance, amblit_linear, ambocc);
@@ -232,7 +232,7 @@ void main()
vec3 glossenv = vec3(0);
vec3 legacyenv = vec3(0);
- sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, norm.xyz, spec.a, envIntensity);
+ sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, norm.xyz, spec.a, envIntensity, false);
adjustIrradiance(irradiance, amblit_linear, ambocc);