From 3400e5fd302c0d9dea6386c4d5bf38876f2cc287 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 16 May 2022 17:21:08 +0000 Subject: SL-17284 Reflection probe tuning and optimization take 1 --- .../shaders/class1/interface/reflectionmipF.glsl | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl new file mode 100644 index 0000000000..ea687aab4f --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl @@ -0,0 +1,75 @@ +/** + * @file reflectionmipF.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$ + */ + +#extension GL_ARB_texture_rectangle : enable + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2DRect screenMap; + +VARYING vec2 vary_texcoord0; + +void main() +{ + float w[9]; + + float c = 1.0/16.0; //corner weight + float e = 1.0/8.0; //edge weight + float m = 1.0/4.0; //middle weight + + //float wsum = c*4+e*4+m; + + w[0] = c; w[1] = e; w[2] = c; + w[3] = e; w[4] = m; w[5] = e; + w[6] = c; w[7] = e; w[8] = c; + + vec2 tc[9]; + + float ed = 1; + float cd = 1; + + + tc[0] = vec2(-cd, cd); tc[1] = vec2(0, ed); tc[2] = vec2(cd, cd); + tc[3] = vec2(-ed, 0); tc[4] = vec2(0, 0); tc[5] = vec2(ed, 0); + tc[6] = vec2(-cd, -cd); tc[7] = vec2(0, -ed); tc[8] = vec2(cd, -1); + + vec3 color = vec3(0,0,0); + + for (int i = 0; i < 9; ++i) + { + color += texture2DRect(screenMap, vary_texcoord0.xy+tc[i]).rgb * w[i]; + //color += texture2DRect(screenMap, vary_texcoord0.xy+tc[i]*2.0).rgb * w[i]*0.5; + } + + //color /= wsum; + + frag_color = vec4(color, 1.0); +} -- cgit v1.2.3 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 +++++++++++++++++++++ .../shaders/class1/interface/radianceGenV.glsl | 38 +++++ 2 files changed, 205 insertions(+) create mode 100644 indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/interface/radianceGenV.glsl (limited to 'indra/newview/app_settings/shaders/class1/interface') 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); +} +// ============================================================================================================= + diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenV.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenV.glsl new file mode 100644 index 0000000000..5f5d9396ff --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenV.glsl @@ -0,0 +1,38 @@ +/** + * @file radianceGenV.glsl + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, 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$ + */ + +uniform mat4 modelview_matrix; + +ATTRIBUTE vec3 position; + +VARYING vec3 vary_dir; + +void main() +{ + gl_Position = vec4(position, 1.0); + + vary_dir = vec3(modelview_matrix * vec4(position, 1.0)).xyz; +} + -- 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. --- .../shaders/class1/interface/irradianceGenF.glsl | 99 ++++++++++++++++++++++ .../shaders/class1/interface/irradianceGenV.glsl | 38 +++++++++ .../shaders/class1/interface/radianceGenF.glsl | 5 +- 3 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/interface/irradianceGenV.glsl (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl new file mode 100644 index 0000000000..2028509775 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl @@ -0,0 +1,99 @@ +/** + * @file irradianceGenF.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]*/ + + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform samplerCubeArray reflectionProbes; +uniform int sourceIdx; + +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/irradiancecube.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. +*/ +// ============================================================================================================= + + + +#define PI 3.1415926535897932384626433832795 + +float deltaPhi = PI/16.0; +float deltaTheta = deltaPhi*0.25; + +void main() +{ + vec3 N = normalize(vary_dir); + vec3 up = vec3(0.0, 1.0, 0.0); + vec3 right = normalize(cross(up, N)); + up = cross(N, right); + + const float TWO_PI = PI * 2.0; + const float HALF_PI = PI * 0.5; + + vec3 color = vec3(0.0); + uint sampleCount = 0u; + for (float phi = 0.0; phi < TWO_PI; phi += deltaPhi) { + for (float theta = 0.0; theta < HALF_PI; theta += deltaTheta) { + vec3 tempVec = cos(phi) * right + sin(phi) * up; + vec3 sampleVector = cos(theta) * N + sin(theta) * tempVec; + color += textureLod(reflectionProbes, vec4(sampleVector, sourceIdx), 3).rgb * cos(theta) * sin(theta); + sampleCount++; + } + } + frag_color = vec4(PI * color / float(sampleCount), 1.0); +} +// ============================================================================================================= + diff --git a/indra/newview/app_settings/shaders/class1/interface/irradianceGenV.glsl b/indra/newview/app_settings/shaders/class1/interface/irradianceGenV.glsl new file mode 100644 index 0000000000..5190abf17c --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/irradianceGenV.glsl @@ -0,0 +1,38 @@ +/** + * @file irradianceGenV.glsl + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, 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$ + */ + +uniform mat4 modelview_matrix; + +ATTRIBUTE vec3 position; + +VARYING vec3 vary_dir; + +void main() +{ + gl_Position = vec4(position, 1.0); + + vary_dir = vec3(modelview_matrix * vec4(position, 1.0)).xyz; +} + 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. --- .../app_settings/shaders/class1/interface/irradianceGenF.glsl | 9 +++++---- .../app_settings/shaders/class1/interface/radianceGenF.glsl | 6 ++++-- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl index 2028509775..4d91395a1b 100644 --- a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl @@ -70,11 +70,12 @@ SOFTWARE. #define PI 3.1415926535897932384626433832795 -float deltaPhi = PI/16.0; -float deltaTheta = deltaPhi*0.25; - void main() { + float deltaPhi = (2.0 * PI) / 11.25; + float deltaTheta = (0.5 * PI) / 4.0; + float mipLevel = 2; + vec3 N = normalize(vary_dir); vec3 up = vec3(0.0, 1.0, 0.0); vec3 right = normalize(cross(up, N)); @@ -89,7 +90,7 @@ void main() for (float theta = 0.0; theta < HALF_PI; theta += deltaTheta) { vec3 tempVec = cos(phi) * right + sin(phi) * up; vec3 sampleVector = cos(theta) * N + sin(theta) * tempVec; - color += textureLod(reflectionProbes, vec4(sampleVector, sourceIdx), 3).rgb * cos(theta) * sin(theta); + color += textureLod(reflectionProbes, vec4(sampleVector, sourceIdx), mipLevel).rgb * cos(theta) * sin(theta); sampleCount++; } } 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 ef98be881c3f13e7668f75cb0d302261053d9804 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Thu, 1 Sep 2022 17:30:48 -0400 Subject: Use an SRGB buffer for initial reflection map capture for proper linear sampling Fix irradiance gen up vector to be properly normalized --- indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl index 4d91395a1b..4681fa1abd 100644 --- a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl @@ -79,7 +79,7 @@ void main() vec3 N = normalize(vary_dir); vec3 up = vec3(0.0, 1.0, 0.0); vec3 right = normalize(cross(up, N)); - up = cross(N, right); + up = normalize(cross(N, right)); const float TWO_PI = PI * 2.0; const float HALF_PI = PI * 0.5; -- 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') 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') 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/irradianceGenF.glsl | 223 ++++++++++++++++----- .../shaders/class1/interface/radianceGenF.glsl | 17 +- .../shaders/class1/interface/reflectionmipF.glsl | 4 + 3 files changed, 190 insertions(+), 54 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl index 4681fa1abd..63e2fce40f 100644 --- a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl @@ -38,63 +38,190 @@ uniform int sourceIdx; 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/irradiancecube.frag -/* -MIT License -Copyright (c) 2018 Sascha Willems +// Code below is derived from the Khronos GLTF Sample viewer: +// https://github.com/KhronosGroup/glTF-Sample-Viewer/blob/master/source/shaders/ibl_filtering.frag -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. +#define MATH_PI 3.1415926535897932384626433832795 -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. -*/ -// ============================================================================================================= +float u_roughness = 1.0; +int u_sampleCount = 16; +float u_lodBias = 2.0; +int u_width = 64; +// Hammersley Points on the Hemisphere +// CC BY 3.0 (Holger Dammertz) +// http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html +// with adapted interface +float radicalInverse_VdC(uint bits) +{ + bits = (bits << 16u) | (bits >> 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); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 +} + +// hammersley2d describes a sequence of points in the 2d unit square [0,1)^2 +// that can be used for quasi Monte Carlo integration +vec2 hammersley2d(int i, int N) { + return vec2(float(i)/float(N), radicalInverse_VdC(uint(i))); +} + +// Hemisphere Sample + +// TBN generates a tangent bitangent normal coordinate frame from the normal +// (the normal must be normalized) +mat3 generateTBN(vec3 normal) +{ + vec3 bitangent = vec3(0.0, 1.0, 0.0); + + float NdotUp = dot(normal, vec3(0.0, 1.0, 0.0)); + float epsilon = 0.0000001; + /*if (1.0 - abs(NdotUp) <= epsilon) + { + // Sampling +Y or -Y, so we need a more robust bitangent. + if (NdotUp > 0.0) + { + bitangent = vec3(0.0, 0.0, 1.0); + } + else + { + bitangent = vec3(0.0, 0.0, -1.0); + } + }*/ + + vec3 tangent = normalize(cross(bitangent, normal)); + bitangent = cross(normal, tangent); + + return mat3(tangent, bitangent, normal); +} + +struct MicrofacetDistributionSample +{ + float pdf; + float cosTheta; + float sinTheta; + float phi; +}; + +MicrofacetDistributionSample Lambertian(vec2 xi, float roughness) +{ + MicrofacetDistributionSample lambertian; + + // Cosine weighted hemisphere sampling + // http://www.pbr-book.org/3ed-2018/Monte_Carlo_Integration/2D_Sampling_with_Multidimensional_Transformations.html#Cosine-WeightedHemisphereSampling + lambertian.cosTheta = sqrt(1.0 - xi.y); + lambertian.sinTheta = sqrt(xi.y); // equivalent to `sqrt(1.0 - cosTheta*cosTheta)`; + lambertian.phi = 2.0 * MATH_PI * xi.x; + + lambertian.pdf = lambertian.cosTheta / MATH_PI; // evaluation for solid angle, therefore drop the sinTheta + + return lambertian; +} + + +// getImportanceSample returns an importance sample direction with pdf in the .w component +vec4 getImportanceSample(int sampleIndex, vec3 N, float roughness) +{ + // generate a quasi monte carlo point in the unit square [0.1)^2 + vec2 xi = hammersley2d(sampleIndex, u_sampleCount); + + MicrofacetDistributionSample importanceSample; + + // generate the points on the hemisphere with a fitting mapping for + // the distribution (e.g. lambertian uses a cosine importance) + importanceSample = Lambertian(xi, roughness); + + // transform the hemisphere sample to the normal coordinate frame + // i.e. rotate the hemisphere to the normal direction + vec3 localSpaceDirection = normalize(vec3( + importanceSample.sinTheta * cos(importanceSample.phi), + importanceSample.sinTheta * sin(importanceSample.phi), + importanceSample.cosTheta + )); + mat3 TBN = generateTBN(N); + vec3 direction = TBN * localSpaceDirection; + + return vec4(direction, importanceSample.pdf); +} + +// Mipmap Filtered Samples (GPU Gems 3, 20.4) +// https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-20-gpu-based-importance-sampling +// https://cgg.mff.cuni.cz/~jaroslav/papers/2007-sketch-fis/Final_sap_0073.pdf +float computeLod(float pdf) +{ + // // Solid angle of current sample -- bigger for less likely samples + // float omegaS = 1.0 / (float(u_sampleCount) * pdf); + // // Solid angle of texel + // // note: the factor of 4.0 * MATH_PI + // float omegaP = 4.0 * MATH_PI / (6.0 * float(u_width) * float(u_width)); + // // Mip level is determined by the ratio of our sample's solid angle to a texel's solid angle + // // note that 0.5 * log2 is equivalent to log4 + // float lod = 0.5 * log2(omegaS / omegaP); + + // babylon introduces a factor of K (=4) to the solid angle ratio + // this helps to avoid undersampling the environment map + // this does not appear in the original formulation by Jaroslav Krivanek and Mark Colbert + // log4(4) == 1 + // lod += 1.0; + + // We achieved good results by using the original formulation from Krivanek & Colbert adapted to cubemaps + // https://cgg.mff.cuni.cz/~jaroslav/papers/2007-sketch-fis/Final_sap_0073.pdf + float lod = 0.5 * log2( 6.0 * float(u_width) * float(u_width) / (float(u_sampleCount) * pdf)); + + + return lod; +} + +vec3 filterColor(vec3 N) +{ + //return textureLod(uCubeMap, N, 3.0).rgb; + vec3 color = vec3(0.f); + float weight = 0.0f; -#define PI 3.1415926535897932384626433832795 + for(int i = 0; i < u_sampleCount; ++i) + { + vec4 importanceSample = getImportanceSample(i, N, 1.0); + vec3 H = vec3(importanceSample.xyz); + float pdf = importanceSample.w; + + // mipmap filtered samples (GPU Gems 3, 20.4) + float lod = computeLod(pdf); + + // apply the bias to the lod + lod += u_lodBias; + + lod = clamp(lod, 0, 7); + // sample lambertian at a lower resolution to avoid fireflies + vec3 lambertian = textureLod(reflectionProbes, vec4(H, sourceIdx), lod).rgb; + + color += lambertian; + } + + if(weight != 0.0f) + { + color /= weight; + } + else + { + color /= float(u_sampleCount); + } + + return color.rgb ; +} + +// entry point void main() { - float deltaPhi = (2.0 * PI) / 11.25; - float deltaTheta = (0.5 * PI) / 4.0; - float mipLevel = 2; - - vec3 N = normalize(vary_dir); - vec3 up = vec3(0.0, 1.0, 0.0); - vec3 right = normalize(cross(up, N)); - up = normalize(cross(N, right)); - - const float TWO_PI = PI * 2.0; - const float HALF_PI = PI * 0.5; - - vec3 color = vec3(0.0); - uint sampleCount = 0u; - for (float phi = 0.0; phi < TWO_PI; phi += deltaPhi) { - for (float theta = 0.0; theta < HALF_PI; theta += deltaTheta) { - vec3 tempVec = cos(phi) * right + sin(phi) * up; - vec3 sampleVector = cos(theta) * N + sin(theta) * tempVec; - color += textureLod(reflectionProbes, vec4(sampleVector, sourceIdx), mipLevel).rgb * cos(theta) * sin(theta); - sampleCount++; - } - } - frag_color = vec4(PI * color / float(sampleCount), 1.0); + vec3 color = vec3(0); + + color = filterColor(vary_dir); + + frag_color = vec4(color,1.0); } -// ============================================================================================================= 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); } // ============================================================================================================= diff --git a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl index ea687aab4f..e8452a9c14 100644 --- a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl @@ -39,6 +39,7 @@ VARYING vec2 vary_texcoord0; void main() { +#if 0 float w[9]; float c = 1.0/16.0; //corner weight @@ -72,4 +73,7 @@ void main() //color /= wsum; frag_color = vec4(color, 1.0); +#else + frag_color = vec4(texture2DRect(screenMap, vary_texcoord0.xy).rgb, 1.0); +#endif } -- 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') 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. --- .../shaders/class1/interface/irradianceGenF.glsl | 12 +++++----- .../shaders/class1/interface/radianceGenF.glsl | 12 ++++------ .../shaders/class1/interface/reflectionmipF.glsl | 26 ++++++++++++++++++++-- 3 files changed, 34 insertions(+), 16 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl index 63e2fce40f..b633813819 100644 --- a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl @@ -177,10 +177,10 @@ float computeLod(float pdf) return lod; } -vec3 filterColor(vec3 N) +vec4 filterColor(vec3 N) { //return textureLod(uCubeMap, N, 3.0).rgb; - vec3 color = vec3(0.f); + vec4 color = vec4(0.f); float weight = 0.0f; for(int i = 0; i < u_sampleCount; ++i) @@ -198,7 +198,7 @@ vec3 filterColor(vec3 N) lod = clamp(lod, 0, 7); // sample lambertian at a lower resolution to avoid fireflies - vec3 lambertian = textureLod(reflectionProbes, vec4(H, sourceIdx), lod).rgb; + vec4 lambertian = textureLod(reflectionProbes, vec4(H, sourceIdx), lod); color += lambertian; } @@ -212,16 +212,16 @@ vec3 filterColor(vec3 N) color /= float(u_sampleCount); } - return color.rgb ; + return color; } // entry point void main() { - vec3 color = vec3(0); + vec4 color = vec4(0); color = filterColor(vary_dir); - frag_color = vec4(color,1.0); + frag_color = color; } 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); } // ============================================================================================================= diff --git a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl index e8452a9c14..9dd97a80b2 100644 --- a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl @@ -33,10 +33,20 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -uniform sampler2DRect screenMap; +// NOTE screenMap should always be texture channel 0 and +// depthmap should always be channel 1 +uniform sampler2DRect diffuseRect; +uniform sampler2DRect depthMap; + +uniform float resScale; +uniform float znear; +uniform float zfar; VARYING vec2 vary_texcoord0; +// get linear depth value given a depth buffer sample d and znear and zfar values +float linearDepth(float d, float znear, float zfar); + void main() { #if 0 @@ -74,6 +84,18 @@ void main() frag_color = vec4(color, 1.0); #else - frag_color = vec4(texture2DRect(screenMap, vary_texcoord0.xy).rgb, 1.0); + vec2 depth_tc = vary_texcoord0.xy * resScale; + float depth = texture(depthMap, depth_tc).r; + float dist = linearDepth(depth, znear, zfar); + + // convert linear depth to distance + vec3 v; + v.xy = depth_tc / 512.0 * 2.0 - 1.0; + v.z = 1.0; + v = normalize(v); + dist /= v.z; + + vec3 col = texture2DRect(diffuseRect, vary_texcoord0.xy).rgb; + frag_color = vec4(col, dist/256.0); #endif } -- cgit v1.2.3 From 26f99409d247a0c872239d73ac05451ef8531ff4 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 7 Oct 2022 12:52:43 -0500 Subject: SL-18190 Temporarily disable occlusion culling by default -- not compatible with depth buffer management changes. --- .../app_settings/shaders/class1/interface/occlusionF.glsl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl b/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl index db130e456c..f5d2804c7f 100644 --- a/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl @@ -23,13 +23,13 @@ * $/LicenseInfo$ */ -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif +out vec4 frag_data[4]; void main() { - frag_color = vec4(1,1,1,1); + // emissive red PBR material for debugging + frag_data[0] = vec4(0, 0, 0, 0); + frag_data[1] = vec4(0, 0, 0, 0); + frag_data[2] = vec4(1, 0, 0, GBUFFER_FLAG_HAS_PBR); + frag_data[3] = vec4(1, 0, 0, 0); } -- 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. --- .../newview/app_settings/shaders/class1/interface/irradianceGenF.glsl | 2 +- indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl index b633813819..feaf562686 100644 --- a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl @@ -196,7 +196,7 @@ vec4 filterColor(vec3 N) // apply the bias to the lod lod += u_lodBias; - lod = clamp(lod, 0, 7); + lod = clamp(lod, 0, 6); // sample lambertian at a lower resolution to avoid fireflies vec4 lambertian = textureLod(reflectionProbes, vec4(H, sourceIdx), lod); 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 --- .../class1/interface/downsampleDepthRectF.glsl | 20 ++++++++++---------- .../shaders/class1/interface/downsampleDepthV.glsl | 2 +- .../shaders/class1/interface/glowcombineF.glsl | 4 ++-- .../shaders/class1/interface/glowcombineFXAAF.glsl | 4 ++-- .../shaders/class1/interface/glowcombineFXAAV.glsl | 3 +-- .../shaders/class1/interface/glowcombineV.glsl | 2 +- .../shaders/class1/interface/radianceGenF.glsl | 3 ++- .../shaders/class1/interface/reflectionmipF.glsl | 15 +++++++-------- .../shaders/class1/interface/splattexturerectF.glsl | 4 ++-- 9 files changed, 28 insertions(+), 29 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl index cff8d9d50f..99662097bb 100644 --- a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl @@ -33,7 +33,7 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -uniform sampler2DRect depthMap; +uniform sampler2D depthMap; VARYING vec2 tc0; VARYING vec2 tc1; @@ -48,22 +48,22 @@ VARYING vec2 tc8; void main() { vec4 depth1 = - vec4(texture2DRect(depthMap, tc0).r, - texture2DRect(depthMap, tc1).r, - texture2DRect(depthMap, tc2).r, - texture2DRect(depthMap, tc3).r); + vec4(texture2D(depthMap, tc0).r, + texture2D(depthMap, tc1).r, + texture2D(depthMap, tc2).r, + texture2D(depthMap, tc3).r); vec4 depth2 = - vec4(texture2DRect(depthMap, tc4).r, - texture2DRect(depthMap, tc5).r, - texture2DRect(depthMap, tc6).r, - texture2DRect(depthMap, tc7).r); + vec4(texture2D(depthMap, tc4).r, + texture2D(depthMap, tc5).r, + texture2D(depthMap, tc6).r, + texture2D(depthMap, tc7).r); depth1 = min(depth1, depth2); float depth = min(depth1.x, depth1.y); depth = min(depth, depth1.z); depth = min(depth, depth1.w); - depth = min(depth, texture2DRect(depthMap, tc8).r); + depth = min(depth, texture2D(depthMap, tc8).r); gl_FragDepth = depth; } diff --git a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthV.glsl b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthV.glsl index 71d80911d6..e104377037 100644 --- a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthV.glsl @@ -45,7 +45,7 @@ void main() { gl_Position = vec4(position, 1.0); - vec2 tc = (position.xy*0.5+0.5)*screen_res; + vec2 tc = (position.xy*0.5+0.5); tc0 = tc+vec2(-delta.x,-delta.y); tc1 = tc+vec2(0,-delta.y); tc2 = tc+vec2(delta.x,-delta.y); diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl index b5bbbb5c73..0b4680767a 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl @@ -34,7 +34,7 @@ out vec4 frag_color; #endif uniform sampler2D glowMap; -uniform sampler2DRect screenMap; +uniform sampler2D screenMap; VARYING vec2 vary_texcoord0; VARYING vec2 vary_texcoord1; @@ -42,5 +42,5 @@ VARYING vec2 vary_texcoord1; void main() { frag_color = texture2D(glowMap, vary_texcoord0.xy) + - texture2DRect(screenMap, vary_texcoord1.xy); + texture2D(screenMap, vary_texcoord1.xy); } diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl index a9e7ea1de8..6a4c2ca623 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl @@ -33,14 +33,14 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -uniform sampler2DRect diffuseRect; +uniform sampler2D diffuseRect; uniform vec2 screen_res; VARYING vec2 vary_tc; void main() { - vec3 col = texture2DRect(diffuseRect, vary_tc*screen_res).rgb; + vec3 col = texture2D(diffuseRect, vary_tc).rgb; frag_color = vec4(col.rgb, dot(col.rgb, vec3(0.299, 0.587, 0.144))); } diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl index 058f3b1b82..48aab1ce21 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl @@ -23,7 +23,6 @@ * $/LicenseInfo$ */ -uniform mat4 modelview_projection_matrix; ATTRIBUTE vec3 position; @@ -31,7 +30,7 @@ VARYING vec2 vary_tc; void main() { - vec4 pos = modelview_projection_matrix*vec4(position.xyz, 1.0); + vec4 pos = vec4(position.xyz, 1.0); gl_Position = pos; vary_tc = pos.xy*0.5+0.5; diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl index f7970b7f78..e08284f762 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl @@ -34,7 +34,7 @@ VARYING vec2 vary_texcoord1; void main() { - gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + gl_Position = vec4(position.xyz, 1.0); vary_texcoord0 = texcoord0; vary_texcoord1 = texcoord1; } 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; diff --git a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl index f0d579f85e..a9c28b2974 100644 --- a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl @@ -35,8 +35,8 @@ out vec4 frag_color; // NOTE screenMap should always be texture channel 0 and // depthmap should always be channel 1 -uniform sampler2DRect diffuseRect; -uniform sampler2DRect depthMap; +uniform sampler2D diffuseRect; +uniform sampler2D depthMap; uniform float resScale; uniform float znear; @@ -76,26 +76,25 @@ void main() for (int i = 0; i < 9; ++i) { - color += texture2DRect(screenMap, vary_texcoord0.xy+tc[i]).rgb * w[i]; - //color += texture2DRect(screenMap, vary_texcoord0.xy+tc[i]*2.0).rgb * w[i]*0.5; + color += texture2D(screenMap, vary_texcoord0.xy+tc[i]).rgb * w[i]; + //color += texture2D(screenMap, vary_texcoord0.xy+tc[i]*2.0).rgb * w[i]*0.5; } //color /= wsum; frag_color = vec4(color, 1.0); #else - vec2 depth_tc = vary_texcoord0.xy * resScale; - float depth = texture(depthMap, depth_tc).r; + float depth = texture(depthMap, vary_texcoord0.xy).r; float dist = linearDepth(depth, znear, zfar); // convert linear depth to distance vec3 v; - v.xy = depth_tc / 256.0 * 2.0 - 1.0; + v.xy = vary_texcoord0.xy / 512.0 * 2.0 - 1.0; v.z = 1.0; v = normalize(v); dist /= v.z; - vec3 col = texture2DRect(diffuseRect, vary_texcoord0.xy).rgb; + vec3 col = texture2D(diffuseRect, vary_texcoord0.xy).rgb; frag_color = vec4(col, dist/256.0); #endif } diff --git a/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl b/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl index 7614075cfd..bf6c1b355c 100644 --- a/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl @@ -33,12 +33,12 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -uniform sampler2DRect screenMap; +uniform sampler2D screenMap; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; void main() { - frag_color = texture2DRect(screenMap, vary_texcoord0.xy) * vertex_color; + frag_color = texture2D(screenMap, vary_texcoord0.xy) * vertex_color; } -- cgit v1.2.3 From e6b5481cad3f81f18ff04ff6af86bd7ad5b9c5da Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 14 Dec 2022 11:00:31 -0600 Subject: SL-18782 WIP -- stub for reflection probe display. --- .../shaders/class1/interface/reflectionprobeF.glsl | 32 ++++++++++++++++++++ .../shaders/class1/interface/reflectionprobeV.glsl | 34 ++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 indra/newview/app_settings/shaders/class1/interface/reflectionprobeF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/interface/reflectionprobeV.glsl (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/reflectionprobeF.glsl b/indra/newview/app_settings/shaders/class1/interface/reflectionprobeF.glsl new file mode 100644 index 0000000000..e2e0a2002b --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/reflectionprobeF.glsl @@ -0,0 +1,32 @@ +/** + * @file reflectionprobeF.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$ + */ + +// debug stub +out vec4 frag_color; + +void main() +{ + frag_color = vec4(0,1,0,0.5); +} diff --git a/indra/newview/app_settings/shaders/class1/interface/reflectionprobeV.glsl b/indra/newview/app_settings/shaders/class1/interface/reflectionprobeV.glsl new file mode 100644 index 0000000000..0efbd63944 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/reflectionprobeV.glsl @@ -0,0 +1,34 @@ +/** + * @file reflectionprobeV.glsl + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, 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$ + */ + + // Debug stub + +ATTRIBUTE vec3 position; + +void main() +{ + gl_Position = vec4(position, 1.0); +} + -- cgit v1.2.3 From 003e34190f314cd159f8ec227ef32c2400e90f48 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Mon, 2 Jan 2023 05:38:29 -0800 Subject: Refactor post processing a smidge Fixes SL-18484. --- indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl index e08284f762..71fa095505 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl @@ -35,7 +35,7 @@ VARYING vec2 vary_texcoord1; void main() { gl_Position = vec4(position.xyz, 1.0); - vary_texcoord0 = texcoord0; - vary_texcoord1 = texcoord1; + vary_texcoord0 = position.xy * 0.5 + 0.5; + vary_texcoord1 = vary_texcoord0; } -- cgit v1.2.3 From a2d17d3c1e5a62f10ab3922b6b12f909f1cd4682 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 9 Jan 2023 18:12:54 -0600 Subject: SL-18869 Optimizations -- Decruftify LLRenderTarget, use a shader to copy color/depth instead of glCopyTexSubImage or glBlitFrameBuffer --- .../shaders/class1/interface/copyF.glsl | 40 ++++++++++++++++++++++ .../shaders/class1/interface/copyV.glsl | 34 ++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 indra/newview/app_settings/shaders/class1/interface/copyF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/interface/copyV.glsl (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/copyF.glsl b/indra/newview/app_settings/shaders/class1/interface/copyF.glsl new file mode 100644 index 0000000000..764bace621 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/copyF.glsl @@ -0,0 +1,40 @@ +/** + * @file copyF.glsl + * + * $LicenseInfo:firstyear=2023&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2023, 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$ + */ + +in vec2 tc; + +uniform sampler2D depthMap; +uniform sampler2D diffuseMap; + +out vec4 frag_color; + +void main() +{ + frag_color = texture(diffuseMap, tc); +#if COPY_DEPTH + gl_FragDepth = texture(depthMap, tc).r; +#endif +} + diff --git a/indra/newview/app_settings/shaders/class1/interface/copyV.glsl b/indra/newview/app_settings/shaders/class1/interface/copyV.glsl new file mode 100644 index 0000000000..ace5da6578 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/copyV.glsl @@ -0,0 +1,34 @@ +/** + * @file copyV.glsl + * + * $LicenseInfo:firstyear=2023&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2023, 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$ + */ + + +in vec3 position; +out vec2 tc; + +void main() +{ + tc = position.xy * 0.5 + 0.5; + gl_Position = vec4(position, 1.0); +} -- cgit v1.2.3 From c6ea8f9c825e823c4f1130d3448eb83a02b8af87 Mon Sep 17 00:00:00 2001 From: Brad Linden Date: Tue, 10 Jan 2023 15:10:25 -0800 Subject: Fix shader syntax error on mac for DRTVWR-559 --- indra/newview/app_settings/shaders/class1/interface/copyF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/copyF.glsl b/indra/newview/app_settings/shaders/class1/interface/copyF.glsl index 764bace621..65d3c20091 100644 --- a/indra/newview/app_settings/shaders/class1/interface/copyF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/copyF.glsl @@ -33,7 +33,7 @@ out vec4 frag_color; void main() { frag_color = texture(diffuseMap, tc); -#if COPY_DEPTH +#if defined(COPY_DEPTH) gl_FragDepth = texture(depthMap, tc).r; #endif } -- cgit v1.2.3 From c2fef4b58838a617650dd40755518dd22558b42b Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 20 Jan 2023 15:48:06 -0600 Subject: SL-19015 Boost brightness of irradiance maps. --- indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl index feaf562686..3e056aa048 100644 --- a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl @@ -212,7 +212,7 @@ vec4 filterColor(vec3 N) color /= float(u_sampleCount); } - return color; + return min(color*1.9, vec4(1)); } // entry point -- 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. --- .../shaders/class1/interface/irradianceGenF.glsl | 198 +-------------------- .../shaders/class1/interface/radianceGenF.glsl | 4 +- 2 files changed, 5 insertions(+), 197 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl index 3e056aa048..2b1e794b52 100644 --- a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl @@ -23,205 +23,11 @@ * $/LicenseInfo$ */ +// debug stub -/*[EXTRA_CODE_HERE]*/ - - -#ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform samplerCubeArray reflectionProbes; -uniform int sourceIdx; - -VARYING vec3 vary_dir; - - -// Code below is derived from the Khronos GLTF Sample viewer: -// https://github.com/KhronosGroup/glTF-Sample-Viewer/blob/master/source/shaders/ibl_filtering.frag - - -#define MATH_PI 3.1415926535897932384626433832795 - -float u_roughness = 1.0; -int u_sampleCount = 16; -float u_lodBias = 2.0; -int u_width = 64; - -// Hammersley Points on the Hemisphere -// CC BY 3.0 (Holger Dammertz) -// http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html -// with adapted interface -float radicalInverse_VdC(uint bits) -{ - bits = (bits << 16u) | (bits >> 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); - return float(bits) * 2.3283064365386963e-10; // / 0x100000000 -} - -// hammersley2d describes a sequence of points in the 2d unit square [0,1)^2 -// that can be used for quasi Monte Carlo integration -vec2 hammersley2d(int i, int N) { - return vec2(float(i)/float(N), radicalInverse_VdC(uint(i))); -} - -// Hemisphere Sample - -// TBN generates a tangent bitangent normal coordinate frame from the normal -// (the normal must be normalized) -mat3 generateTBN(vec3 normal) -{ - vec3 bitangent = vec3(0.0, 1.0, 0.0); - - float NdotUp = dot(normal, vec3(0.0, 1.0, 0.0)); - float epsilon = 0.0000001; - /*if (1.0 - abs(NdotUp) <= epsilon) - { - // Sampling +Y or -Y, so we need a more robust bitangent. - if (NdotUp > 0.0) - { - bitangent = vec3(0.0, 0.0, 1.0); - } - else - { - bitangent = vec3(0.0, 0.0, -1.0); - } - }*/ - - vec3 tangent = normalize(cross(bitangent, normal)); - bitangent = cross(normal, tangent); - - return mat3(tangent, bitangent, normal); -} - -struct MicrofacetDistributionSample -{ - float pdf; - float cosTheta; - float sinTheta; - float phi; -}; - -MicrofacetDistributionSample Lambertian(vec2 xi, float roughness) -{ - MicrofacetDistributionSample lambertian; - - // Cosine weighted hemisphere sampling - // http://www.pbr-book.org/3ed-2018/Monte_Carlo_Integration/2D_Sampling_with_Multidimensional_Transformations.html#Cosine-WeightedHemisphereSampling - lambertian.cosTheta = sqrt(1.0 - xi.y); - lambertian.sinTheta = sqrt(xi.y); // equivalent to `sqrt(1.0 - cosTheta*cosTheta)`; - lambertian.phi = 2.0 * MATH_PI * xi.x; - - lambertian.pdf = lambertian.cosTheta / MATH_PI; // evaluation for solid angle, therefore drop the sinTheta - - return lambertian; -} - -// getImportanceSample returns an importance sample direction with pdf in the .w component -vec4 getImportanceSample(int sampleIndex, vec3 N, float roughness) -{ - // generate a quasi monte carlo point in the unit square [0.1)^2 - vec2 xi = hammersley2d(sampleIndex, u_sampleCount); - - MicrofacetDistributionSample importanceSample; - - // generate the points on the hemisphere with a fitting mapping for - // the distribution (e.g. lambertian uses a cosine importance) - importanceSample = Lambertian(xi, roughness); - - // transform the hemisphere sample to the normal coordinate frame - // i.e. rotate the hemisphere to the normal direction - vec3 localSpaceDirection = normalize(vec3( - importanceSample.sinTheta * cos(importanceSample.phi), - importanceSample.sinTheta * sin(importanceSample.phi), - importanceSample.cosTheta - )); - mat3 TBN = generateTBN(N); - vec3 direction = TBN * localSpaceDirection; - - return vec4(direction, importanceSample.pdf); -} - -// Mipmap Filtered Samples (GPU Gems 3, 20.4) -// https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-20-gpu-based-importance-sampling -// https://cgg.mff.cuni.cz/~jaroslav/papers/2007-sketch-fis/Final_sap_0073.pdf -float computeLod(float pdf) -{ - // // Solid angle of current sample -- bigger for less likely samples - // float omegaS = 1.0 / (float(u_sampleCount) * pdf); - // // Solid angle of texel - // // note: the factor of 4.0 * MATH_PI - // float omegaP = 4.0 * MATH_PI / (6.0 * float(u_width) * float(u_width)); - // // Mip level is determined by the ratio of our sample's solid angle to a texel's solid angle - // // note that 0.5 * log2 is equivalent to log4 - // float lod = 0.5 * log2(omegaS / omegaP); - - // babylon introduces a factor of K (=4) to the solid angle ratio - // this helps to avoid undersampling the environment map - // this does not appear in the original formulation by Jaroslav Krivanek and Mark Colbert - // log4(4) == 1 - // lod += 1.0; - - // We achieved good results by using the original formulation from Krivanek & Colbert adapted to cubemaps - - // https://cgg.mff.cuni.cz/~jaroslav/papers/2007-sketch-fis/Final_sap_0073.pdf - float lod = 0.5 * log2( 6.0 * float(u_width) * float(u_width) / (float(u_sampleCount) * pdf)); - - - return lod; -} - -vec4 filterColor(vec3 N) -{ - //return textureLod(uCubeMap, N, 3.0).rgb; - vec4 color = vec4(0.f); - float weight = 0.0f; - - for(int i = 0; i < u_sampleCount; ++i) - { - vec4 importanceSample = getImportanceSample(i, N, 1.0); - - vec3 H = vec3(importanceSample.xyz); - float pdf = importanceSample.w; - - // mipmap filtered samples (GPU Gems 3, 20.4) - float lod = computeLod(pdf); - - // apply the bias to the lod - lod += u_lodBias; - - lod = clamp(lod, 0, 6); - // sample lambertian at a lower resolution to avoid fireflies - vec4 lambertian = textureLod(reflectionProbes, vec4(H, sourceIdx), lod); - - color += lambertian; - } - - if(weight != 0.0f) - { - color /= weight; - } - else - { - color /= float(u_sampleCount); - } - - return min(color*1.9, vec4(1)); -} - -// entry point void main() { - vec4 color = vec4(0); - - color = filterColor(vary_dir); - - frag_color = color; + frag_color = vec4(0.5, 0, 0.5, 0); } - 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 6f136d403b6bbccae80661c6585f29e1caed3a7c Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 1 Feb 2023 17:09:34 -0600 Subject: SL-19000 Fix various 3D UI components not respecting depth buffer. Incidental decruft. Do I get a prize for 1000th jira? --- .../shaders/class1/interface/glowcombineF.glsl | 18 ++++++++---------- .../shaders/class1/interface/glowcombineFXAAF.glsl | 13 +++++-------- .../shaders/class1/interface/glowcombineV.glsl | 12 ++++-------- 3 files changed, 17 insertions(+), 26 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl index 0b4680767a..3ead2149f5 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl @@ -27,20 +27,18 @@ /*[EXTRA_CODE_HERE]*/ -#ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif -uniform sampler2D glowMap; -uniform sampler2D screenMap; +uniform sampler2D emissiveRect; +uniform sampler2D diffuseRect; +uniform sampler2D depthMap; -VARYING vec2 vary_texcoord0; -VARYING vec2 vary_texcoord1; +in vec2 tc; void main() { - frag_color = texture2D(glowMap, vary_texcoord0.xy) + - texture2D(screenMap, vary_texcoord1.xy); + frag_color = texture2D(emissiveRect, tc) + + texture2D(diffuseRect, tc); + + gl_FragDepth = texture(depthMap, tc).r; } diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl index 6a4c2ca623..c50548d528 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl @@ -27,20 +27,17 @@ /*[EXTRA_CODE_HERE]*/ -#ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif uniform sampler2D diffuseRect; uniform vec2 screen_res; -VARYING vec2 vary_tc; + +in vec2 vary_tc; void main() { - vec3 col = texture2D(diffuseRect, vary_tc).rgb; - - frag_color = vec4(col.rgb, dot(col.rgb, vec3(0.299, 0.587, 0.144))); + vec3 col = texture(diffuseRect, vary_tc).rgb; + + frag_color = vec4(col.rgb, dot(col.rgb, vec3(0.299, 0.587, 0.144))); } diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl index 71fa095505..8fa08a18c3 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl @@ -25,17 +25,13 @@ uniform mat4 modelview_projection_matrix; -ATTRIBUTE vec3 position; -ATTRIBUTE vec2 texcoord0; -ATTRIBUTE vec2 texcoord1; +in vec3 position; -VARYING vec2 vary_texcoord0; -VARYING vec2 vary_texcoord1; +out vec2 tc; void main() { - gl_Position = vec4(position.xyz, 1.0); - vary_texcoord0 = position.xy * 0.5 + 0.5; - vary_texcoord1 = vary_texcoord0; + gl_Position = vec4(position.xyz, 1.0); + tc = position.xy * 0.5 + 0.5; } -- cgit v1.2.3 From 1c2410b8af62254e96d60b2ae2e411d4756215e4 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 3 Feb 2023 19:45:31 -0600 Subject: SL-19148 Decruft followthrough -- decruft shader tree and some remaining forward rendering code. --- .../shaders/class1/interface/irradianceGenF.glsl | 33 --------------------- .../shaders/class1/interface/reflectionprobeF.glsl | 32 -------------------- .../shaders/class1/interface/reflectionprobeV.glsl | 34 ---------------------- 3 files changed, 99 deletions(-) delete mode 100644 indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/interface/reflectionprobeF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/interface/reflectionprobeV.glsl (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl deleted file mode 100644 index 2b1e794b52..0000000000 --- a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file irradianceGenF.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$ - */ - -// debug stub - -out vec4 frag_color; - -void main() -{ - frag_color = vec4(0.5, 0, 0.5, 0); -} diff --git a/indra/newview/app_settings/shaders/class1/interface/reflectionprobeF.glsl b/indra/newview/app_settings/shaders/class1/interface/reflectionprobeF.glsl deleted file mode 100644 index e2e0a2002b..0000000000 --- a/indra/newview/app_settings/shaders/class1/interface/reflectionprobeF.glsl +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @file reflectionprobeF.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$ - */ - -// debug stub -out vec4 frag_color; - -void main() -{ - frag_color = vec4(0,1,0,0.5); -} diff --git a/indra/newview/app_settings/shaders/class1/interface/reflectionprobeV.glsl b/indra/newview/app_settings/shaders/class1/interface/reflectionprobeV.glsl deleted file mode 100644 index 0efbd63944..0000000000 --- a/indra/newview/app_settings/shaders/class1/interface/reflectionprobeV.glsl +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file reflectionprobeV.glsl - * - * $LicenseInfo:firstyear=2022&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, 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$ - */ - - // Debug stub - -ATTRIBUTE vec3 position; - -void main() -{ - gl_Position = vec4(position, 1.0); -} - -- cgit v1.2.3 From 4ea51c6ce4b29c0b3875e32f0daf86390cec8950 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 3 Feb 2023 19:53:43 -0600 Subject: SL-19148 Decruft followthrough -- kill more unused shader files --- .../shaders/class1/interface/customalphaF.glsl | 46 --------------- .../shaders/class1/interface/customalphaV.glsl | 41 ------------- .../shaders/class1/interface/downsampleDepthF.glsl | 65 -------------------- .../class1/interface/downsampleDepthRectF.glsl | 69 ---------------------- .../shaders/class1/interface/downsampleDepthV.glsl | 59 ------------------ .../class1/interface/onetexturenocolorF.glsl | 39 ------------ .../class1/interface/onetexturenocolorV.glsl | 38 ------------ .../class1/interface/splattexturerectF.glsl | 44 -------------- .../shaders/class1/interface/twotextureaddF.glsl | 41 ------------- .../shaders/class1/interface/twotextureaddV.glsl | 41 ------------- 10 files changed, 483 deletions(-) delete mode 100644 indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/interface/customalphaV.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/interface/downsampleDepthF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/interface/downsampleDepthV.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/interface/onetexturenocolorF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/interface/onetexturenocolorV.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/interface/twotextureaddV.glsl (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl b/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl deleted file mode 100644 index f6b31a5956..0000000000 --- a/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @file customalphaF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2D diffuseMap; - -uniform float custom_alpha; - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -void main() -{ - vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); - color.rgb = pow(color.rgb, vec3(0.45)); - color.rgb *= vertex_color.rgb; - color.a *= max(custom_alpha, vertex_color.a); - frag_color = color; -} diff --git a/indra/newview/app_settings/shaders/class1/interface/customalphaV.glsl b/indra/newview/app_settings/shaders/class1/interface/customalphaV.glsl deleted file mode 100644 index 890474d6d8..0000000000 --- a/indra/newview/app_settings/shaders/class1/interface/customalphaV.glsl +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @file customalphaV.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -uniform mat4 modelview_projection_matrix; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec4 diffuse_color; -ATTRIBUTE vec2 texcoord0; - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -void main() -{ - gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); - vary_texcoord0 = texcoord0; - vertex_color = diffuse_color; -} - diff --git a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthF.glsl b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthF.glsl deleted file mode 100644 index f8efd7cb4a..0000000000 --- a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthF.glsl +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @file debugF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, 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$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2D depthMap; - -VARYING vec2 tc0; -VARYING vec2 tc1; -VARYING vec2 tc2; -VARYING vec2 tc3; -VARYING vec2 tc4; -VARYING vec2 tc5; -VARYING vec2 tc6; -VARYING vec2 tc7; -VARYING vec2 tc8; - -void main() -{ - vec4 depth1 = - vec4(texture2D(depthMap, tc0).r, - texture2D(depthMap, tc1).r, - texture2D(depthMap, tc2).r, - texture2D(depthMap, tc3).r); - - vec4 depth2 = - vec4(texture2D(depthMap, tc4).r, - texture2D(depthMap, tc5).r, - texture2D(depthMap, tc6).r, - texture2D(depthMap, tc7).r); - - depth1 = min(depth1, depth2); - float depth = min(depth1.x, depth1.y); - depth = min(depth, depth1.z); - depth = min(depth, depth1.w); - depth = min(depth, texture2D(depthMap, tc8).r); - - gl_FragDepth = depth; -} diff --git a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl deleted file mode 100644 index 99662097bb..0000000000 --- a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @file debugF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, 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$ - */ - -#extension GL_ARB_texture_rectangle : enable - -/*[EXTRA_CODE_HERE]*/ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2D depthMap; - -VARYING vec2 tc0; -VARYING vec2 tc1; -VARYING vec2 tc2; -VARYING vec2 tc3; -VARYING vec2 tc4; -VARYING vec2 tc5; -VARYING vec2 tc6; -VARYING vec2 tc7; -VARYING vec2 tc8; - -void main() -{ - vec4 depth1 = - vec4(texture2D(depthMap, tc0).r, - texture2D(depthMap, tc1).r, - texture2D(depthMap, tc2).r, - texture2D(depthMap, tc3).r); - - vec4 depth2 = - vec4(texture2D(depthMap, tc4).r, - texture2D(depthMap, tc5).r, - texture2D(depthMap, tc6).r, - texture2D(depthMap, tc7).r); - - depth1 = min(depth1, depth2); - float depth = min(depth1.x, depth1.y); - depth = min(depth, depth1.z); - depth = min(depth, depth1.w); - depth = min(depth, texture2D(depthMap, tc8).r); - - gl_FragDepth = depth; -} diff --git a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthV.glsl b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthV.glsl deleted file mode 100644 index e104377037..0000000000 --- a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthV.glsl +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @file debugV.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, 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$ - */ - -uniform mat4 modelview_projection_matrix; - -ATTRIBUTE vec3 position; - -uniform vec2 screen_res; - -uniform vec2 delta; - -VARYING vec2 tc0; -VARYING vec2 tc1; -VARYING vec2 tc2; -VARYING vec2 tc3; -VARYING vec2 tc4; -VARYING vec2 tc5; -VARYING vec2 tc6; -VARYING vec2 tc7; -VARYING vec2 tc8; - -void main() -{ - gl_Position = vec4(position, 1.0); - - vec2 tc = (position.xy*0.5+0.5); - tc0 = tc+vec2(-delta.x,-delta.y); - tc1 = tc+vec2(0,-delta.y); - tc2 = tc+vec2(delta.x,-delta.y); - tc3 = tc+vec2(-delta.x,0); - tc4 = tc+vec2(0,0); - tc5 = tc+vec2(delta.x,0); - tc6 = tc+vec2(-delta.x,delta.y); - tc7 = tc+vec2(0,delta.y); - tc8 = tc+vec2(delta.x,delta.y); -} - diff --git a/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorF.glsl b/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorF.glsl deleted file mode 100644 index 415181126b..0000000000 --- a/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorF.glsl +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @file onetexturenocolorF.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, 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$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2D tex0; - -VARYING vec2 vary_texcoord0; - -void main() -{ - frag_color = texture2D(tex0, vary_texcoord0.xy); -} diff --git a/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorV.glsl b/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorV.glsl deleted file mode 100644 index 6b9986c8d7..0000000000 --- a/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorV.glsl +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file onetexturenocolorV.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -uniform mat4 modelview_projection_matrix; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec2 texcoord0; - -VARYING vec2 vary_texcoord0; - -void main() -{ - gl_Position = modelview_projection_matrix * vec4(position, 1); - vary_texcoord0 = texcoord0; -} - diff --git a/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl b/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl deleted file mode 100644 index bf6c1b355c..0000000000 --- a/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @file splattexturerectF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, 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$ - */ - -#extension GL_ARB_texture_rectangle : enable - -/*[EXTRA_CODE_HERE]*/ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2D screenMap; - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -void main() -{ - frag_color = texture2D(screenMap, vary_texcoord0.xy) * vertex_color; -} diff --git a/indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl b/indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl deleted file mode 100644 index 95679e93e7..0000000000 --- a/indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @file twotextureaddF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2D tex0; -uniform sampler2D tex1; - -VARYING vec2 vary_texcoord0; -VARYING vec2 vary_texcoord1; - -void main() -{ - frag_color = texture2D(tex0, vary_texcoord0.xy)+texture2D(tex1, vary_texcoord1.xy); -} diff --git a/indra/newview/app_settings/shaders/class1/interface/twotextureaddV.glsl b/indra/newview/app_settings/shaders/class1/interface/twotextureaddV.glsl deleted file mode 100644 index 3c2f297f7f..0000000000 --- a/indra/newview/app_settings/shaders/class1/interface/twotextureaddV.glsl +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @file twotextureaddV.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$ - */ - -uniform mat4 modelview_projection_matrix; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec2 texcoord0; -ATTRIBUTE vec2 texcoord1; - -VARYING vec2 vary_texcoord0; -VARYING vec2 vary_texcoord1; - -void main() -{ - gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); - vary_texcoord0 = texcoord0; - vary_texcoord1 = texcoord1; -} - -- 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') 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 e5e94b5fa832c62dc0df239fdb4aefc23e559c0c Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 23 Feb 2023 11:47:24 -0600 Subject: DRTVWR-559 Fix for irradiance maps going black at 128x128 radiance map resolution. Improve radiance map anti-aliasing and default to 128x128 everywhere. --- .../shaders/class1/interface/gaussianF.glsl | 53 ++++++++++++++++++++++ .../shaders/class1/interface/reflectionmipF.glsl | 52 ++------------------- .../class1/interface/splattexturerectV.glsl | 11 ++--- 3 files changed, 61 insertions(+), 55 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class1/interface/gaussianF.glsl (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/gaussianF.glsl b/indra/newview/app_settings/shaders/class1/interface/gaussianF.glsl new file mode 100644 index 0000000000..8e341503f5 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/gaussianF.glsl @@ -0,0 +1,53 @@ +/** + * @file gaussianF.glsl + * + * $LicenseInfo:firstyear=2023&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2023, 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$ + */ + +out vec4 frag_color; + +uniform sampler2D diffuseRect; + +uniform float resScale; + +// texture direction, will be <1, 0> or <0, 1> +uniform vec2 direction; + +in vec2 vary_texcoord0; + +// get linear depth value given a depth buffer sample d and znear and zfar values +float linearDepth(float d, float znear, float zfar); + +void main() +{ + vec3 col = vec3(0,0,0); + + float w[] = { 0.0002, 0.0060, 0.0606, 0.2417, 0.3829, 0.2417, 0.0606, 0.0060, 0.0002 }; + + for (int i = 0; i < 9; ++i) + { + vec2 tc = vary_texcoord0 + (i-4)*direction*resScale; + col += texture(diffuseRect, tc).rgb * w[i]; + } + + frag_color = vec4(col, 0.0); +} diff --git a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl index a9c28b2974..9f7706fe36 100644 --- a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl @@ -23,18 +23,8 @@ * $/LicenseInfo$ */ -#extension GL_ARB_texture_rectangle : enable - -/*[EXTRA_CODE_HERE]*/ - -#ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif -// NOTE screenMap should always be texture channel 0 and -// depthmap should always be channel 1 uniform sampler2D diffuseRect; uniform sampler2D depthMap; @@ -42,48 +32,13 @@ uniform float resScale; uniform float znear; uniform float zfar; -VARYING vec2 vary_texcoord0; +in vec2 vary_texcoord0; // get linear depth value given a depth buffer sample d and znear and zfar values float linearDepth(float d, float znear, float zfar); void main() { -#if 0 - float w[9]; - - float c = 1.0/16.0; //corner weight - float e = 1.0/8.0; //edge weight - float m = 1.0/4.0; //middle weight - - //float wsum = c*4+e*4+m; - - w[0] = c; w[1] = e; w[2] = c; - w[3] = e; w[4] = m; w[5] = e; - w[6] = c; w[7] = e; w[8] = c; - - vec2 tc[9]; - - float ed = 1; - float cd = 1; - - - tc[0] = vec2(-cd, cd); tc[1] = vec2(0, ed); tc[2] = vec2(cd, cd); - tc[3] = vec2(-ed, 0); tc[4] = vec2(0, 0); tc[5] = vec2(ed, 0); - tc[6] = vec2(-cd, -cd); tc[7] = vec2(0, -ed); tc[8] = vec2(cd, -1); - - vec3 color = vec3(0,0,0); - - for (int i = 0; i < 9; ++i) - { - color += texture2D(screenMap, vary_texcoord0.xy+tc[i]).rgb * w[i]; - //color += texture2D(screenMap, vary_texcoord0.xy+tc[i]*2.0).rgb * w[i]*0.5; - } - - //color /= wsum; - - frag_color = vec4(color, 1.0); -#else float depth = texture(depthMap, vary_texcoord0.xy).r; float dist = linearDepth(depth, znear, zfar); @@ -94,7 +49,6 @@ void main() v = normalize(v); dist /= v.z; - vec3 col = texture2D(diffuseRect, vary_texcoord0.xy).rgb; - frag_color = vec4(col, dist/256.0); -#endif + vec3 col = texture(diffuseRect, vary_texcoord0.xy).rgb; + frag_color = vec4(col, dist/256.0); } diff --git a/indra/newview/app_settings/shaders/class1/interface/splattexturerectV.glsl b/indra/newview/app_settings/shaders/class1/interface/splattexturerectV.glsl index 641d670c26..edc0a9628b 100644 --- a/indra/newview/app_settings/shaders/class1/interface/splattexturerectV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/splattexturerectV.glsl @@ -25,17 +25,16 @@ uniform mat4 modelview_projection_matrix; -ATTRIBUTE vec3 position; -ATTRIBUTE vec2 texcoord0; -ATTRIBUTE vec4 diffuse_color; +in vec3 position; +in vec4 diffuse_color; -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; +out vec4 vertex_color; +out vec2 vary_texcoord0; void main() { gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); - vary_texcoord0 = texcoord0; + vary_texcoord0 = position.xy*0.5+0.5; vertex_color = diffuse_color; } -- cgit v1.2.3 From 46b2c0660a091f5b3596084a71f63c8145bfac68 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Sat, 25 Feb 2023 22:24:46 -0800 Subject: Hammering on more mac optimizations. SL-18563 --- indra/newview/app_settings/shaders/class1/interface/gaussianF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/gaussianF.glsl b/indra/newview/app_settings/shaders/class1/interface/gaussianF.glsl index 8e341503f5..188fac5460 100644 --- a/indra/newview/app_settings/shaders/class1/interface/gaussianF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/gaussianF.glsl @@ -41,7 +41,7 @@ void main() { vec3 col = vec3(0,0,0); - float w[] = { 0.0002, 0.0060, 0.0606, 0.2417, 0.3829, 0.2417, 0.0606, 0.0060, 0.0002 }; + float w[9] = float[9]( 0.0002, 0.0060, 0.0606, 0.2417, 0.3829, 0.2417, 0.0606, 0.0060, 0.0002 ); for (int i = 0; i < 9; ++i) { -- cgit v1.2.3 From e5a2f85005bbf94f39ef048dbfe43276990f1154 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 27 Feb 2023 16:53:56 -0600 Subject: SL-19226 Reimplement water fresnel offset/scale, exposure balance for midday, adjust reflections off, and decruft depth buffer error correction shenanigans that are no longer used. --- .../shaders/class1/interface/reflectionmipF.glsl | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl index 9f7706fe36..45267e4403 100644 --- a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl @@ -26,29 +26,11 @@ out vec4 frag_color; uniform sampler2D diffuseRect; -uniform sampler2D depthMap; - -uniform float resScale; -uniform float znear; -uniform float zfar; in vec2 vary_texcoord0; -// get linear depth value given a depth buffer sample d and znear and zfar values -float linearDepth(float d, float znear, float zfar); - void main() { - float depth = texture(depthMap, vary_texcoord0.xy).r; - float dist = linearDepth(depth, znear, zfar); - - // convert linear depth to distance - vec3 v; - v.xy = vary_texcoord0.xy / 512.0 * 2.0 - 1.0; - v.z = 1.0; - v = normalize(v); - dist /= v.z; - vec3 col = texture(diffuseRect, vary_texcoord0.xy).rgb; - frag_color = vec4(col, dist/256.0); + frag_color = vec4(col, 0.0); } -- cgit v1.2.3 From 78e7ada94bc48a7e42f96fa2b716e8f9ff8bc580 Mon Sep 17 00:00:00 2001 From: Brad Linden Date: Mon, 27 Feb 2023 16:39:11 -0800 Subject: Mac shader and assertion fixes for DRTVWR-559 --- .../app_settings/shaders/class1/interface/splattexturerectV.glsl | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/splattexturerectV.glsl b/indra/newview/app_settings/shaders/class1/interface/splattexturerectV.glsl index edc0a9628b..7af7f20f85 100644 --- a/indra/newview/app_settings/shaders/class1/interface/splattexturerectV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/splattexturerectV.glsl @@ -26,15 +26,12 @@ uniform mat4 modelview_projection_matrix; in vec3 position; -in vec4 diffuse_color; -out vec4 vertex_color; out vec2 vary_texcoord0; void main() { gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); vary_texcoord0 = position.xy*0.5+0.5; - vertex_color = diffuse_color; } -- cgit v1.2.3 From f3ce17701e8dbbbc7a0e8e73c740b161bb2f36c0 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Mon, 13 Mar 2023 08:05:33 -0700 Subject: Make sure the glow combine only happens in the gamma correct shader. --- indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl index 3ead2149f5..770c436ede 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl @@ -29,7 +29,6 @@ out vec4 frag_color; -uniform sampler2D emissiveRect; uniform sampler2D diffuseRect; uniform sampler2D depthMap; @@ -37,8 +36,7 @@ in vec2 tc; void main() { - frag_color = texture2D(emissiveRect, tc) + - texture2D(diffuseRect, tc); + frag_color = texture2D(diffuseRect, tc); gl_FragDepth = texture(depthMap, tc).r; } -- 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') 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 b44ad50f75724a5d9e53bd52d2724111568caf24 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Fri, 31 Mar 2023 10:54:19 -0700 Subject: Move glow extract to be after tonemapping. SL-19513 --- indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl | 3 ++- .../app_settings/shaders/class1/interface/glowcombineFXAAF.glsl | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl index 770c436ede..3b25a5df16 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl @@ -31,12 +31,13 @@ out vec4 frag_color; uniform sampler2D diffuseRect; uniform sampler2D depthMap; +uniform sampler2D emissiveRect; in vec2 tc; void main() { - frag_color = texture2D(diffuseRect, tc); + frag_color = texture2D(diffuseRect, tc) + texture2D(emissiveRect, tc); gl_FragDepth = texture(depthMap, tc).r; } diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl index c50548d528..6cc83138a2 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl @@ -30,6 +30,7 @@ out vec4 frag_color; uniform sampler2D diffuseRect; +uniform sampler2D emissiveRect; uniform vec2 screen_res; @@ -37,7 +38,7 @@ in vec2 vary_tc; void main() { - vec3 col = texture(diffuseRect, vary_tc).rgb; + vec3 col = texture(diffuseRect, vary_tc).rgb + texture(emissiveRect, vary_tc).rgb; frag_color = vec4(col.rgb, dot(col.rgb, vec3(0.299, 0.587, 0.144))); } -- 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/alphamaskF.glsl | 2 +- indra/newview/app_settings/shaders/class1/interface/clipF.glsl | 2 +- indra/newview/app_settings/shaders/class1/interface/debugF.glsl | 2 +- indra/newview/app_settings/shaders/class1/interface/gaussianF.glsl | 2 +- indra/newview/app_settings/shaders/class1/interface/highlightF.glsl | 2 +- indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl b/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl index f520f301d9..69c1983b4d 100644 --- a/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl @@ -44,5 +44,5 @@ void main() discard; } - frag_color = col; + frag_color = max(col, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/interface/clipF.glsl b/indra/newview/app_settings/shaders/class1/interface/clipF.glsl index ac2bc8703b..9454bbf21e 100644 --- a/indra/newview/app_settings/shaders/class1/interface/clipF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/clipF.glsl @@ -42,5 +42,5 @@ void main() discard; } - frag_color = color; + frag_color = max(color, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/interface/debugF.glsl b/indra/newview/app_settings/shaders/class1/interface/debugF.glsl index 67c6baddbb..cb8d6a8c03 100644 --- a/indra/newview/app_settings/shaders/class1/interface/debugF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/debugF.glsl @@ -33,5 +33,5 @@ uniform vec4 color; void main() { - frag_color = color; + frag_color = max(color, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/interface/gaussianF.glsl b/indra/newview/app_settings/shaders/class1/interface/gaussianF.glsl index 188fac5460..eca591d387 100644 --- a/indra/newview/app_settings/shaders/class1/interface/gaussianF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/gaussianF.glsl @@ -49,5 +49,5 @@ void main() col += texture(diffuseRect, tc).rgb * w[i]; } - frag_color = vec4(col, 0.0); + frag_color = max(vec4(col, 0.0), vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl index 6cc9bbbea2..58c9e5ad0a 100644 --- a/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl @@ -36,5 +36,5 @@ VARYING vec2 vary_texcoord0; void main() { - frag_color = color*texture2D(diffuseMap, vary_texcoord0.xy); + frag_color = max(color*texture2D(diffuseMap, vary_texcoord0.xy), vec4(0)); } 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 5bfae438fda23d287898238ad7cbedafd81fb33a Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Sat, 8 Apr 2023 20:18:15 -0700 Subject: Start scrapping screenTarget(). Makes our binding flow _far more_ predictable and makes way more sense. DRTVWR-559 SL-19524 SL-19513 --- .../app_settings/shaders/class1/interface/glowcombineFXAAF.glsl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl index 6cc83138a2..c50548d528 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl @@ -30,7 +30,6 @@ out vec4 frag_color; uniform sampler2D diffuseRect; -uniform sampler2D emissiveRect; uniform vec2 screen_res; @@ -38,7 +37,7 @@ in vec2 vary_tc; void main() { - vec3 col = texture(diffuseRect, vary_tc).rgb + texture(emissiveRect, vary_tc).rgb; + vec3 col = texture(diffuseRect, vary_tc).rgb; frag_color = vec4(col.rgb, dot(col.rgb, vec3(0.299, 0.587, 0.144))); } -- cgit v1.2.3 From 23365ca51aef2447efa07b0097a421ff864feec1 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Wed, 12 Apr 2023 16:58:15 -0700 Subject: Fix for nameplates, HUD text generally. DRTVWR-559 SL-19524 SL-19513 --- indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl index 3b25a5df16..e578bb6fc5 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl @@ -30,7 +30,6 @@ out vec4 frag_color; uniform sampler2D diffuseRect; -uniform sampler2D depthMap; uniform sampler2D emissiveRect; in vec2 tc; @@ -38,6 +37,4 @@ in vec2 tc; void main() { frag_color = texture2D(diffuseRect, tc) + texture2D(emissiveRect, tc); - - gl_FragDepth = texture(depthMap, tc).r; } -- 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. --- .../app_settings/shaders/class1/interface/alphamaskF.glsl | 10 +++------- .../app_settings/shaders/class1/interface/alphamaskV.glsl | 10 +++++----- .../app_settings/shaders/class1/interface/benchmarkF.glsl | 8 ++------ .../app_settings/shaders/class1/interface/benchmarkV.glsl | 4 ++-- indra/newview/app_settings/shaders/class1/interface/clipF.glsl | 6 +----- indra/newview/app_settings/shaders/class1/interface/clipV.glsl | 4 ++-- .../newview/app_settings/shaders/class1/interface/debugF.glsl | 4 ---- .../newview/app_settings/shaders/class1/interface/debugV.glsl | 2 +- .../app_settings/shaders/class1/interface/glowcombineF.glsl | 4 +--- .../shaders/class1/interface/glowcombineFXAAF.glsl | 2 -- .../shaders/class1/interface/glowcombineFXAAV.glsl | 4 ++-- .../app_settings/shaders/class1/interface/highlightF.glsl | 8 ++------ .../app_settings/shaders/class1/interface/highlightNormV.glsl | 10 +++++----- .../app_settings/shaders/class1/interface/highlightSpecV.glsl | 10 +++++----- .../app_settings/shaders/class1/interface/highlightV.glsl | 6 +++--- .../app_settings/shaders/class1/interface/irradianceGenV.glsl | 4 ++-- .../app_settings/shaders/class1/interface/occlusionCubeV.glsl | 2 +- .../shaders/class1/interface/occlusionSkinnedV.glsl | 2 +- .../app_settings/shaders/class1/interface/occlusionV.glsl | 2 +- .../shaders/class1/interface/onetexturefilterF.glsl | 8 ++------ .../shaders/class1/interface/onetexturefilterV.glsl | 6 +++--- .../app_settings/shaders/class1/interface/pathfindingF.glsl | 6 +----- .../shaders/class1/interface/pathfindingNoNormalV.glsl | 6 +++--- .../app_settings/shaders/class1/interface/pathfindingV.glsl | 8 ++++---- .../app_settings/shaders/class1/interface/radianceGenF.glsl | 2 +- .../app_settings/shaders/class1/interface/radianceGenV.glsl | 4 ++-- .../app_settings/shaders/class1/interface/solidcolorF.glsl | 8 ++------ .../app_settings/shaders/class1/interface/solidcolorV.glsl | 6 +++--- .../shaders/class1/interface/twotexturecompareF.glsl | 10 +++------- .../shaders/class1/interface/twotexturecompareV.glsl | 10 +++++----- indra/newview/app_settings/shaders/class1/interface/uiF.glsl | 10 +++------- indra/newview/app_settings/shaders/class1/interface/uiV.glsl | 10 +++++----- 32 files changed, 76 insertions(+), 120 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/interface') diff --git a/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl b/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl index 69c1983b4d..a46e91c394 100644 --- a/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl @@ -23,22 +23,18 @@ * $/LicenseInfo$ */ -#ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif uniform sampler2D diffuseMap; uniform float minimum_alpha; -VARYING vec2 vary_texcoord0; -VARYING vec4 vertex_color; +in vec2 vary_texcoord0; +in vec4 vertex_color; void main() { - vec4 col = vertex_color*texture2D(diffuseMap, vary_texcoord0.xy); + vec4 col = vertex_color*texture(diffuseMap, vary_texcoord0.xy); if (col.a < minimum_alpha) { discard; diff --git a/indra/newview/app_settings/shaders/class1/interface/alphamaskV.glsl b/indra/newview/app_settings/shaders/class1/interface/alphamaskV.glsl index 3580d1f27b..a8dac55130 100644 --- a/indra/newview/app_settings/shaders/class1/interface/alphamaskV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/alphamaskV.glsl @@ -26,12 +26,12 @@ uniform mat4 texture_matrix0; uniform mat4 modelview_projection_matrix; -ATTRIBUTE vec3 position; -ATTRIBUTE vec4 diffuse_color; -ATTRIBUTE vec2 texcoord0; +in vec3 position; +in vec4 diffuse_color; +in vec2 texcoord0; -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; +out vec4 vertex_color; +out vec2 vary_texcoord0; void main() { diff --git a/indra/newview/app_settings/shaders/class1/interface/benchmarkF.glsl b/indra/newview/app_settings/shaders/class1/interface/benchmarkF.glsl index 1936e0dcaa..06b19c22c9 100644 --- a/indra/newview/app_settings/shaders/class1/interface/benchmarkF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/benchmarkF.glsl @@ -23,17 +23,13 @@ * $/LicenseInfo$ */ -#ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif uniform sampler2D diffuseMap; -VARYING vec2 tc0; +in vec2 tc0; void main() { - frag_color = texture2D(diffuseMap, tc0); + frag_color = texture(diffuseMap, tc0); } diff --git a/indra/newview/app_settings/shaders/class1/interface/benchmarkV.glsl b/indra/newview/app_settings/shaders/class1/interface/benchmarkV.glsl index 7beb20ede4..cbcc6bef97 100644 --- a/indra/newview/app_settings/shaders/class1/interface/benchmarkV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/benchmarkV.glsl @@ -25,9 +25,9 @@ uniform mat4 modelview_projection_matrix; -ATTRIBUTE vec3 position; +in vec3 position; -VARYING vec2 tc0; +out vec2 tc0; void main() { diff --git a/indra/newview/app_settings/shaders/class1/interface/clipF.glsl b/indra/newview/app_settings/shaders/class1/interface/clipF.glsl index 9454bbf21e..ee2d652f32 100644 --- a/indra/newview/app_settings/shaders/class1/interface/clipF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/clipF.glsl @@ -23,16 +23,12 @@ * $/LicenseInfo$ */ -#ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif uniform vec4 color; uniform vec4 clip_plane; -VARYING vec3 vary_position; +in vec3 vary_position; void main() diff --git a/indra/newview/app_settings/shaders/class1/interface/clipV.glsl b/indra/newview/app_settings/shaders/class1/interface/clipV.glsl index e376b25a71..7dd2ef593f 100644 --- a/indra/newview/app_settings/shaders/class1/interface/clipV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/clipV.glsl @@ -26,9 +26,9 @@ uniform mat4 modelview_projection_matrix; uniform mat4 modelview_matrix; -ATTRIBUTE vec3 position; +in vec3 position; -VARYING vec3 vary_position; +out vec3 vary_position; void main() { diff --git a/indra/newview/app_settings/shaders/class1/interface/debugF.glsl b/indra/newview/app_settings/shaders/class1/interface/debugF.glsl index cb8d6a8c03..cefa429639 100644 --- a/indra/newview/app_settings/shaders/class1/interface/debugF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/debugF.glsl @@ -23,11 +23,7 @@ * $/LicenseInfo$ */ -#ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif uniform vec4 color; diff --git a/indra/newview/app_settings/shaders/class1/interface/debugV.glsl b/indra/newview/app_settings/shaders/class1/interface/debugV.glsl index 153998f1d5..2e32863109 100644 --- a/indra/newview/app_settings/shaders/class1/interface/debugV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/debugV.glsl @@ -25,7 +25,7 @@ uniform mat4 modelview_projection_matrix; -ATTRIBUTE vec3 position; +in vec3 position; #ifdef HAS_SKIN mat4 getObjectSkinnedTransform(); diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl index e578bb6fc5..fa8aa5c7fe 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl @@ -23,8 +23,6 @@ * $/LicenseInfo$ */ -#extension GL_ARB_texture_rectangle : enable - /*[EXTRA_CODE_HERE]*/ out vec4 frag_color; @@ -36,5 +34,5 @@ in vec2 tc; void main() { - frag_color = texture2D(diffuseRect, tc) + texture2D(emissiveRect, tc); + frag_color = texture(diffuseRect, tc) + texture(emissiveRect, tc); } diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl index c50548d528..3d4035620f 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl @@ -23,8 +23,6 @@ * $/LicenseInfo$ */ -#extension GL_ARB_texture_rectangle : enable - /*[EXTRA_CODE_HERE]*/ out vec4 frag_color; diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl index 48aab1ce21..fa67b13e4d 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl @@ -24,9 +24,9 @@ */ -ATTRIBUTE vec3 position; +in vec3 position; -VARYING vec2 vary_tc; +out vec2 vary_tc; void main() { diff --git a/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl index 58c9e5ad0a..9bba1b2e18 100644 --- a/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl @@ -23,18 +23,14 @@ * $/LicenseInfo$ */ -#ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif uniform vec4 color; uniform sampler2D diffuseMap; -VARYING vec2 vary_texcoord0; +in vec2 vary_texcoord0; void main() { - frag_color = max(color*texture2D(diffuseMap, vary_texcoord0.xy), vec4(0)); + frag_color = max(color*texture(diffuseMap, vary_texcoord0.xy), vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/interface/highlightNormV.glsl b/indra/newview/app_settings/shaders/class1/interface/highlightNormV.glsl index 947c2b0065..0253c7236d 100644 --- a/indra/newview/app_settings/shaders/class1/interface/highlightNormV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/highlightNormV.glsl @@ -26,12 +26,12 @@ uniform mat4 texture_matrix0; uniform mat4 modelview_projection_matrix; -ATTRIBUTE vec3 position; -ATTRIBUTE vec2 texcoord0; -ATTRIBUTE vec2 texcoord1; -ATTRIBUTE vec2 texcoord2; +in vec3 position; +in vec2 texcoord0; +in vec2 texcoord1; +in vec2 texcoord2; -VARYING vec2 vary_texcoord0; +out vec2 vary_texcoord0; void main() { diff --git a/indra/newview/app_settings/shaders/class1/interface/highlightSpecV.glsl b/indra/newview/app_settings/shaders/class1/interface/highlightSpecV.glsl index c5d102b739..9f7ff8337a 100644 --- a/indra/newview/app_settings/shaders/class1/interface/highlightSpecV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/highlightSpecV.glsl @@ -26,12 +26,12 @@ uniform mat4 texture_matrix0; uniform mat4 modelview_projection_matrix; -ATTRIBUTE vec3 position; -ATTRIBUTE vec2 texcoord0; -ATTRIBUTE vec2 texcoord1; -ATTRIBUTE vec2 texcoord2; +in vec3 position; +in vec2 texcoord0; +in vec2 texcoord1; +in vec2 texcoord2; -VARYING vec2 vary_texcoord0; +out vec2 vary_texcoord0; void main() { diff --git a/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl b/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl index 0b362cf46c..481b7a3b1d 100644 --- a/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl @@ -26,10 +26,10 @@ uniform mat4 texture_matrix0; uniform mat4 modelview_projection_matrix; -ATTRIBUTE vec3 position; -ATTRIBUTE vec2 texcoord0; +in vec3 position; +in vec2 texcoord0; -VARYING vec2 vary_texcoord0; +out vec2 vary_texcoord0; #ifdef HAS_SKIN mat4 getObjectSkinnedTransform(); diff --git a/indra/newview/app_settings/shaders/class1/interface/irradianceGenV.glsl b/indra/newview/app_settings/shaders/class1/interface/irradianceGenV.glsl index 5190abf17c..633c928e6b 100644 --- a/indra/newview/app_settings/shaders/class1/interface/irradianceGenV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/irradianceGenV.glsl @@ -25,9 +25,9 @@ uniform mat4 modelview_matrix; -ATTRIBUTE vec3 position; +in vec3 position; -VARYING vec3 vary_dir; +out vec3 vary_dir; void main() { diff --git a/indra/newview/app_settings/shaders/class1/interface/occlusionCubeV.glsl b/indra/newview/app_settings/shaders/class1/interface/occlusionCubeV.glsl index 5c479d27a9..75ff19e470 100644 --- a/indra/newview/app_settings/shaders/class1/interface/occlusionCubeV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/occlusionCubeV.glsl @@ -25,7 +25,7 @@ uniform mat4 modelview_projection_matrix; -ATTRIBUTE vec3 position; +in vec3 position; uniform vec3 box_center; uniform vec3 box_size; diff --git a/indra/newview/app_settings/shaders/class1/interface/occlusionSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/interface/occlusionSkinnedV.glsl index 7305065a05..1ff9c347b6 100644 --- a/indra/newview/app_settings/shaders/class1/interface/occlusionSkinnedV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/occlusionSkinnedV.glsl @@ -26,7 +26,7 @@ uniform mat4 projection_matrix; uniform mat4 modelview_matrix; -ATTRIBUTE vec3 position; +in vec3 position; mat4 getObjectSkinnedTransform(); diff --git a/indra/newview/app_settings/shaders/class1/interface/occlusionV.glsl b/indra/newview/app_settings/shaders/class1/interface/occlusionV.glsl index c26fa08ddc..b44c746fa7 100644 --- a/indra/newview/app_settings/shaders/class1/interface/occlusionV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/occlusionV.glsl @@ -25,7 +25,7 @@ uniform mat4 modelview_projection_matrix; -ATTRIBUTE vec3 position; +in vec3 position; void main() { diff --git a/indra/newview/app_settings/shaders/class1/interface/onetexturefilterF.glsl b/indra/newview/app_settings/shaders/class1/interface/onetexturefilterF.glsl index f1400c9b44..a85d055a5b 100644 --- a/indra/newview/app_settings/shaders/class1/interface/onetexturefilterF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/onetexturefilterF.glsl @@ -23,20 +23,16 @@ * $/LicenseInfo$ */ -#ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif uniform sampler2D tex0; uniform float tolerance; -VARYING vec2 vary_texcoord0; +in vec2 vary_texcoord0; void main() { - frag_color = texture2D(tex0, vary_texcoord0.xy); + frag_color = texture(tex0, vary_texcoord0.xy); if(frag_color[0] + frag_color[1] + frag_color[2] < tolerance) { diff --git a/indra/newview/app_settings/shaders/class1/interface/onetexturefilterV.glsl b/indra/newview/app_settings/shaders/class1/interface/onetexturefilterV.glsl index a33ef7e92c..1b8411603a 100644 --- a/indra/newview/app_settings/shaders/class1/interface/onetexturefilterV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/onetexturefilterV.glsl @@ -25,10 +25,10 @@ uniform mat4 modelview_projection_matrix; -ATTRIBUTE vec3 position; -ATTRIBUTE vec2 texcoord0; +in vec3 position; +in vec2 texcoord0; -VARYING vec2 vary_texcoord0; +out vec2 vary_texcoord0; void main() { diff --git a/indra/newview/app_settings/shaders/class1/interface/pathfindingF.glsl b/indra/newview/app_settings/shaders/class1/interface/pathfindingF.glsl index 7379360e17..fac22be6de 100644 --- a/indra/newview/app_settings/shaders/class1/interface/pathfindingF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/pathfindingF.glsl @@ -23,13 +23,9 @@ * $/LicenseInfo$ */ -#ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif -VARYING vec4 vertex_color; +in vec4 vertex_color; void main() { diff --git a/indra/newview/app_settings/shaders/class1/interface/pathfindingNoNormalV.glsl b/indra/newview/app_settings/shaders/class1/interface/pathfindingNoNormalV.glsl index 19fa607307..4f08df839d 100644 --- a/indra/newview/app_settings/shaders/class1/interface/pathfindingNoNormalV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/pathfindingNoNormalV.glsl @@ -25,10 +25,10 @@ uniform mat4 modelview_projection_matrix; -ATTRIBUTE vec3 position; -ATTRIBUTE vec4 diffuse_color; +in vec3 position; +in vec4 diffuse_color; -VARYING vec4 vertex_color; +out vec4 vertex_color; uniform float tint; uniform float alpha_scale; diff --git a/indra/newview/app_settings/shaders/class1/interface/pathfindingV.glsl b/indra/newview/app_settings/shaders/class1/interface/pathfindingV.glsl index 91f252cf1e..9e77927cb8 100644 --- a/indra/newview/app_settings/shaders/class1/interface/pathfindingV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/pathfindingV.glsl @@ -25,11 +25,11 @@ uniform mat4 modelview_projection_matrix; -ATTRIBUTE vec3 position; -ATTRIBUTE vec4 diffuse_color; -ATTRIBUTE vec3 normal; +in vec3 position; +in vec4 diffuse_color; +in vec3 normal; -VARYING vec4 vertex_color; +out vec4 vertex_color; uniform float tint; uniform float ambiance; 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; diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenV.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenV.glsl index 5f5d9396ff..2c31e98838 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenV.glsl @@ -25,9 +25,9 @@ uniform mat4 modelview_matrix; -ATTRIBUTE vec3 position; +in vec3 position; -VARYING vec3 vary_dir; +out vec3 vary_dir; void main() { diff --git a/indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl b/indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl index da02534dbb..a14334fd01 100644 --- a/indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl @@ -23,21 +23,17 @@ * $/LicenseInfo$ */ -#ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif uniform sampler2D tex0; uniform vec4 color; -VARYING vec2 vary_texcoord0; +in vec2 vary_texcoord0; void main() { - float alpha = texture2D(tex0, vary_texcoord0.xy).a * color.a; + float alpha = texture(tex0, vary_texcoord0.xy).a * color.a; frag_color = vec4(color.rgb, alpha); } diff --git a/indra/newview/app_settings/shaders/class1/interface/solidcolorV.glsl b/indra/newview/app_settings/shaders/class1/interface/solidcolorV.glsl index f33115d78d..b280fcdc15 100644 --- a/indra/newview/app_settings/shaders/class1/interface/solidcolorV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/solidcolorV.glsl @@ -25,10 +25,10 @@ uniform mat4 modelview_projection_matrix; -ATTRIBUTE vec3 position; -ATTRIBUTE vec2 texcoord0; +in vec3 position; +in vec2 texcoord0; -VARYING vec2 vary_texcoord0; +out vec2 vary_texcoord0; void main() { diff --git a/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl b/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl index 6eeb2596b2..6d51b898b7 100644 --- a/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl @@ -23,11 +23,7 @@ * $/LicenseInfo$ */ -#ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif uniform sampler2D tex0; uniform sampler2D tex1; @@ -36,12 +32,12 @@ uniform float dither_scale; uniform float dither_scale_s; uniform float dither_scale_t; -VARYING vec2 vary_texcoord0; -VARYING vec2 vary_texcoord1; +in vec2 vary_texcoord0; +in vec2 vary_texcoord1; void main() { - frag_color = abs(texture2D(tex0, vary_texcoord0.xy) - texture2D(tex1, vary_texcoord0.xy)); + frag_color = abs(texture(tex0, vary_texcoord0.xy) - texture(tex1, vary_texcoord0.xy)); vec2 dither_coord; dither_coord[0] = vary_texcoord0[0] * dither_scale_s; diff --git a/indra/newview/app_settings/shaders/class1/interface/twotexturecompareV.glsl b/indra/newview/app_settings/shaders/class1/interface/twotexturecompareV.glsl index 67c6674f0c..a103bff12d 100644 --- a/indra/newview/app_settings/shaders/class1/interface/twotexturecompareV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/twotexturecompareV.glsl @@ -25,12 +25,12 @@ uniform mat4 modelview_projection_matrix; -ATTRIBUTE vec3 position; -ATTRIBUTE vec2 texcoord0; -ATTRIBUTE vec2 texcoord1; +in vec3 position; +in vec2 texcoord0; +in vec2 texcoord1; -VARYING vec2 vary_texcoord0; -VARYING vec2 vary_texcoord1; +out vec2 vary_texcoord0; +out vec2 vary_texcoord1; void main() { diff --git a/indra/newview/app_settings/shaders/class1/interface/uiF.glsl b/indra/newview/app_settings/shaders/class1/interface/uiF.glsl index 299bfb72aa..a29b848253 100644 --- a/indra/newview/app_settings/shaders/class1/interface/uiF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/uiF.glsl @@ -23,18 +23,14 @@ * $/LicenseInfo$ */ -#ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif uniform sampler2D diffuseMap; -VARYING vec2 vary_texcoord0; -VARYING vec4 vertex_color; +in vec2 vary_texcoord0; +in vec4 vertex_color; void main() { - frag_color = vertex_color*texture2D(diffuseMap, vary_texcoord0.xy); + frag_color = vertex_color*texture(diffuseMap, vary_texcoord0.xy); } diff --git a/indra/newview/app_settings/shaders/class1/interface/uiV.glsl b/indra/newview/app_settings/shaders/class1/interface/uiV.glsl index 220dafef25..91a846b9fa 100644 --- a/indra/newview/app_settings/shaders/class1/interface/uiV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/uiV.glsl @@ -26,12 +26,12 @@ uniform mat4 texture_matrix0; uniform mat4 modelview_projection_matrix; -ATTRIBUTE vec3 position; -ATTRIBUTE vec4 diffuse_color; -ATTRIBUTE vec2 texcoord0; +in vec3 position; +in vec4 diffuse_color; +in vec2 texcoord0; -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; +out vec4 vertex_color; +out vec2 vary_texcoord0; void main() { -- cgit v1.2.3