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:
authorBastien Montagne <montagne29@wanadoo.fr>2017-05-01 17:21:53 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2017-05-01 17:32:55 +0300
commitd7d4bca23be91ec5b0ce562d47a34ee49dd337b8 (patch)
tree6184684f5300324294dbaa103522e7e817e3d6bd /source/blender/editors/sculpt_paint
parent6ef497d401e5e7842d1e9d33e491672bb77d60e0 (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/sculpt_paint')
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index b6c4febe607..e53cf05bb15 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -169,9 +169,7 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
glEnable(GL_LINE_SMOOTH);
- VertexFormat *format = immVertexFormat();
- unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
- unsigned int line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
+ uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
@@ -179,23 +177,20 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
glGetFloatv(GL_VIEWPORT, viewport_size);
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
+ immUniform1i("num_colors", 2); /* "advanced" mode */
const float alpha = (float)paint->paint_cursor_col[3] / 255.0f;
- immUniform4f("color1", 0.0f, 0.0f, 0.0f, alpha);
- immUniform4f("color2", 1.0f, 1.0f, 1.0f, alpha);
+ immUniformArray4fv("colors", (float *)(float[][4]){{0.0f, 0.0f, 0.0f, alpha}, {1.0f, 1.0f, 1.0f, alpha}}, 2);
immUniform1f("dash_width", 6.0f);
- immUniform1f("dash_width_on", 3.0f);
immBegin(PRIM_LINES, 2);
if (stroke->constrain_line) {
- immAttrib2f(line_origin, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
- immVertex2f(pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
- immVertex2f(pos, stroke->constrained_pos[0], stroke->constrained_pos[1]);
+ immVertex2f(shdr_pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
+ immVertex2f(shdr_pos, stroke->constrained_pos[0], stroke->constrained_pos[1]);
}
else {
- immAttrib2f(line_origin, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
- immVertex2f(pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
- immVertex2f(pos, x, y);
+ immVertex2f(shdr_pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
+ immVertex2f(shdr_pos, x, y);
}
immEnd();