From 31e2fa5e50bc5aad265e8ec12613223eeb3ae3e1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 21 Jun 2022 22:44:30 -0500 Subject: SL-17600 WIP -- Proper radiance maps (not just mipped cubemaps). --- .../shaders/class1/interface/radianceGenF.glsl | 167 +++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl (limited to 'indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl new file mode 100644 index 0000000000..27008b8a1c --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -0,0 +1,167 @@ +/** + * @file radianceGenF.glsl + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2022, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + + +/*[EXTRA_CODE_HERE]*/ + +#define REFMAP_COUNT 256 + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform samplerCubeArray reflectionProbes; + +VARYING vec3 vary_dir; + +// ============================================================================================================= +// Parts of this file are (c) 2018 Sascha Willems +// SNIPPED FROM https://github.com/SaschaWillems/Vulkan-glTF-PBR/blob/master/data/shaders/prefilterenvmap.frag +/* +MIT License + +Copyright (c) 2018 Sascha Willems + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ +// ============================================================================================================= + + +uniform float roughness; + +uniform int numSamples; + +const float PI = 3.1415926536; + +// Based omn http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/ +float random(vec2 co) +{ + float a = 12.9898; + float b = 78.233; + float c = 43758.5453; + float dt= dot(co.xy ,vec2(a,b)); + float sn= mod(dt,3.14); + return fract(sin(sn) * c); +} + +vec2 hammersley2d(uint i, uint N) +{ + // Radical inverse based on http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html + uint bits = (i << 16u) | (i >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + float rdi = float(bits) * 2.3283064365386963e-10; + return vec2(float(i) /float(N), rdi); +} + +// Based on http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_slides.pdf +vec3 importanceSample_GGX(vec2 Xi, float roughness, vec3 normal) +{ + // Maps a 2D point to a hemisphere with spread based on roughness + float alpha = roughness * roughness; + float phi = 2.0 * PI * Xi.x + random(normal.xz) * 0.1; + float cosTheta = sqrt((1.0 - Xi.y) / (1.0 + (alpha*alpha - 1.0) * Xi.y)); + float sinTheta = sqrt(1.0 - cosTheta * cosTheta); + vec3 H = vec3(sinTheta * cos(phi), sinTheta * sin(phi), cosTheta); + + // Tangent space + vec3 up = abs(normal.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangentX = normalize(cross(up, normal)); + vec3 tangentY = normalize(cross(normal, tangentX)); + + // Convert to world Space + return normalize(tangentX * H.x + tangentY * H.y + normal * H.z); +} + +// Normal Distribution function +float D_GGX(float dotNH, float roughness) +{ + float alpha = roughness * roughness; + float alpha2 = alpha * alpha; + float denom = dotNH * dotNH * (alpha2 - 1.0) + 1.0; + return (alpha2)/(PI * denom*denom); +} + +vec3 prefilterEnvMap(vec3 R, float roughness) +{ + vec3 N = R; + vec3 V = R; + vec3 color = vec3(0.0); + float totalWeight = 0.0; + float envMapDim = 256.0; + for(uint i = 0u; i < numSamples; i++) { + vec2 Xi = hammersley2d(i, numSamples); + vec3 H = importanceSample_GGX(Xi, roughness, N); + vec3 L = 2.0 * dot(V, H) * H - V; + float dotNL = clamp(dot(N, L), 0.0, 1.0); + if(dotNL > 0.0) { + // Filtering based on https://placeholderart.wordpress.com/2015/07/28/implementation-notes-runtime-environment-map-filtering-for-image-based-lighting/ + + float dotNH = clamp(dot(N, H), 0.0, 1.0); + float dotVH = clamp(dot(V, H), 0.0, 1.0); + + // Probability Distribution Function + float pdf = D_GGX(dotNH, roughness) * dotNH / (4.0 * dotVH) + 0.0001; + // Slid angle of current smple + float omegaS = 1.0 / (float(numSamples) * pdf); + // Solid angle of 1 pixel across all cube faces + float omegaP = 4.0 * PI / (6.0 * envMapDim * envMapDim); + // Biased (+1.0) mip level for better result + float mipLevel = roughness == 0.0 ? 0.0 : max(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f); + color += textureLod(reflectionProbes, vec4(L,REFMAP_COUNT), mipLevel).rgb * dotNL; + totalWeight += dotNL; + + } + } + return (color / totalWeight); +} + +void main() +{ + vec3 N = normalize(vary_dir); + frag_color = vec4(prefilterEnvMap(N, roughness), 1.0); +} +// ============================================================================================================= + -- cgit v1.2.3 From d0d1b832d4983f35ab29947eb6fda54a8aa48f8a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 22 Jun 2022 13:25:50 -0500 Subject: SL-17600 Proper irradiance probes. --- .../newview/app_settings/shaders/class1/interface/radianceGenF.glsl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index 27008b8a1c..3fc227eae7 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -26,8 +26,6 @@ /*[EXTRA_CODE_HERE]*/ -#define REFMAP_COUNT 256 - #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; #else @@ -35,6 +33,7 @@ out vec4 frag_color; #endif uniform samplerCubeArray reflectionProbes; +uniform int sourceIdx; VARYING vec3 vary_dir; @@ -150,7 +149,7 @@ vec3 prefilterEnvMap(vec3 R, float roughness) float omegaP = 4.0 * PI / (6.0 * envMapDim * envMapDim); // Biased (+1.0) mip level for better result float mipLevel = roughness == 0.0 ? 0.0 : max(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f); - color += textureLod(reflectionProbes, vec4(L,REFMAP_COUNT), mipLevel).rgb * dotNL; + color += textureLod(reflectionProbes, vec4(L,sourceIdx), mipLevel).rgb * dotNL; totalWeight += dotNL; } -- cgit v1.2.3 From 6540b4c480d1d4b4c8342a0d093d09f525485659 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 22 Jun 2022 19:56:26 -0500 Subject: SL-17600 Cubemap filter tuning. --- .../newview/app_settings/shaders/class1/interface/radianceGenF.glsl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index 3fc227eae7..94fedce243 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -68,7 +68,7 @@ SOFTWARE. uniform float roughness; -uniform int numSamples; +uniform float mipLevel; const float PI = 3.1415926536; @@ -130,6 +130,8 @@ vec3 prefilterEnvMap(vec3 R, float roughness) vec3 color = vec3(0.0); float totalWeight = 0.0; float envMapDim = 256.0; + int numSamples = 32/max(int(mipLevel), 1); + for(uint i = 0u; i < numSamples; i++) { vec2 Xi = hammersley2d(i, numSamples); vec3 H = importanceSample_GGX(Xi, roughness, N); @@ -148,7 +150,7 @@ vec3 prefilterEnvMap(vec3 R, float roughness) // Solid angle of 1 pixel across all cube faces float omegaP = 4.0 * PI / (6.0 * envMapDim * envMapDim); // Biased (+1.0) mip level for better result - float mipLevel = roughness == 0.0 ? 0.0 : max(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f); + //float mipLevel = roughness == 0.0 ? 0.0 : max(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f); color += textureLod(reflectionProbes, vec4(L,sourceIdx), mipLevel).rgb * dotNL; totalWeight += dotNL; -- cgit v1.2.3 From 48eea4de0a9304cd25af46defb52cb0adeeb87c4 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Sat, 17 Sep 2022 15:37:21 -0500 Subject: Adjust radiance maps to better match Substance --- indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index 94fedce243..05c86de6d4 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -151,7 +151,7 @@ vec3 prefilterEnvMap(vec3 R, float roughness) float omegaP = 4.0 * PI / (6.0 * envMapDim * envMapDim); // Biased (+1.0) mip level for better result //float mipLevel = roughness == 0.0 ? 0.0 : max(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f); - color += textureLod(reflectionProbes, vec4(L,sourceIdx), mipLevel).rgb * dotNL; + color += textureLod(reflectionProbes, vec4(L,sourceIdx), mipLevel+0.75).rgb * dotNL; totalWeight += dotNL; } -- cgit v1.2.3 From 655f8d8ee14598a9368d2593533ee190f878b6dd Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Sat, 17 Sep 2022 20:18:54 -0500 Subject: Fix for overbright and artifacted radiance maps on NVIDIA hardware --- indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index 05c86de6d4..94fedce243 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -151,7 +151,7 @@ vec3 prefilterEnvMap(vec3 R, float roughness) float omegaP = 4.0 * PI / (6.0 * envMapDim * envMapDim); // Biased (+1.0) mip level for better result //float mipLevel = roughness == 0.0 ? 0.0 : max(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f); - color += textureLod(reflectionProbes, vec4(L,sourceIdx), mipLevel+0.75).rgb * dotNL; + color += textureLod(reflectionProbes, vec4(L,sourceIdx), mipLevel).rgb * dotNL; totalWeight += dotNL; } -- cgit v1.2.3 From 04d3a29a699cd0a4c08ab096bfbab153e65c1fd1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 19 Sep 2022 17:27:33 -0500 Subject: SL-18190 Faster better stronger radiance/irradiance maps --- .../shaders/class1/interface/radianceGenF.glsl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index 94fedce243..7c175eab5f 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -66,7 +66,7 @@ SOFTWARE. // ============================================================================================================= -uniform float roughness; +//uniform float roughness; uniform float mipLevel; @@ -123,14 +123,18 @@ float D_GGX(float dotNH, float roughness) return (alpha2)/(PI * denom*denom); } -vec3 prefilterEnvMap(vec3 R, float roughness) +vec3 prefilterEnvMap(vec3 R) { vec3 N = R; vec3 V = R; vec3 color = vec3(0.0); float totalWeight = 0.0; float envMapDim = 256.0; - int numSamples = 32/max(int(mipLevel), 1); + int numSamples = 8; + + float numMips = 7.0; + + float roughness = (mipLevel+1)/numMips; for(uint i = 0u; i < numSamples; i++) { vec2 Xi = hammersley2d(i, numSamples); @@ -150,8 +154,9 @@ vec3 prefilterEnvMap(vec3 R, float roughness) // Solid angle of 1 pixel across all cube faces float omegaP = 4.0 * PI / (6.0 * envMapDim * envMapDim); // Biased (+1.0) mip level for better result - //float mipLevel = roughness == 0.0 ? 0.0 : max(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f); - color += textureLod(reflectionProbes, vec4(L,sourceIdx), mipLevel).rgb * dotNL; + //float mip = roughness == 0.0 ? 0.0 : max(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f); + float mip = clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, 7.f); + color += textureLod(reflectionProbes, vec4(L,sourceIdx), mip).rgb * dotNL; totalWeight += dotNL; } @@ -162,7 +167,7 @@ vec3 prefilterEnvMap(vec3 R, float roughness) void main() { vec3 N = normalize(vary_dir); - frag_color = vec4(prefilterEnvMap(N, roughness), 1.0); + frag_color = vec4(prefilterEnvMap(N), 1.0); } // ============================================================================================================= -- cgit v1.2.3 From c466e44334fd60c8270b68c70b8ae999b8dbd395 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 20 Sep 2022 19:09:26 -0500 Subject: SL-18190 Reduce banding (stay in linear space as much as possible, increase precision of reflection probes). Faster radiance and irradiance map generation. --- .../shaders/class1/interface/radianceGenF.glsl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index 7c175eab5f..bb4a79247d 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -37,6 +37,10 @@ uniform int sourceIdx; VARYING vec3 vary_dir; +//uniform float roughness; + +uniform float mipLevel; + // ============================================================================================================= // Parts of this file are (c) 2018 Sascha Willems // SNIPPED FROM https://github.com/SaschaWillems/Vulkan-glTF-PBR/blob/master/data/shaders/prefilterenvmap.frag @@ -65,11 +69,6 @@ SOFTWARE. */ // ============================================================================================================= - -//uniform float roughness; - -uniform float mipLevel; - const float PI = 3.1415926536; // Based omn http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/ @@ -130,11 +129,13 @@ vec3 prefilterEnvMap(vec3 R) vec3 color = vec3(0.0); float totalWeight = 0.0; float envMapDim = 256.0; - int numSamples = 8; + int numSamples = 4; float numMips = 7.0; - float roughness = (mipLevel+1)/numMips; + float roughness = mipLevel/numMips; + + numSamples = max(int(numSamples*roughness), 1); for(uint i = 0u; i < numSamples; i++) { vec2 Xi = hammersley2d(i, numSamples); @@ -154,8 +155,8 @@ vec3 prefilterEnvMap(vec3 R) // Solid angle of 1 pixel across all cube faces float omegaP = 4.0 * PI / (6.0 * envMapDim * envMapDim); // Biased (+1.0) mip level for better result - //float mip = roughness == 0.0 ? 0.0 : max(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f); - float mip = clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, 7.f); + float mip = roughness == 0.0 ? 0.0 : clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, 7.f); + //float mip = clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, 7.f); color += textureLod(reflectionProbes, vec4(L,sourceIdx), mip).rgb * dotNL; totalWeight += dotNL; @@ -170,4 +171,3 @@ void main() frag_color = vec4(prefilterEnvMap(N), 1.0); } // ============================================================================================================= - -- cgit v1.2.3 From 9448db5d4af7bba094e5bc51f85e5c2491d3f5a1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 6 Oct 2022 18:40:01 -0500 Subject: SL-18190 Water shader WIP. Better parallax correction for sphere probes. Reduce probe memory footprint. Remove framebuffer copies and move to deprecate stencil buffer usage. --- .../app_settings/shaders/class1/interface/radianceGenF.glsl | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index bb4a79247d..f4879b52de 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -26,11 +26,7 @@ /*[EXTRA_CODE_HERE]*/ -#ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif uniform samplerCubeArray reflectionProbes; uniform int sourceIdx; @@ -122,11 +118,11 @@ float D_GGX(float dotNH, float roughness) return (alpha2)/(PI * denom*denom); } -vec3 prefilterEnvMap(vec3 R) +vec4 prefilterEnvMap(vec3 R) { vec3 N = R; vec3 V = R; - vec3 color = vec3(0.0); + vec4 color = vec4(0.0); float totalWeight = 0.0; float envMapDim = 256.0; int numSamples = 4; @@ -157,7 +153,7 @@ vec3 prefilterEnvMap(vec3 R) // Biased (+1.0) mip level for better result float mip = roughness == 0.0 ? 0.0 : clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, 7.f); //float mip = clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, 7.f); - color += textureLod(reflectionProbes, vec4(L,sourceIdx), mip).rgb * dotNL; + color += textureLod(reflectionProbes, vec4(L,sourceIdx), mip) * dotNL; totalWeight += dotNL; } @@ -168,6 +164,6 @@ vec3 prefilterEnvMap(vec3 R) void main() { vec3 N = normalize(vary_dir); - frag_color = vec4(prefilterEnvMap(N), 1.0); + frag_color = prefilterEnvMap(N); } // ============================================================================================================= -- cgit v1.2.3 From de4c018499ddaebbe466fb5a8938554a2d4a3b19 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 19 Oct 2022 14:41:17 -0500 Subject: SL-18105 Hook up render pipe directly to LLTextureEntry::mGLTFMaterial and add LLViewerFetchedTextures to LLFetchedGLTFMaterial. Lower reflection probe resolution to 128x128 per side. --- indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index f4879b52de..32f157e9d2 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -127,7 +127,7 @@ vec4 prefilterEnvMap(vec3 R) float envMapDim = 256.0; int numSamples = 4; - float numMips = 7.0; + float numMips = 6.0; float roughness = mipLevel/numMips; @@ -151,7 +151,7 @@ vec4 prefilterEnvMap(vec3 R) // Solid angle of 1 pixel across all cube faces float omegaP = 4.0 * PI / (6.0 * envMapDim * envMapDim); // Biased (+1.0) mip level for better result - float mip = roughness == 0.0 ? 0.0 : clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, 7.f); + float mip = roughness == 0.0 ? 0.0 : clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, numMips); //float mip = clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, 7.f); color += textureLod(reflectionProbes, vec4(L,sourceIdx), mip) * dotNL; totalWeight += dotNL; -- cgit v1.2.3 From 97277e74a9d966ed441e51f844f9012f55cca3dc Mon Sep 17 00:00:00 2001 From: Jonathan Goodman Date: Mon, 14 Nov 2022 18:12:22 +0000 Subject: Merged in SL-18332 (pull request #1194) First pass of Screen Space Reflections Approved-by: Dave Parks --- indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index 839e10ce5e..858052281b 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -36,6 +36,7 @@ VARYING vec3 vary_dir; //uniform float roughness; uniform float mipLevel; +uniform int u_width; // ============================================================================================================= // Parts of this file are (c) 2018 Sascha Willems @@ -124,7 +125,7 @@ vec4 prefilterEnvMap(vec3 R) vec3 V = R; vec4 color = vec4(0.0); float totalWeight = 0.0; - float envMapDim = 128.0; + float envMapDim = u_width; int numSamples = 4; float numMips = 6.0; -- cgit v1.2.3 From 10b8dcc497599042655dcc4037c9ae98d494bd6f Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 30 Jan 2023 18:56:19 -0600 Subject: SL-19015 Bump probe resolution back to 256 by default (drop to 128 if vram < 2GB), remove irradiance map feedback loop (one bounce, but but more stable and allows for much brighter first bounce), make sky contribution to irradiance not tint the world blue. Make irradiance that appears in radiance maps match world irradiance. --- indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index 858052281b..e60ddcd569 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -37,6 +37,8 @@ VARYING vec3 vary_dir; uniform float mipLevel; uniform int u_width; +uniform float max_probe_lod; + // ============================================================================================================= // Parts of this file are (c) 2018 Sascha Willems @@ -128,7 +130,7 @@ vec4 prefilterEnvMap(vec3 R) float envMapDim = u_width; int numSamples = 4; - float numMips = 6.0; + float numMips = max_probe_lod; float roughness = mipLevel/numMips; -- cgit v1.2.3 From cd0944caa692e6440f85d21fa706636fc5e46e27 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 17 Feb 2023 14:55:06 -0600 Subject: SL-19239 Redo integration of Sascha's radiance map filter. --- .../shaders/class1/interface/radianceGenF.glsl | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index e60ddcd569..b6f080739e 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -127,14 +127,11 @@ vec4 prefilterEnvMap(vec3 R) vec3 V = R; vec4 color = vec4(0.0); float totalWeight = 0.0; - float envMapDim = u_width; - int numSamples = 4; - - float numMips = max_probe_lod; + float envMapDim = float(textureSize(reflectionProbes, 0).s); + float roughness = mipLevel/max_probe_lod; + int numSamples = max(int(32*roughness), 1); - float roughness = mipLevel/numMips; - - numSamples = max(int(numSamples*roughness), 1); + float numMips = max_probe_lod+1; for(uint i = 0u; i < numSamples; i++) { vec2 Xi = hammersley2d(i, numSamples); @@ -154,11 +151,9 @@ vec4 prefilterEnvMap(vec3 R) // Solid angle of 1 pixel across all cube faces float omegaP = 4.0 * PI / (6.0 * envMapDim * envMapDim); // Biased (+1.0) mip level for better result - float mip = roughness == 0.0 ? 0.0 : clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, numMips); - //float mip = clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, 7.f); - color += textureLod(reflectionProbes, vec4(L,sourceIdx), mip) * dotNL; + float mipLevel = roughness == 0.0 ? 0.0 : max(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f); + color += textureLod(reflectionProbes, vec4(L, sourceIdx), mipLevel) * dotNL; totalWeight += dotNL; - } } return (color / totalWeight); -- cgit v1.2.3 From 8c7c4c424d07e39191e827f441af406724829b50 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 22 Mar 2023 10:38:24 -0500 Subject: DRTVWR-559 Quality pass -- Fix sky banding, fix off-by-one-mip in reflection probes (thanks Rye), remove noiseMap from light shaders (removes speckles), make irradiance maps RGB16F instead of RGBA16. Use actual luminance for sky instead of max color component during irradiance map pass. --- indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index b6f080739e..a1839d4a67 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -151,7 +151,7 @@ vec4 prefilterEnvMap(vec3 R) // Solid angle of 1 pixel across all cube faces float omegaP = 4.0 * PI / (6.0 * envMapDim * envMapDim); // Biased (+1.0) mip level for better result - float mipLevel = roughness == 0.0 ? 0.0 : max(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f); + float mipLevel = roughness == 0.0 ? 0.0 : clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, max_probe_lod); color += textureLod(reflectionProbes, vec4(L, sourceIdx), mipLevel) * dotNL; totalWeight += dotNL; } -- cgit v1.2.3 From bb79718c8f0050569c80a1bfe4dd428321706d1a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 6 Apr 2023 13:21:25 -0500 Subject: SL-19538 Followup -- scrub all possible sources of NaNs, make dynamic exposure controls not persist, limit exposure range, and do a debug gl pass. --- indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index a1839d4a67..cd5d97c785 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -162,6 +162,6 @@ vec4 prefilterEnvMap(vec3 R) void main() { vec3 N = normalize(vary_dir); - frag_color = prefilterEnvMap(N); + frag_color = max(prefilterEnvMap(N), vec4(0)); } // ============================================================================================================= -- cgit v1.2.3 From c827d32ebedeaa46ed75a91ae779f6547fc0d090 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 17 May 2023 18:09:36 -0500 Subject: SL-19655 Decruft legacy GLSL shaders and now unused build queues. --- indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index cd5d97c785..9ecdf0bf77 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -31,7 +31,7 @@ out vec4 frag_color; uniform samplerCubeArray reflectionProbes; uniform int sourceIdx; -VARYING vec3 vary_dir; +in vec3 vary_dir; //uniform float roughness; -- cgit v1.2.3