diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2017-05-01 17:21:53 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2017-05-01 17:32:55 +0300 |
commit | d7d4bca23be91ec5b0ce562d47a34ee49dd337b8 (patch) | |
tree | 6184684f5300324294dbaa103522e7e817e3d6bd /source/blender/editors/gpencil/gpencil_paint.c | |
parent | 6ef497d401e5e7842d1e9d33e491672bb77d60e0 (diff) |
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_paint.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index b4092a73df8..6659510c6cc 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1862,25 +1862,21 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr) immUnbindProgram(); - format = immVertexFormat(); - const uint shdr_dashed_pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT); - const uint shdr_dashed_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR); float viewport_size[4]; glGetFloatv(GL_VIEWPORT, viewport_size); immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); - immUniform4f("color1", 1.0f, 0.39f, 0.39f, 0.78f); - immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f); + immUniformColor4f(1.0f, 0.39f, 0.39f, 0.78f); + immUniform1i("num_colors", 0); /* "simple" mode */ immUniform1f("dash_width", 12.0f); - immUniform1f("dash_width_on", 6.0f); + immUniform1f("dash_factor", 0.5f); - imm_draw_circle_wire_dashed(shdr_dashed_pos, shdr_dashed_origin, x, y, p->radius, - /* XXX Dashed shader gives bad results with sets of small segments currently, - * temp hack around the issue. :( */ - max_ii(8, p->radius / 2)); /* was fixed 40 */ + imm_draw_circle_wire(shdr_pos, x, y, p->radius, + /* XXX Dashed shader gives bad results with sets of small segments currently, + * temp hack around the issue. :( */ + max_ii(8, p->radius / 2)); /* was fixed 40 */ immUnbindProgram(); |