diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-09-21 23:00:48 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-09-22 03:44:39 +0300 |
commit | 4bfa3f4f9ba13d49409e64d71d6894a3be12cf16 (patch) | |
tree | 95c301bf256f6eaac2f319f568fdc79d22b9e2de /source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl | |
parent | e4f05df206b865997f42fe928442226f948cd0e5 (diff) |
Edit Mesh Mode : Make line smoother.
This introduce some little artifacts on the border of edges because some pixel with very low opacity does not get discarded and then occlude the face rendered behind if it has not been drawn yet.
To fix this. I added an offset in the geometry shader for the edge fixup. This make the artifact only visible on the border of the object if there is a very dense wire region. It's only visible in edge select mode since vertex and face center also hides the artifacts.
We can enable this only if AA is enabled but for now it's always enabled.
Diffstat (limited to 'source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl')
-rw-r--r-- | source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl index 64809a37d11..afd1e5a74a8 100644 --- a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl +++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl @@ -108,6 +108,12 @@ void doVertex(int v, vec4 pos) EmitVertex(); } +#ifdef ANTI_ALIASING +#define Z_OFFSET 0.008 +#else +#define Z_OFFSET 0.0 +#endif + void main() { /* First we detect which case we are in */ @@ -214,7 +220,7 @@ void main() } /* to not let face color bleed */ - faceColor = vec4(0.0); + faceColor.a = 0.0; /* we don't want other edges : make them far */ eData1 = vec4(1e10); @@ -231,7 +237,7 @@ void main() eData1.zw = pos[vbe]; doVertex(v, pPos[v]); - doVertex(v, pPos[v] + vec4(fixvec[v], 0.0, 0.0)); + doVertex(v, pPos[v] + vec4(fixvec[v], Z_OFFSET, 0.0)); /* Now one triangle only shade one edge * so we use the edge distance calculated @@ -247,19 +253,19 @@ void main() edgesBweight[2] = ebweight[vbe]; doVertex(vaf, pPos[vaf]); - doVertex(vaf, pPos[vaf] + vec4(fixvecaf[v], 0.0, 0.0)); + doVertex(vaf, pPos[vaf] + vec4(fixvecaf[v], Z_OFFSET, 0.0)); /* corner vertices should not draw edges but draw point only */ flag[2] = (vData[vbe].x << 8); #ifdef VERTEX_SELECTION doVertex(vaf, pPos[vaf]); - doVertex(vaf, pPos[vaf] + vec4(cornervec[vaf], 0.0, 0.0)); + doVertex(vaf, pPos[vaf] + vec4(cornervec[vaf], Z_OFFSET, 0.0)); #endif } /* finish the loop strip */ doVertex(2, pPos[2]); - doVertex(2, pPos[2] + vec4(fixvec[2], 0.0, 0.0)); + doVertex(2, pPos[2] + vec4(fixvec[2], Z_OFFSET, 0.0)); #endif } /* Harder case : compute visible edges vectors */ |