[Bf-blender-cvs] [bd6cc282d28] master: Fix T61573 GPencil: Annotation thickness doesn't work with on OSX
Clément Foucault
noreply at git.blender.org
Mon Jun 29 14:19:58 CEST 2020
Commit: bd6cc282d28f58766d84d78d4400d3020fe4cb10
Author: Clément Foucault
Date: Sun Jun 28 16:29:27 2020 +0200
Branches: master
https://developer.blender.org/rBbd6cc282d28f58766d84d78d4400d3020fe4cb10
Fix T61573 GPencil: Annotation thickness doesn't work with on OSX
This fixes the issue by using the polyline shader but this does not gives
the best results.
A better way would be to have a dedicated shader for the lines to avoid
the line break at every angle change.
===================================================================
M source/blender/editors/gpencil/annotate_draw.c
===================================================================
diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c
index 22df7bbbf31..089f41b4a66 100644
--- a/source/blender/editors/gpencil/annotate_draw.c
+++ b/source/blender/editors/gpencil/annotate_draw.c
@@ -172,9 +172,14 @@ static void annotation_draw_stroke_buffer(bGPdata *gps,
float oldpressure = points[0].pressure;
/* draw stroke curve */
- GPU_line_width(max_ff(oldpressure * thickness, 1.0));
+ immBindBuiltinProgram(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR);
+
+ float viewport[4];
+ GPU_viewport_size_get_f(viewport);
+ immUniform2fv("viewportSize", &viewport[2]);
+
+ immUniform1f("lineWidth", max_ff(oldpressure * thickness, 1.0) * U.pixelsize);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3fvAlpha(ink, ink[3]);
immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints);
@@ -193,7 +198,7 @@ static void annotation_draw_stroke_buffer(bGPdata *gps,
immEnd();
draw_points = 0;
- GPU_line_width(max_ff(pt->pressure * thickness, 1.0f));
+ immUniform1f("lineWidth", max_ff(pt->pressure * thickness, 1.0) * U.pixelsize);
immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints - i + 1);
/* need to roll-back one point to ensure that there are no gaps in the stroke */
@@ -327,11 +332,17 @@ static void annotation_draw_stroke_3d(
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR);
+
+ float viewport[4];
+ GPU_viewport_size_get_f(viewport);
+ immUniform2fv("viewportSize", &viewport[2]);
+
+ immUniform1f("lineWidth", max_ff(curpressure * thickness, 1.0) * U.pixelsize);
+
immUniformColor3fvAlpha(ink, ink[3]);
/* draw stroke curve */
- GPU_line_width(max_ff(curpressure * thickness, 1.0f));
immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints + cyclic_add);
const bGPDspoint *pt = points;
for (int i = 0; i < totpoints; i++, pt++) {
@@ -351,7 +362,7 @@ static void annotation_draw_stroke_3d(
draw_points = 0;
curpressure = pt->pressure;
- GPU_line_width(max_ff(curpressure * thickness, 1.0f));
+ immUniform1f("lineWidth", max_ff(curpressure * thickness, 1.0) * U.pixelsize);
immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints - i + 1 + cyclic_add);
/* need to roll-back one point to ensure that there are no gaps in the stroke */
@@ -424,11 +435,15 @@ static void annotation_draw_stroke_2d(const bGPDspoint *points,
}
else {
/* draw stroke curve */
- GPU_line_width(max_ff(oldpressure * thickness, 1.0));
-
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR);
immUniformColor3fvAlpha(ink, ink[3]);
+ float viewport[4];
+ GPU_viewport_size_get_f(viewport);
+ immUniform2fv("viewportSize", &viewport[2]);
+
+ immUniform1f("lineWidth", max_ff(oldpressure * thickness, 1.0) * U.pixelsize);
+
immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints);
for (int i = 0; i < totpoints; i++) {
@@ -448,7 +463,8 @@ static void annotation_draw_stroke_2d(const bGPDspoint *points,
immEnd();
draw_points = 0;
- GPU_line_width(max_ff(pt->pressure * thickness, 1.0f));
+ immUniform1f("lineWidth", max_ff(pt->pressure * thickness, 1.0) * U.pixelsize);
+
immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints - i + 1);
/* need to roll-back one point to ensure that there are no gaps in the stroke */
@@ -683,9 +699,6 @@ static void annotation_draw_data_layers(
continue;
}
- /* set basic stroke thickness */
- GPU_line_width(lthick);
-
/* Add layer drawing settings to the set of "draw flags"
* NOTE: If the setting doesn't apply, it *must* be cleared,
* as dflag's carry over from the previous layer
More information about the Bf-blender-cvs
mailing list