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:
authorAntonioya <blendergit@gmail.com>2019-03-17 21:47:31 +0300
committerAntonioya <blendergit@gmail.com>2019-03-17 21:47:56 +0300
commit6577618d5bb93792c805e0c22e4de1a015ee25d5 (patch)
tree05d5056646b3aefd8be21bb1ff314e4373865683 /source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl
parent887d052e56a515145f4dd7433e49c91c5d149169 (diff)
GPencil: Changes in Fill and new 3D Cursor View Plane
This commit groups several options that were tested in grease pencil branch: - Changes to fill algorithms and improves, specially in small areas and stroke corners. New options has been added in order to define how the fill is working and internally there are optimizations in detect the small areas in the extremes. Kudos to @charlie for coding this fill improvements. - New 3D cursor view plane option. Now it's possible to lock the drawing plane to the 3D cursor and use the 3D cursor orientation. This allows more flexibility when you are drawing and reduce the need to create geometry to draw over surfaces. - Canvas Grid now can be locked to 3D cursor. - New option to reproject stroke using 3D cursor. - Small tweaks and fixes. Changes reviewed by @pepeland and @mendio
Diffstat (limited to 'source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl30
1 files changed, 26 insertions, 4 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl b/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl
index 3de1bd838b3..6c7e2d17e06 100644
--- a/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl
@@ -1,6 +1,9 @@
uniform mat4 ModelViewProjectionMatrix;
uniform vec2 Viewport;
uniform int xraymode;
+uniform int caps_start;
+uniform int caps_end;
+uniform int fill_stroke;
layout(lines_adjacency) in;
layout(triangle_strip, max_vertices = 13) out;
@@ -15,6 +18,8 @@ out vec2 mTexCoord;
#define GP_XRAY_3DSPACE 1
#define GP_XRAY_BACK 2
+#define GPENCIL_FLATCAP 1
+
/* project 3d point to 2d on screen space */
vec2 toScreenSpace(vec4 vertex)
{
@@ -37,6 +42,22 @@ float getZdepth(vec4 point)
/* in front by default */
return 0.0;
}
+
+/* check equality but with a small tolerance */
+bool is_equal(vec4 p1, vec4 p2)
+{
+ float limit = 0.0001;
+ float x = abs(p1.x - p2.x);
+ float y = abs(p1.y - p2.y);
+ float z = abs(p1.z - p2.z);
+
+ if ((x < limit) && (y < limit) && (z < limit)) {
+ return true;
+ }
+
+ return false;
+}
+
void main(void)
{
float MiterLimit = 0.75;
@@ -134,10 +155,11 @@ void main(void)
}
/* generate the start endcap (alpha < 0 used as endcap flag)*/
- if (P0 == P2) {
+ float extend = (fill_stroke > 0) ? 2 : 1 ;
+ if ((caps_start != GPENCIL_FLATCAP) && is_equal(P0,P2)) {
mTexCoord = vec2(1, 0.5);
mColor = vec4(finalColor[1].rgb, finalColor[1].a * -1.0) ;
- vec2 svn1 = normalize(sp1 - sp2) * length_a * 4.0;
+ vec2 svn1 = normalize(sp1 - sp2) * length_a * 4.0 * extend;
gl_Position = vec4((sp1 + svn1) / Viewport, getZdepth(P1), 1.0);
EmitVertex();
@@ -174,7 +196,7 @@ void main(void)
EmitVertex();
/* generate the end endcap (alpha < 0 used as endcap flag)*/
- if (P1 == P3) {
+ if ((caps_end != GPENCIL_FLATCAP) && is_equal(P1,P3)) {
mTexCoord = vec2(0, 1);
mColor = vec4(finalColor[2].rgb, finalColor[2].a * -1.0) ;
gl_Position = vec4((sp2 + (length_b * 2.0) * miter_b) / Viewport, getZdepth(P2), 1.0);
@@ -187,7 +209,7 @@ void main(void)
mTexCoord = vec2(1, 0.5);
mColor = vec4(finalColor[2].rgb, finalColor[2].a * -1.0) ;
- vec2 svn2 = normalize(sp2 - sp1) * length_b * 4.0;
+ vec2 svn2 = normalize(sp2 - sp1) * length_b * 4.0 * extend;
gl_Position = vec4((sp2 + svn2) / Viewport, getZdepth(P2), 1.0);
EmitVertex();
}