summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings
diff options
context:
space:
mode:
authorRunitaiLinden <davep@lindenlab.com>2023-06-21 20:51:18 -0500
committerRunitaiLinden <davep@lindenlab.com>2023-06-21 20:51:18 -0500
commitf0dc9ea3fd1b91028cf9c039f646a9da48c41f27 (patch)
treee7a97f33b79684550f8d16ff8b1a18564e8d7ea7 /indra/newview/app_settings
parent85967398ff8591170d89374652a6998ff6cd3d69 (diff)
parentdb485adbeb1c7a7d64fbddd124f7f4c73214ef99 (diff)
Merge branch 'DRTVWR-559' of github.com:secondlife/viewer into DRTVWR-559
Diffstat (limited to 'indra/newview/app_settings')
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl41
1 files changed, 26 insertions, 15 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl
index b2d1e75d04..f14f7eac8d 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl
@@ -36,7 +36,7 @@ uniform mat4 inv_modelview_delta;
vec4 getPositionWithDepth(vec2 pos_screen, float depth);
-float random (vec2 uv)
+float random (vec2 uv)
{
return fract(sin(dot(uv, vec2(12.9898, 78.233))) * 43758.5453123); //simple random function
}
@@ -75,7 +75,7 @@ float getLinearDepth(vec2 tc)
return -pos.z;
}
-bool traceScreenRay(vec3 position, vec3 reflection, out vec4 hitColor, out float hitDepth, float depth, sampler2D textureFrame)
+bool traceScreenRay(vec3 position, vec3 reflection, out vec4 hitColor, out float hitDepth, float depth, sampler2D textureFrame)
{
// transform position and reflection into same coordinate frame as the sceneMap and sceneDepth
reflection += position;
@@ -93,22 +93,27 @@ bool traceScreenRay(vec3 position, vec3 reflection, out vec4 hitColor, out float
bool hit = false;
hitColor = vec4(0);
-
int i = 0;
- if (depth > depthRejectBias)
+ if (depth > depthRejectBias)
{
- for (; i < iterationCount && !hit; i++)
+ for (; i < iterationCount && !hit; i++)
{
screenPosition = generateProjectedPosition(marchingPosition);
+ if (screenPosition.x > 1 || screenPosition.x < 0 ||
+ screenPosition.y > 1 || screenPosition.y < 0)
+ {
+ hit = false;
+ break;
+ }
depthFromScreen = getLinearDepth(screenPosition);
delta = abs(marchingPosition.z) - depthFromScreen;
- if (depth < depthFromScreen + epsilon && depth > depthFromScreen - epsilon)
+ if (depth < depthFromScreen + epsilon && depth > depthFromScreen - epsilon)
{
break;
}
- if (abs(delta) < distanceBias)
+ if (abs(delta) < distanceBias)
{
vec4 color = vec4(1);
if(debugDraw)
@@ -118,7 +123,7 @@ bool traceScreenRay(vec3 position, vec3 reflection, out vec4 hitColor, out float
hit = true;
break;
}
- if (isBinarySearchEnabled && delta > 0)
+ if (isBinarySearchEnabled && delta > 0)
{
break;
}
@@ -130,7 +135,7 @@ bool traceScreenRay(vec3 position, vec3 reflection, out vec4 hitColor, out float
step = step * (1.0 - rayStep * max(directionSign, 0.0));
marchingPosition += step * (-directionSign);
}
- else
+ else
{
marchingPosition += step;
}
@@ -148,15 +153,21 @@ bool traceScreenRay(vec3 position, vec3 reflection, out vec4 hitColor, out float
marchingPosition = marchingPosition - step * sign(delta);
screenPosition = generateProjectedPosition(marchingPosition);
+ if (screenPosition.x > 1 || screenPosition.x < 0 ||
+ screenPosition.y > 1 || screenPosition.y < 0)
+ {
+ hit = false;
+ break;
+ }
depthFromScreen = getLinearDepth(screenPosition);
delta = abs(marchingPosition.z) - depthFromScreen;
- if (depth < depthFromScreen + epsilon && depth > depthFromScreen - epsilon)
+ if (depth < depthFromScreen + epsilon && depth > depthFromScreen - epsilon)
{
break;
}
- if (abs(delta) < distanceBias && depthFromScreen != (depth - distanceBias))
+ if (abs(delta) < distanceBias && depthFromScreen != (depth - distanceBias))
{
vec4 color = vec4(1);
if(debugDraw)
@@ -326,8 +337,8 @@ collectedColor = vec4(1, 0, 1, 1);
float jitter = mod( c, 1.0);
vec2 screenpos = 1 - abs(tc * 2 - 1);
- 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 vignette = clamp((abs(screenpos.x) * abs(screenpos.y)) * 16,0, 1);
+ vignette *= clamp((dot(normalize(viewPos), n) * 0.5 + 0.5) * 5.5 - 0.8, 0, 1);
float zFar = 128.0;
vignette *= clamp(1.0+(viewPos.z/zFar), 0.0, 1.0);
@@ -345,7 +356,7 @@ collectedColor = vec4(1, 0, 1, 1);
{
if (vignette > 0)
{
- for (int i = 0; i < totalSamples; i++)
+ for (int i = 0; i < totalSamples; i++)
{
vec3 firstBasis = normalize(cross(getPoissonSample(i), rayDirection));
vec3 secondBasis = normalize(cross(rayDirection, firstBasis));
@@ -358,7 +369,7 @@ collectedColor = vec4(1, 0, 1, 1);
hitpoint.a = 0;
- if (hit)
+ if (hit)
{
++hits;
collectedColor += hitpoint;