diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-03-29 13:40:26 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-04-01 20:27:13 +0400 |
commit | 3ed49a810d469174d2c0233dcb03d249adc60056 (patch) | |
tree | 6e80355cf213b928c9d292ebf894095aad687d8e /source/blender/editors/space_view3d/drawobject.c | |
parent | ad7980a51a7e1c2492691e403ffdf84a29081c35 (diff) |
Make matcaps suck less
This commit does various changes for matcaps:
One is taking advantage of drawing with pbvh (which would only happen
with dyntopo previously) and drawing with partial redraw during
sculpting.
The second one is support for masks. To make this work in the special
case of multires, which uses flat shading, I use the only available flat
shaded builtins in OpenGL 2.0 which are color and secondary color.
Abusing colors in that way is also essential for flat shading to work if
we are to use pbvh draw in multires, since it is the color that is being
interpolated flatly, not the normal (which can only interpolated
smoothly). The pbvh drawing code for multires used last triangle
element's normal to compute the shading which would only produce smooth
results. This could change if we did the shading in the vertex shader
for flat shaded primitives, but this is more complex and makes it harder
to have one shader to rule the mole.
Also increased the brightness of the default diffuse color for
sculpting. This should be useful since artists like to tweak the
lighting settings and it will give them the full dynamic range of the
lights, but also it helps with correct brightness of sculpted matcaps.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D435
Diffstat (limited to 'source/blender/editors/space_view3d/drawobject.c')
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index a8abd08a4cc..84b39356089 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -3454,6 +3454,8 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D else if (((is_obact && ob->mode & OB_MODE_TEXTURE_PAINT)) || check_object_draw_texture(scene, v3d, dt)) { + bool draw_loose = true; + if ((v3d->flag & V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) && (base->flag & SELECT) && @@ -3464,9 +3466,33 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } if (draw_glsl_material(scene, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) { + Paint *p; + glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); + /* this will get ignored mostly, will only be relevant for matcaps */ + glColor3f(1.0, 1.0, 1.0); + + if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && (p = BKE_paint_get_active(scene))) { + GPUVertexAttribs gattribs; + float planes[4][4]; + float (*fpl)[4] = NULL; + int fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING); + + if (ob->sculpt->partial_redraw) { + if (ar->do_draw & RGN_DRAW_PARTIAL) { + sculpt_get_redraw_planes(planes, ar, rv3d, ob); + fpl = planes; + ob->sculpt->partial_redraw = 0; + } + } + + GPU_enable_material(1, &gattribs); + dm->drawFacesSolid(dm, fpl, fast, NULL); + draw_loose = false; + } + else + dm->drawFacesGLSL(dm, GPU_enable_material); - dm->drawFacesGLSL(dm, GPU_enable_material); // if (BKE_bproperty_object_get(ob, "Text")) // XXX draw_mesh_text(ob, 1); GPU_disable_material(); @@ -3480,7 +3506,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D draw_mesh_textured(scene, v3d, rv3d, ob, dm, draw_flags); } - if (!(draw_flags & DRAW_FACE_SELECT)) { + if (draw_loose && !(draw_flags & DRAW_FACE_SELECT)) { if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { if ((dflag & DRAW_CONSTCOLOR) == 0) { glColor3ubv(ob_wire_col); |