Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2021-09-21 17:38:25 +0300
committerClément Foucault <foucault.clem@gmail.com>2021-09-21 17:39:17 +0300
commit84f98e28e384f1245c11a81da57e74fa6130d286 (patch)
treedfb3f205996f6bd3d67dc67a7bd1ca1c1d7ce80d /source/blender/draw/engines/eevee/shaders
parent33955231f326c972dfd96486beb66f58831b59a3 (diff)
Fix T87801: Eevee ambient occlusion is incorrect on M1 macMini
The issue was caused by `textureSize()` returning the size of the level 0 even when the min texture level is higher than 0. Using a uniform to pass the correct size fixes the issue. This issue also affected the downsampling of radiance for reflections and refractions. This does not affect anything other than the recusive downsampling shaders.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders')
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl13
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl19
2 files changed, 21 insertions, 11 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl
index d1cb25af82f..9fc258da185 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl
@@ -9,14 +9,16 @@
uniform sampler2D source;
uniform float fireflyFactor;
+#ifndef COPY_SRC
+uniform vec2 texelSize;
+#endif
+
out vec4 FragColor;
void main()
{
- vec2 texel_size = 1.0 / vec2(textureSize(source, 0));
- vec2 uvs = gl_FragCoord.xy * texel_size;
-
#ifdef COPY_SRC
+ vec2 uvs = gl_FragCoord.xy / vec2(textureSize(source, 0));
FragColor = textureLod(source, uvs, 0.0);
FragColor = safe_color(FragColor);
@@ -25,7 +27,10 @@ void main()
FragColor *= 1.0 - max(0.0, luma - fireflyFactor) / luma;
#else
- vec4 ofs = texel_size.xyxy * vec4(0.75, 0.75, -0.75, -0.75);
+ /* NOTE(@fclem): textureSize() does not work the same on all implementations
+ * when changing the min and max texture levels. Use uniform instead (see T87801). */
+ vec2 uvs = gl_FragCoord.xy * texelSize;
+ vec4 ofs = texelSize.xyxy * vec4(0.75, 0.75, -0.75, -0.75);
uvs *= 2.0;
FragColor = textureLod(source, uvs + ofs.xy, 0.0);
diff --git a/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl
index ccb65d2e5a6..8ef39a55921 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl
@@ -14,6 +14,10 @@ uniform int depthLayer;
uniform sampler2D depthBuffer;
#endif
+#ifndef COPY_DEPTH
+uniform vec2 texelSize;
+#endif
+
#ifdef LAYERED
# define sampleLowerMip(t) texture(depthBuffer, vec3(t, depthLayer)).r
# define gatherLowerMip(t) textureGather(depthBuffer, vec3(t, depthLayer))
@@ -41,23 +45,24 @@ out vec4 fragColor;
void main()
{
vec2 texel = gl_FragCoord.xy;
- vec2 texel_size = 1.0 / vec2(textureSize(depthBuffer, 0).xy);
#ifdef COPY_DEPTH
- vec2 uv = texel * texel_size;
+ vec2 uv = texel / vec2(textureSize(depthBuffer, 0).xy);
float val = sampleLowerMip(uv);
#else
- vec2 uv = texel * 2.0 * texel_size;
+ /* NOTE(@fclem): textureSize() does not work the same on all implementations
+ * when changing the min and max texture levels. Use uniform instead (see T87801). */
+ vec2 uv = texel * 2.0 * texelSize;
vec4 samp;
# ifdef GPU_ARB_texture_gather
samp = gatherLowerMip(uv);
# else
- samp.x = sampleLowerMip(uv + vec2(-0.5, -0.5) * texel_size);
- samp.y = sampleLowerMip(uv + vec2(-0.5, 0.5) * texel_size);
- samp.z = sampleLowerMip(uv + vec2(0.5, -0.5) * texel_size);
- samp.w = sampleLowerMip(uv + vec2(0.5, 0.5) * texel_size);
+ samp.x = sampleLowerMip(uv + vec2(-0.5, -0.5) * texelSize);
+ samp.y = sampleLowerMip(uv + vec2(-0.5, 0.5) * texelSize);
+ samp.z = sampleLowerMip(uv + vec2(0.5, -0.5) * texelSize);
+ samp.w = sampleLowerMip(uv + vec2(0.5, 0.5) * texelSize);
# endif
float val = minmax4(samp.x, samp.y, samp.z, samp.w);