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:
authorJeroen Bakker <jeroen@blender.org>2021-01-29 17:19:01 +0300
committerJeroen Bakker <jeroen@blender.org>2021-01-29 17:19:01 +0300
commitcacc1d723c763e8ea1f8e616e98b2dc35ed25f26 (patch)
tree26ef53914d3954dd94d9d25f2ddeb15ebab3e91c
parent9f89166b52b1de880c14847a1d0cd830d7c83f5b (diff)
Fix T81169: Grease Pencil Z-depth drawing issue on OSX + AMD Graphic Cards
The grease pencil merge depth shader is designed to only work correctly in octographic mode. The uv coordinates used `noperspective` attribute. Somehow this doesn't lead to render artifacts on most platforms and was only detected on OSX + AMD cards. This fix would calculate the uv coordinate inside the fragment shader and isn't passed along from the vertex shader. Thanks to Sebastián Barschkis for providing the hardware and time and Clément Foucault for helping out with the final fix.
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_frag.glsl5
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_vert.glsl3
2 files changed, 1 insertions, 7 deletions
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_frag.glsl
index 71597197bd8..2f711f6a2c5 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_frag.glsl
@@ -1,13 +1,10 @@
uniform sampler2D depthBuf;
-uniform float strokeDepth2d;
uniform bool strokeOrder3d;
-noperspective in vec4 uvcoordsvar;
-
void main()
{
- float depth = textureLod(depthBuf, uvcoordsvar.xy, 0).r;
+ float depth = textureLod(depthBuf, gl_FragCoord.xy / vec2(textureSize(depthBuf, 0)), 0).r;
if (strokeOrder3d) {
gl_FragDepth = depth;
}
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_vert.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_vert.glsl
index 1e5a900f486..0c5260a9ec4 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_vert.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_vert.glsl
@@ -1,8 +1,6 @@
uniform vec4 gpModelMatrix[4];
-noperspective out vec4 uvcoordsvar;
-
void main()
{
mat4 model_matrix = mat4(gpModelMatrix[0], gpModelMatrix[1], gpModelMatrix[2], gpModelMatrix[3]);
@@ -10,5 +8,4 @@ void main()
float x = -1.0 + float((v & 1) << 2);
float y = -1.0 + float((v & 2) << 1);
gl_Position = ViewProjectionMatrix * (model_matrix * vec4(x, y, 0.0, 1.0));
- uvcoordsvar = vec4((gl_Position.xy / gl_Position.w + 1.0) * 0.5, 0.0, 0.0);
}