diff options
Diffstat (limited to 'indra/newview/app_settings')
5 files changed, 244 insertions, 50 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 79639c9b32..5dff358a63 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9164,6 +9164,61 @@ <key>Value</key> <integer>0</integer> </map> + <key>RenderScreenSpaceReflectionIterations</key> + <map> + <key>Comment</key> + <string>Renders screen space reflections to better account for dynamic objects with reflection probes.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>S32</string> + <key>Value</key> + <integer>40</integer> + </map> + <key>RenderScreenSpaceReflectionRayStep</key> + <map> + <key>Comment</key> + <string>Renders screen space reflections to better account for dynamic objects with reflection probes.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>0.1</real> + </map> + <key>RenderScreenSpaceReflectionDistanceBias</key> + <map> + <key>Comment</key> + <string>Renders screen space reflections to better account for dynamic objects with reflection probes.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>0.015</real> + </map> + <key>RenderScreenSpaceReflectionDepthRejectBias</key> + <map> + <key>Comment</key> + <string>Renders screen space reflections to better account for dynamic objects with reflection probes.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>0.001</real> + </map> + <key>RenderScreenSpaceReflectionGlossySamples</key> + <map> + <key>Comment</key> + <string>Renders screen space reflections to better account for dynamic objects with reflection probes.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>S32</string> + <key>Value</key> + <integer>8</integer> + </map> <key>RenderBumpmapMinDistanceSquared</key> <map> <key>Comment</key> diff --git a/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflUtil.glsl index d054305767..1a85d70256 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflUtil.glsl @@ -30,7 +30,7 @@ float random (vec2 uv) return 0; } -float tapScreenSpaceReflection(int totalSamples, vec2 tc, vec3 viewPos, vec3 n, inout vec4 collectedColor, sampler2D source) +float tapScreenSpaceReflection(int totalSamples, vec2 tc, vec3 viewPos, vec3 n, inout vec4 collectedColor, sampler2D source, float glossiness) { collectedColor = vec4(0); return 0; diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index bc631afd1d..53e15bd1a1 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -26,7 +26,7 @@ #define FLT_MAX 3.402823466e+38 #if defined(SSR) -float tapScreenSpaceReflection(int totalSamples, vec2 tc, vec3 viewPos, vec3 n, inout vec4 collectedColor, sampler2D source); +float tapScreenSpaceReflection(int totalSamples, vec2 tc, vec3 viewPos, vec3 n, inout vec4 collectedColor, sampler2D source, float glossiness); #endif uniform samplerCubeArray reflectionProbes; @@ -687,9 +687,9 @@ 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); + float w = tapScreenSpaceReflection(1, tc, pos, norm, ssr, sceneMap, glossiness); - glossenv = mix(glossenv, ssr.rgb, w); + glossenv = mix(glossenv, ssr.rgb, ssr.a); } #endif } @@ -790,10 +790,10 @@ 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); + float w = tapScreenSpaceReflection(1, tc, pos, norm, ssr, sceneMap, glossiness); - glossenv = mix(glossenv, ssr.rgb, w); - legacyenv = mix(legacyenv, ssr.rgb, w); + glossenv = mix(glossenv, ssr.rgb, ssr.a); + legacyenv = mix(legacyenv, ssr.rgb, ssr.a); } #endif diff --git a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl index 02e724c155..dbf20fe2d8 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl @@ -51,7 +51,7 @@ vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensi float random (vec2 uv); -float tapScreenSpaceReflection(int totalSamples, vec2 tc, vec3 viewPos, vec3 n, inout vec4 collectedColor, sampler2D source); +float tapScreenSpaceReflection(int totalSamples, vec2 tc, vec3 viewPos, vec3 n, inout vec4 collectedColor, sampler2D source, float glossiness); void main() { @@ -84,7 +84,7 @@ void main() vec4 collectedColor = vec4(0); - float w = tapScreenSpaceReflection(4, tc, pos, n, collectedColor, diffuseMap); + float w = tapScreenSpaceReflection(4, tc, pos, n, collectedColor, diffuseMap, 0); collectedColor.rgb *= specCol.rgb; diff --git a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl index c355b671c0..f75c69e262 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl @@ -55,10 +55,14 @@ bool isBinarySearchEnabled = true; bool isAdaptiveStepEnabled = true; bool isExponentialStepEnabled = true; bool debugDraw = false; -int iterationCount = 40; -float rayStep = 0.1; -float distanceBias = 0.02; -float depthRejectBias = 0.001; + +uniform float iterationCount; +uniform float rayStep; +uniform float distanceBias; +uniform float depthRejectBias; +uniform float glossySampleCount; +uniform float noiseSine; + float epsilon = 0.1; float getLinearDepth(vec2 tc) @@ -168,7 +172,138 @@ bool traceScreenRay(vec3 position, vec3 reflection, out vec4 hitColor, out float return hit; } -float tapScreenSpaceReflection(int totalSamples, vec2 tc, vec3 viewPos, vec3 n, inout vec4 collectedColor, sampler2D source) +uniform vec3 POISSON3D_SAMPLES[128] = vec3[128]( + vec3(0.5433144, 0.1122154, 0.2501391), + vec3(0.6575254, 0.721409, 0.16286), + vec3(0.02888453, 0.05170321, 0.7573566), + vec3(0.06635678, 0.8286457, 0.07157445), + vec3(0.8957489, 0.4005505, 0.7916042), + vec3(0.3423355, 0.5053263, 0.9193521), + vec3(0.9694794, 0.9461077, 0.5406441), + vec3(0.9975473, 0.02789414, 0.7320132), + vec3(0.07781899, 0.3862341, 0.918594), + vec3(0.4439073, 0.9686955, 0.4055861), + vec3(0.9657035, 0.6624081, 0.7082613), + vec3(0.7712346, 0.07273269, 0.3292839), + vec3(0.2489169, 0.2550394, 0.1950516), + vec3(0.7249326, 0.9328285, 0.3352458), + vec3(0.6028461, 0.4424961, 0.5393377), + vec3(0.2879795, 0.7427881, 0.6619173), + vec3(0.3193627, 0.0486145, 0.08109283), + vec3(0.1233155, 0.602641, 0.4378719), + vec3(0.9800708, 0.211729, 0.6771586), + vec3(0.4894537, 0.3319927, 0.8087631), + vec3(0.4802743, 0.6358885, 0.814935), + vec3(0.2692913, 0.9911493, 0.9934899), + vec3(0.5648789, 0.8553897, 0.7784553), + vec3(0.8497344, 0.7870212, 0.02065313), + vec3(0.7503014, 0.2826185, 0.05412734), + vec3(0.8045461, 0.6167251, 0.9532926), + vec3(0.04225039, 0.2141281, 0.8678675), + vec3(0.07116079, 0.9971236, 0.3396397), + vec3(0.464099, 0.480959, 0.2775862), + vec3(0.6346927, 0.31871, 0.6588384), + vec3(0.449012, 0.8189669, 0.2736875), + vec3(0.452929, 0.2119148, 0.672004), + vec3(0.01506042, 0.7102436, 0.9800494), + vec3(0.1970513, 0.4713539, 0.4644522), + vec3(0.13715, 0.7253224, 0.5056525), + vec3(0.9006432, 0.5335414, 0.02206874), + vec3(0.9960898, 0.7961011, 0.01468861), + vec3(0.3386469, 0.6337739, 0.9310676), + vec3(0.1745718, 0.9114985, 0.1728188), + vec3(0.6342545, 0.5721557, 0.4553517), + vec3(0.1347412, 0.1137158, 0.7793725), + vec3(0.3574478, 0.3448052, 0.08741581), + vec3(0.7283059, 0.4753885, 0.2240275), + vec3(0.8293507, 0.9971212, 0.2747005), + vec3(0.6501846, 0.000688076, 0.7795712), + vec3(0.01149416, 0.4930083, 0.792608), + vec3(0.666189, 0.1875442, 0.7256873), + vec3(0.8538797, 0.2107637, 0.1547532), + vec3(0.5826825, 0.9750752, 0.9105834), + vec3(0.8914346, 0.08266425, 0.5484225), + vec3(0.4374518, 0.02987111, 0.7810078), + vec3(0.2287418, 0.1443802, 0.1176908), + vec3(0.2671157, 0.8929081, 0.8989366), + vec3(0.5425819, 0.5524959, 0.6963879), + vec3(0.3515188, 0.8304397, 0.0502702), + vec3(0.3354864, 0.2130747, 0.141169), + vec3(0.9729427, 0.3509927, 0.6098799), + vec3(0.7585629, 0.7115368, 0.9099342), + vec3(0.0140543, 0.6072157, 0.9436461), + vec3(0.9190664, 0.8497264, 0.1643751), + vec3(0.1538157, 0.3219983, 0.2984214), + vec3(0.8854713, 0.2968667, 0.8511457), + vec3(0.1910622, 0.03047311, 0.3571215), + vec3(0.2456353, 0.5568692, 0.3530164), + vec3(0.6927255, 0.8073994, 0.5808484), + vec3(0.8089353, 0.8969175, 0.3427134), + vec3(0.194477, 0.7985603, 0.8712182), + vec3(0.7256182, 0.5653068, 0.3985921), + vec3(0.9889427, 0.4584851, 0.8363391), + vec3(0.5718582, 0.2127113, 0.2950557), + vec3(0.5480209, 0.0193435, 0.2992659), + vec3(0.6598953, 0.09478426, 0.92187), + vec3(0.1385615, 0.2193868, 0.205245), + vec3(0.7623423, 0.1790726, 0.1508465), + vec3(0.7569032, 0.3773386, 0.4393887), + vec3(0.5842971, 0.6538072, 0.5224424), + vec3(0.9954313, 0.5763943, 0.9169143), + vec3(0.001311183, 0.340363, 0.1488652), + vec3(0.8167927, 0.4947158, 0.4454727), + vec3(0.3978434, 0.7106082, 0.002727509), + vec3(0.5459411, 0.7473233, 0.7062873), + vec3(0.4151598, 0.5614617, 0.4748358), + vec3(0.4440694, 0.1195122, 0.9624678), + vec3(0.1081301, 0.4813806, 0.07047641), + vec3(0.2402785, 0.3633997, 0.3898734), + vec3(0.2317942, 0.6488295, 0.4221864), + vec3(0.01145542, 0.9304277, 0.4105759), + vec3(0.3563728, 0.9228861, 0.3282344), + vec3(0.855314, 0.6949819, 0.3175117), + vec3(0.730832, 0.01478493, 0.5728671), + vec3(0.9304829, 0.02653277, 0.712552), + vec3(0.4132186, 0.4127623, 0.6084146), + vec3(0.7517329, 0.9978395, 0.1330464), + vec3(0.5210338, 0.4318751, 0.9721575), + vec3(0.02953994, 0.1375937, 0.9458942), + vec3(0.1835506, 0.9896691, 0.7919457), + vec3(0.3857062, 0.2682322, 0.1264563), + vec3(0.6319699, 0.8735335, 0.04390657), + vec3(0.5630485, 0.3339024, 0.993995), + vec3(0.90701, 0.1512893, 0.8970422), + vec3(0.3027443, 0.1144253, 0.1488708), + vec3(0.9149003, 0.7382028, 0.7914025), + vec3(0.07979286, 0.6892691, 0.2866171), + vec3(0.7743186, 0.8046008, 0.4399814), + vec3(0.3128662, 0.4362317, 0.6030678), + vec3(0.1133721, 0.01605821, 0.391872), + vec3(0.5185481, 0.9210006, 0.7889017), + vec3(0.8217013, 0.325305, 0.1668191), + vec3(0.8358996, 0.1449739, 0.3668382), + vec3(0.1778213, 0.5599256, 0.1327691), + vec3(0.06690693, 0.5508637, 0.07212365), + vec3(0.9750564, 0.284066, 0.5727578), + vec3(0.4350255, 0.8949825, 0.03574753), + vec3(0.8931149, 0.9177974, 0.8123496), + vec3(0.9055127, 0.989903, 0.813235), + vec3(0.2897243, 0.3123978, 0.5083504), + vec3(0.1519223, 0.3958645, 0.2640327), + vec3(0.6840154, 0.6463035, 0.2346607), + vec3(0.986473, 0.8714055, 0.3960275), + vec3(0.6819352, 0.4169535, 0.8379834), + vec3(0.9147297, 0.6144146, 0.7313942), + vec3(0.6554981, 0.5014008, 0.9748477), + vec3(0.9805915, 0.1318207, 0.2371372), + vec3(0.5980836, 0.06796348, 0.9941338), + vec3(0.6836596, 0.9917196, 0.2319056), + vec3(0.5276511, 0.2745509, 0.5422578), + vec3(0.829482, 0.03758276, 0.1240466), + vec3(0.2698198, 0.0002266169, 0.3449324) +); + +float tapScreenSpaceReflection(int totalSamples, vec2 tc, vec3 viewPos, vec3 n, inout vec4 collectedColor, sampler2D source, float glossiness) { collectedColor = vec4(0); int hits = 0; @@ -180,55 +315,59 @@ float tapScreenSpaceReflection(int totalSamples, vec2 tc, vec3 viewPos, vec3 n, vec2 uv2 = tc * screen_res; float c = (uv2.x + uv2.y) * 0.125; float jitter = mod( c, 1.0); - - vec3 firstBasis = normalize(cross(vec3(1,1,1), rayDirection)); - vec3 secondBasis = normalize(cross(rayDirection, firstBasis)); vec2 screenpos = 1 - abs(tc * 2 - 1); - float vignette = clamp((screenpos.x * screenpos.y) * 16,0, 1); - vignette *= clamp((dot(normalize(viewPos), n) * 0.5 + 0.5 - 0.2) * 8, 0, 1); - float zFar = 64.0; - vignette *= clamp(1.0+(viewPos.z/zFar), 0.0, 1.0); - //vignette *= min(linearDepth(getDepth(tc), zNear, zFar) / zFar, 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 zFar = 32.0; + vignette *= clamp(1.0+(viewPos.z/zFar), 0.0, 1.0); + + vec4 hitpoint; + + glossiness = 1 - glossiness; + + totalSamples = int(max(glossySampleCount, glossySampleCount * glossiness * vignette)); + + totalSamples = max(totalSamples, 4); - if (totalSamples > 1) { - for (int i = 0; i < totalSamples; i++) { - vec2 coeffs = vec2(random(tc + vec2(0, i)) + random(tc + vec2(i, 0))); - vec3 reflectionDirectionRandomized = rayDirection + firstBasis * coeffs.x + secondBasis * coeffs.y; + for (int i = 0; i < totalSamples; i++) + { + vec3 firstBasis = normalize(cross(POISSON3D_SAMPLES[i] * 2 - 1, 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); - //float hitDepth; + //float hitDepth; - bool hit = traceScreenRay(viewPos, normalize(reflectionDirectionRandomized), hitpoint, depth, depth, source); + bool hit = traceScreenRay(viewPos, normalize(reflectionDirectionRandomized), hitpoint, depth, depth, source); - if (hit) - { - ++hits; - collectedColor += hitpoint; + hitpoint.a = 0; + + if (hit) + { + ++hits; + collectedColor += hitpoint; + collectedColor.a += 1; + } } } - } - else - { - bool hit = traceScreenRay(viewPos, normalize(rayDirection), hitpoint, depth, depth, source); - if (hit) + + if (hits > 0) { - ++hits; - collectedColor += hitpoint; + collectedColor /= hits; + } + else + { + collectedColor = vec4(0); } } - - if (hits > 0) - { - collectedColor /= hits; - } - else - { - collectedColor = vec4(0); - } - - return min(float(hits), 1.0) * vignette; + float hitAlpha = hits; + hitAlpha /= totalSamples; + collectedColor.a = hitAlpha * vignette; + return hits; } |