summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class3
diff options
context:
space:
mode:
authorRunitaiLinden <davep@lindenlab.com>2023-06-15 14:52:17 -0500
committerRunitaiLinden <davep@lindenlab.com>2023-06-15 14:52:17 -0500
commit6f767db34992b04d67cb25bf976581aee4acac78 (patch)
tree38aff025d05613899ce4cca1a6465550ad44f005 /indra/newview/app_settings/shaders/class3
parent47be24e467a9fe5a2c0466a49f58769f6b81fdc4 (diff)
parent44f26248ec668635b5d5b161f4736a670d364792 (diff)
Merge branch 'DRTVWR-559' of github.com:secondlife/viewer into DRTVWR-559
Diffstat (limited to 'indra/newview/app_settings/shaders/class3')
-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.glsl43
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl8
5 files changed, 62 insertions, 31 deletions
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 615a25d2de..82e2de0c0f 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..1b2a34ef01 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, false);
// 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 5ad25c325f..b2d1e75d04 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl
@@ -61,6 +61,8 @@ uniform float rayStep;
uniform float distanceBias;
uniform float depthRejectBias;
uniform float glossySampleCount;
+uniform float adaptiveStepMultiplier;
+uniform float noiseSine;
float epsilon = 0.1;
@@ -135,7 +137,7 @@ bool traceScreenRay(vec3 position, vec3 reflection, out vec4 hitColor, out float
if (isExponentialStepEnabled)
{
- step *= 1.05;
+ step *= adaptiveStepMultiplier;
}
}
if(isBinarySearchEnabled)
@@ -302,8 +304,16 @@ uniform vec3 POISSON3D_SAMPLES[128] = vec3[128](
vec3(0.2698198, 0.0002266169, 0.3449324)
);
+vec3 getPoissonSample(int i) {
+ return POISSON3D_SAMPLES[i] * 2 - 1;
+}
+
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;
@@ -319,9 +329,10 @@ float tapScreenSpaceReflection(int totalSamples, vec2 tc, vec3 viewPos, vec3 n,
float vignette = clamp((abs(screenpos.x) * abs(screenpos.y)) * 64,0, 1);
vignette *= clamp((dot(normalize(viewPos), n) * 0.5 + 0.5) * 16, 0, 1);
- float zFar = 32.0;
+ float zFar = 128.0;
vignette *= clamp(1.0+(viewPos.z/zFar), 0.0, 1.0);
+ vignette *= clamp(glossiness * 3 - 1.7, 0, 1);
vec4 hitpoint;
@@ -329,17 +340,17 @@ float tapScreenSpaceReflection(int totalSamples, vec2 tc, vec3 viewPos, vec3 n,
totalSamples = int(max(glossySampleCount, glossySampleCount * glossiness * vignette));
- totalSamples = max(totalSamples, 4);
-
+ totalSamples = max(totalSamples, 1);
+ if (glossiness < 0.35)
{
+ if (vignette > 0)
{
for (int i = 0; i < totalSamples; i++)
{
- vec3 firstBasis = normalize(cross(POISSON3D_SAMPLES[i] * 2 - 1, rayDirection));
+ vec3 firstBasis = normalize(cross(getPoissonSample(i), rayDirection));
vec3 secondBasis = normalize(cross(rayDirection, firstBasis));
vec2 coeffs = vec2(random(tc + vec2(0, i)) + random(tc + vec2(i, 0)));
- vec3 reflectionDirectionRandomized = rayDirection + ((firstBasis * coeffs.x + secondBasis * coeffs.y) * 0.125 * max(glossiness, 0.025));
- //vec3 reflectionDirectionRandomized = rayDirection + (POISSON3D_SAMPLES[i] * 2 - 1) * 0.125 * max(glossiness, 0.025);
+ vec3 reflectionDirectionRandomized = rayDirection + ((firstBasis * coeffs.x + secondBasis * coeffs.y) * glossiness);
//float hitDepth;
@@ -354,15 +365,15 @@ float tapScreenSpaceReflection(int totalSamples, vec2 tc, vec3 viewPos, vec3 n,
collectedColor.a += 1;
}
}
- }
-
- if (hits > 0)
- {
- collectedColor /= hits;
- }
- else
- {
- collectedColor = vec4(0);
+
+ if (hits > 0)
+ {
+ collectedColor /= hits;
+ }
+ else
+ {
+ collectedColor = vec4(0);
+ }
}
}
float hitAlpha = hits;
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);