diff options
author | Jonathan Goodman <geenz@lindenlab.com> | 2022-11-14 18:12:22 +0000 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2022-11-14 18:12:22 +0000 |
commit | 97277e74a9d966ed441e51f844f9012f55cca3dc (patch) | |
tree | ed6a5c00a5065951ff9f77bf0277fb202dff0c0e /indra/newview/app_settings/shaders/class3 | |
parent | 843a5c287e34855fb7bd4882d8d0a106e987a9f7 (diff) |
Merged in SL-18332 (pull request #1194)
First pass of Screen Space Reflections
Approved-by: Dave Parks
Diffstat (limited to 'indra/newview/app_settings/shaders/class3')
9 files changed, 343 insertions, 55 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl index 6dd446d9f7..43327be49f 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl @@ -33,10 +33,10 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -uniform sampler2DRect depthMap; -uniform sampler2DRect diffuseRect; -uniform sampler2DRect specularRect; -uniform sampler2DRect emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl +uniform sampler2D depthMap; +uniform sampler2D diffuseRect; +uniform sampler2D specularRect; +uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl uniform sampler2D noiseMap; uniform sampler2D lightFunc; @@ -57,6 +57,7 @@ float calcLegacyDistanceAttenuation(float distance, float falloff); vec4 getPosition(vec2 pos_screen); vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensity); vec2 getScreenXY(vec4 clip); +vec2 getScreenCoord(vec4 clip); vec3 srgb_to_linear(vec3 c); // Util @@ -76,7 +77,7 @@ void main() discard; // Bail immediately #else vec3 final_color = vec3(0, 0, 0); - vec2 tc = getScreenXY(vary_fragcoord); + vec2 tc = getScreenCoord(vary_fragcoord); vec3 pos = getPosition(tc).xyz; if (pos.z < far_z) { @@ -87,15 +88,15 @@ void main() vec3 n; vec4 norm = getNormalEnvIntensityFlags(tc, n, envIntensity); // need `norm.w` for GET_GBUFFER_FLAG() - vec4 spec = texture2DRect(specularRect, tc); - vec3 diffuse = texture2DRect(diffuseRect, tc).rgb; + vec4 spec = texture2D(specularRect, tc); + vec3 diffuse = texture2D(diffuseRect, tc).rgb; vec3 h, l, v = -normalize(pos); float nh, nv, vh, lightDist; if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR)) { - vec3 colorEmissive = texture2DRect(emissiveRect, tc).rgb; + vec3 colorEmissive = texture2D(emissiveRect, tc).rgb; vec3 orm = spec.rgb; float perceptualRoughness = orm.g; float metallic = orm.b; diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightV.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightV.glsl index ad6a0fa752..831b3b2684 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightV.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightV.glsl @@ -23,8 +23,6 @@ * $/LicenseInfo$ */ -uniform mat4 modelview_projection_matrix; - ATTRIBUTE vec3 position; VARYING vec4 vary_fragcoord; @@ -32,7 +30,7 @@ VARYING vec4 vary_fragcoord; void main() { //transform vertex - vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0); + vec4 pos = vec4(position.xyz, 1.0); vary_fragcoord = pos; gl_Position = pos; diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl index cb8877ebe5..4a172f7a10 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl @@ -34,13 +34,13 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -uniform sampler2DRect diffuseRect; -uniform sampler2DRect specularRect; -uniform sampler2DRect depthMap; -uniform sampler2DRect normalMap; -uniform sampler2DRect emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl +uniform sampler2D diffuseRect; +uniform sampler2D specularRect; +uniform sampler2D depthMap; +uniform sampler2D normalMap; +uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl uniform samplerCube environmentMap; -uniform sampler2DRect lightMap; +uniform sampler2D lightMap; uniform sampler2D noiseMap; uniform sampler2D projectionMap; // rgba uniform sampler2D lightFunc; @@ -82,6 +82,7 @@ vec3 getProjectedLightAmbiance(float amb_da, float attenuation, float lit, float vec3 getProjectedLightDiffuseColor(float light_distance, vec2 projected_uv ); vec3 getProjectedLightSpecularColor(vec3 pos, vec3 n); vec2 getScreenXY(vec4 clip); +vec2 getScreenCoord(vec4 clip); vec3 srgb_to_linear(vec3 cs); vec4 texture2DLodSpecular(vec2 tc, float lod); @@ -102,7 +103,7 @@ void main() discard; #else vec3 final_color = vec3(0,0,0); - vec2 tc = getScreenXY(vary_fragcoord); + vec2 tc = getScreenCoord(vary_fragcoord); vec3 pos = getPosition(tc).xyz; vec3 lv; @@ -117,7 +118,7 @@ void main() if (proj_shadow_idx >= 0) { - vec4 shd = texture2DRect(lightMap, tc); + vec4 shd = texture2D(lightMap, tc); shadow = (proj_shadow_idx==0)?shd.b:shd.a; shadow += shadow_fade; shadow = clamp(shadow, 0.0, 1.0); @@ -138,8 +139,8 @@ void main() float nh, nl, nv, vh, lightDist; calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist); - vec3 diffuse = texture2DRect(diffuseRect, tc).rgb; - vec4 spec = texture2DRect(specularRect, tc); + vec3 diffuse = texture2D(diffuseRect, tc).rgb; + vec4 spec = texture2D(specularRect, tc); vec3 dlit = vec3(0, 0, 0); vec3 slit = vec3(0, 0, 0); @@ -147,7 +148,7 @@ void main() if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR)) { - vec3 colorEmissive = texture2DRect(emissiveRect, tc).rgb; + vec3 colorEmissive = texture2D(emissiveRect, tc).rgb; vec3 orm = spec.rgb; float perceptualRoughness = orm.g; float metallic = orm.b; diff --git a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl index cdffcf103d..0c8baab14f 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl @@ -33,13 +33,13 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -uniform sampler2DRect diffuseRect; -uniform sampler2DRect specularRect; -uniform sampler2DRect normalMap; -uniform sampler2DRect emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl +uniform sampler2D diffuseRect; +uniform sampler2D specularRect; +uniform sampler2D normalMap; +uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl uniform sampler2D noiseMap; uniform sampler2D lightFunc; -uniform sampler2DRect depthMap; +uniform sampler2D depthMap; uniform vec3 env_mat[3]; uniform float sun_wash; @@ -62,7 +62,9 @@ float calcLegacyDistanceAttenuation(float distance, float falloff); vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensity); vec4 getPosition(vec2 pos_screen); vec2 getScreenXY(vec4 clip); +vec2 getScreenCoord(vec4 clip); vec3 srgb_to_linear(vec3 c); +float getDepth(vec2 tc); vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, float perceptualRoughness, @@ -74,15 +76,15 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, void main() { vec3 final_color = vec3(0); - vec2 tc = getScreenXY(vary_fragcoord); + vec2 tc = getScreenCoord(vary_fragcoord); vec3 pos = getPosition(tc).xyz; float envIntensity; vec3 n; vec4 norm = getNormalEnvIntensityFlags(tc, n, envIntensity); // need `norm.w` for GET_GBUFFER_FLAG() - vec3 diffuse = texture2DRect(diffuseRect, tc).rgb; - vec4 spec = texture2DRect(specularRect, tc); + vec3 diffuse = texture2D(diffuseRect, tc).rgb; + vec4 spec = texture2D(specularRect, tc); // Common half vectors calcs vec3 lv = trans_center.xyz-pos; @@ -99,7 +101,7 @@ void main() if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR)) { - vec3 colorEmissive = texture2DRect(emissiveRect, tc).rgb; + vec3 colorEmissive = texture2D(emissiveRect, tc).rgb; vec3 orm = spec.rgb; float perceptualRoughness = orm.g; float metallic = orm.b; diff --git a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl new file mode 100644 index 0000000000..9172789b38 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl @@ -0,0 +1,98 @@ +/** + * @file class3/deferred/screenSpaceReflPostF.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$ + */ + +#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 vec2 screen_res; +uniform mat4 projection_matrix; +uniform mat4 inv_proj; +uniform float zNear; +uniform float zFar; + +VARYING vec2 vary_fragcoord; +VARYING vec3 camera_ray; + +uniform sampler2D depthMap; +uniform sampler2D normalMap; +uniform sampler2D sceneMap; +uniform sampler2D diffuseRect; + +vec3 getNorm(vec2 screenpos); +float getDepth(vec2 pos_screen); +float linearDepth(float d, float znear, float zfar); +float linearDepth01(float d, float znear, float zfar); + +vec4 getPositionWithDepth(vec2 pos_screen, float depth); +vec4 getPosition(vec2 pos_screen); + +bool traceScreenRay(vec3 position, vec3 reflection, out vec3 hitColor, out float hitDepth, float depth, sampler2D textureFrame); +float random (vec2 uv); +void main() { + vec2 tc = vary_fragcoord.xy; + float depth = linearDepth01(getDepth(tc), zNear, zFar); + vec3 pos = getPositionWithDepth(tc, getDepth(tc)).xyz; + vec3 viewPos = camera_ray * depth; + vec3 rayDirection = normalize(reflect(normalize(viewPos), getNorm(tc))) * -viewPos.z; + vec2 hitpixel; + vec3 hitpoint; + + vec2 uv2 = tc * screen_res; + float c = (uv2.x + uv2.y) * 0.125; + float jitter = mod( c, 1.0); + + vec3 firstBasis = normalize(cross(vec3(0.f, 0.f, 1.f), rayDirection)); + vec3 secondBasis = normalize(cross(rayDirection, firstBasis)); + + frag_color.rgb = texture(diffuseRect, tc).rgb; + vec4 collectedColor; + for (int i = 0; i < 1; i++) { + vec2 coeffs = vec2(random(tc + vec2(0, i)) + random(tc + vec2(i, 0))) * 0.25; + vec3 reflectionDirectionRandomized = rayDirection + firstBasis * coeffs.x + secondBasis * coeffs.y; + + bool hit = traceScreenRay(pos, reflectionDirectionRandomized, hitpoint, depth, depth, diffuseRect); + if (hit) { + vec2 screenpos = tc * 2 - 1; + float vignette = 1;// clamp((1 - dot(screenpos, screenpos)) * 4,0, 1); + vignette *= dot(normalize(viewPos), getNorm(tc)) * 0.5 + 0.5; + vignette *= min(linearDepth(getDepth(tc), zNear, zFar) / (zFar * 0.0125), 1); + collectedColor.rgb = hitpoint * vignette * 0.25; + frag_color.rgb = hitpoint; + } + } + + //frag_color.rgb = collectedColor.rgb; + + + + frag_color.a = 1.0; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostV.glsl b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostV.glsl new file mode 100644 index 0000000000..b084094d4d --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostV.glsl @@ -0,0 +1,48 @@ +/** + * @file class3/deferred/screenSpaceReflPostV.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 projection_matrix; +uniform mat4 inv_proj; + +ATTRIBUTE vec3 position; + +uniform vec2 screen_res; + +VARYING vec2 vary_fragcoord; +VARYING vec3 camera_ray; + + +void main() +{ + //transform vertex + vec4 pos = vec4(position.xyz, 1.0); + gl_Position = pos; + + vary_fragcoord = pos.xy * 0.5 + 0.5; + + vec4 rayOrig = inv_proj * vec4(pos.xy, 1, 1); + camera_ray = rayOrig.xyz / rayOrig.w; + +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl new file mode 100644 index 0000000000..5eefd99d00 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl @@ -0,0 +1,138 @@ +/** + * @file class3/deferred/screenSpaceReflUtil.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 sampler2D depthMap; +uniform sampler2D normalMap; +uniform sampler2D sceneMap; +uniform vec2 screen_res; +uniform mat4 projection_matrix; +uniform float zNear; +uniform float zFar; +uniform mat4 inv_proj; + +vec4 getPositionWithDepth(vec2 pos_screen, float depth); +float linearDepth(float depth, float near, float far); +float getDepth(vec2 pos_screen); +float linearDepth01(float d, float znear, float zfar); + +float random (vec2 uv) { + return fract(sin(dot(uv, vec2(12.9898, 78.233))) * 43758.5453123); //simple random function +} + +// Based off of https://github.com/RoundedGlint585/ScreenSpaceReflection/ +// A few tweaks here and there to suit our needs. + +vec2 generateProjectedPosition(vec3 pos){ + vec4 samplePosition = projection_matrix * vec4(pos, 1.f); + samplePosition.xy = (samplePosition.xy / samplePosition.w) * 0.5 + 0.5; + return samplePosition.xy; +} + +bool isBinarySearchEnabled = true; +bool isAdaptiveStepEnabled = true; +bool isExponentialStepEnabled = false; +bool debugDraw = false; +int iterationCount = 100; +float rayStep = 0.2; +float distanceBias = 0.05; +float depthRejectBias = 0.001; +float epsilon = 0.1; + +bool traceScreenRay(vec3 position, vec3 reflection, out vec3 hitColor, out float hitDepth, float depth, sampler2D textureFrame) { + vec3 step = rayStep * reflection; + vec3 marchingPosition = position + step; + float delta; + float depthFromScreen; + vec2 screenPosition; + bool hit = false; + hitColor = vec3(0); + + int i = 0; + if (depth > depthRejectBias) { + for (; i < iterationCount && !hit; i++) { + screenPosition = generateProjectedPosition(marchingPosition); + depthFromScreen = abs(getPositionWithDepth(screenPosition, linearDepth(getDepth(screenPosition), zNear, zFar)).z); + delta = abs(marchingPosition.z) - depthFromScreen; + + if (depth < depthFromScreen + epsilon && depth > depthFromScreen - epsilon) { + break; + } + + if (abs(delta) < distanceBias) { + vec3 color = vec3(1); + if(debugDraw) + color = vec3( 0.5+ sign(delta)/2,0.3,0.5- sign(delta)/2); + hitColor = texture(textureFrame, screenPosition).xyz * color; + hitDepth = depthFromScreen; + hit = true; + break; + } + if (isBinarySearchEnabled && delta > 0) { + break; + } + if (isAdaptiveStepEnabled){ + float directionSign = sign(abs(marchingPosition.z) - depthFromScreen); + //this is sort of adapting step, should prevent lining reflection by doing sort of iterative converging + //some implementation doing it by binary search, but I found this idea more cheaty and way easier to implement + step = step * (1.0 - rayStep * max(directionSign, 0.0)); + marchingPosition += step * (-directionSign); + } + else { + marchingPosition += step; + } + + if (isExponentialStepEnabled){ + step *= 1.05; + } + } + if(isBinarySearchEnabled){ + for(; i < iterationCount && !hit; i++){ + + step *= 0.5; + marchingPosition = marchingPosition - step * sign(delta); + + screenPosition = generateProjectedPosition(marchingPosition); + depthFromScreen = abs(getPositionWithDepth(screenPosition, getDepth(screenPosition)).z); + delta = abs(marchingPosition.z) - depthFromScreen; + + if (depth < depthFromScreen + epsilon && depth > depthFromScreen - epsilon) { + break; + } + + if (abs(delta) < distanceBias && depthFromScreen != (depth - distanceBias)) { + vec3 color = vec3(1); + if(debugDraw) + color = vec3( 0.5+ sign(delta)/2,0.3,0.5- sign(delta)/2); + hitColor = texture(textureFrame, screenPosition).xyz * color; + hitDepth = depthFromScreen; + hit = true; + break; + } + } + } + } + + return hit; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 879f4ef510..5f6982746b 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -37,19 +37,19 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -uniform sampler2DRect diffuseRect; -uniform sampler2DRect specularRect; -uniform sampler2DRect normalMap; -uniform sampler2DRect emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl +uniform sampler2D diffuseRect; +uniform sampler2D specularRect; +uniform sampler2D normalMap; +uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl uniform sampler2D altDiffuseMap; // PBR: irradiance, skins/default/textures/default_irradiance.png const float M_PI = 3.14159265; #if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO) -uniform sampler2DRect lightMap; +uniform sampler2D lightMap; #endif -uniform sampler2DRect depthMap; +uniform sampler2D depthMap; uniform sampler2D lightFunc; uniform float blur_size; @@ -81,6 +81,7 @@ void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 pos, vec3 norm, float glossiness, float envIntensity); void applyGlossEnv(inout vec3 color, vec3 glossenv, vec4 spec, vec3 pos, vec3 norm); void applyLegacyEnv(inout vec3 color, vec3 legacyenv, vec4 spec, vec3 pos, vec3 norm, float envIntensity); +float getDepth(vec2 pos_screen); vec3 linear_to_srgb(vec3 c); vec3 srgb_to_linear(vec3 c); @@ -118,18 +119,18 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, void main() { vec2 tc = vary_fragcoord.xy; - float depth = texture2DRect(depthMap, tc.xy).r; + float depth = getDepth(tc.xy); vec4 pos = getPositionWithDepth(tc, depth); - vec4 norm = texture2DRect(normalMap, tc); + vec4 norm = texture2D(normalMap, tc); float envIntensity = norm.z; norm.xyz = getNorm(tc); vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; - vec4 baseColor = texture2DRect(diffuseRect, tc); - vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); // NOTE: PBR linear Emissive + vec4 baseColor = texture2D(diffuseRect, tc); + vec4 spec = texture2D(specularRect, vary_fragcoord.xy); // NOTE: PBR linear Emissive #if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO) - vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; + vec2 scol_ambocc = texture2D(lightMap, vary_fragcoord.xy).rg; #endif #if defined(HAS_SUN_SHADOW) @@ -155,12 +156,12 @@ void main() if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR)) { - vec3 orm = texture2DRect(specularRect, tc).rgb; + vec3 orm = texture2D(specularRect, tc).rgb; float perceptualRoughness = orm.g; float metallic = orm.b; float ao = orm.r * ambocc; - vec3 colorEmissive = texture2DRect(emissiveRect, tc).rgb; + vec3 colorEmissive = texture2D(emissiveRect, tc).rgb; // PBR IBL float gloss = 1.0 - perceptualRoughness; diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl index 3274153a46..8618159313 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl @@ -44,13 +44,13 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -uniform sampler2DRect diffuseRect; -uniform sampler2DRect specularRect; -uniform sampler2DRect depthMap; -uniform sampler2DRect normalMap; -uniform sampler2DRect emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl +uniform sampler2D diffuseRect; +uniform sampler2D specularRect; +uniform sampler2D depthMap; +uniform sampler2D normalMap; +uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl uniform samplerCube environmentMap; -uniform sampler2DRect lightMap; +uniform sampler2D lightMap; uniform sampler2D noiseMap; uniform sampler2D projectionMap; // rgba uniform sampler2D lightFunc; @@ -90,6 +90,7 @@ vec3 getProjectedLightAmbiance(float amb_da, float attenuation, float lit, float vec3 getProjectedLightDiffuseColor(float light_distance, vec2 projected_uv ); vec3 getProjectedLightSpecularColor(vec3 pos, vec3 n); vec2 getScreenXY(vec4 clip_point); +vec2 getScreenCoord(vec4 clip_point); vec3 srgb_to_linear(vec3 c); vec4 texture2DLodSpecular(vec2 tc, float lod); @@ -110,7 +111,7 @@ void main() discard; #else vec3 final_color = vec3(0,0,0); - vec2 tc = getScreenXY(vary_fragcoord); + vec2 tc = getScreenCoord(vary_fragcoord); vec3 pos = getPosition(tc).xyz; vec3 lv; @@ -125,7 +126,7 @@ void main() if (proj_shadow_idx >= 0) { - vec4 shd = texture2DRect(lightMap, tc); + vec4 shd = texture2D(lightMap, tc); shadow = (proj_shadow_idx == 0) ? shd.b : shd.a; shadow += shadow_fade; shadow = clamp(shadow, 0.0, 1.0); @@ -146,15 +147,15 @@ void main() float nh, nl, nv, vh, lightDist; calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist); - vec3 diffuse = texture2DRect(diffuseRect, tc).rgb; - vec4 spec = texture2DRect(specularRect, tc); + vec3 diffuse = texture2D(diffuseRect, tc).rgb; + vec4 spec = texture2D(specularRect, tc); vec3 dlit = vec3(0, 0, 0); vec3 slit = vec3(0, 0, 0); vec3 amb_rgb = vec3(0); if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR)) { - vec3 colorEmissive = texture2DRect(emissiveRect, tc).rgb; + vec3 colorEmissive = texture2D(emissiveRect, tc).rgb; vec3 orm = spec.rgb; float perceptualRoughness = orm.g; float metallic = orm.b; |