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>2018-05-27 12:25:29 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-05-27 12:26:17 +0300
commit4ca4e64d25f69eb4cbb96084fb688b69484e1507 (patch)
tree7c8079fe267740e5230881abc4d7d6905ba0a9d9 /source/blender/draw/modes/shaders
parent9a74b603670cc3fab14d9fcd7be7b3c17731a8ee (diff)
Grid: Do not go over objects in front/side ortho views.
Fixes T55190 Grid displayed on top of objects in orthographic view
Diffstat (limited to 'source/blender/draw/modes/shaders')
-rw-r--r--source/blender/draw/modes/shaders/object_grid_frag.glsl30
1 files changed, 18 insertions, 12 deletions
diff --git a/source/blender/draw/modes/shaders/object_grid_frag.glsl b/source/blender/draw/modes/shaders/object_grid_frag.glsl
index 2d0d637fc45..2b04bb0d855 100644
--- a/source/blender/draw/modes/shaders/object_grid_frag.glsl
+++ b/source/blender/draw/modes/shaders/object_grid_frag.glsl
@@ -29,6 +29,7 @@ uniform int gridFlag;
#define PLANE_XY (1 << 4)
#define PLANE_XZ (1 << 5)
#define PLANE_YZ (1 << 6)
+#define GRID_BACK (1 << 9) /* grid is behind objects */
#define GRID_LINE_SMOOTH 1.15
@@ -137,18 +138,6 @@ void main()
}
}
- /* Manual, non hard, depth test:
- * Progressively fade the grid below occluders
- * (avoids poping visuals due to depth buffer precision) */
- float scene_depth = texture(depthBuffer, sPos).r;
- /* Add a small bias so the grid will always
- * be on top of a mesh with the same depth. */
- float grid_depth = gl_FragCoord.z - 1e-8;
- /* Harder settings tend to flicker more,
- * but have less "see through" appearance. */
- const float test_hardness = 1e4;
- fade *= 1.0 - clamp((grid_depth - scene_depth) * test_hardness, 0.0, 1.0);
-
if ((gridFlag & GRID) > 0) {
float grid_res = log(dist * gridResolution) * gridOneOverLogSubdiv;
@@ -217,5 +206,22 @@ void main()
}
}
+ float scene_depth = texture(depthBuffer, sPos).r;
+ if ((gridFlag & GRID_BACK) > 0) {
+ fade *= (scene_depth == 1.0) ? 1.0 : 0.0;
+ }
+ else {
+ /* Manual, non hard, depth test:
+ * Progressively fade the grid below occluders
+ * (avoids poping visuals due to depth buffer precision) */
+ /* Add a small bias so the grid will always
+ * be on top of a mesh with the same depth. */
+ float grid_depth = gl_FragCoord.z - 1e-8;
+ /* Harder settings tend to flicker more,
+ * but have less "see through" appearance. */
+ const float test_hardness = 1e4;
+ fade *= 1.0 - clamp((grid_depth - scene_depth) * test_hardness, 0.0, 1.0);
+ }
+
FragColor.a *= fade;
}