diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-12-02 03:40:58 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-12-02 15:15:52 +0300 |
commit | 9516921c05bd9fee5c94942eb8e38f47ba7e4351 (patch) | |
tree | da007fc17bc6a02f849dae2e8f76f5ab304fe4dc /source/blender/draw/intern/draw_cache_impl_lattice.c | |
parent | 1f6c3699a836d485ed37f443cd0fcd19e978dbb6 (diff) |
Overlay Engine: Refactor & Cleanup
This is the unification of all overlays into one overlay engine as described in T65347.
I went over all the code making it more future proof with less hacks and removing old / not relevent parts.
Goals / Acheivements:
- Remove internal shader usage (only drw shaders)
- Remove viewportSize and viewportSizeInv and put them in gloabl ubo
- Fixed some drawing issues: Missing probe option and Missing Alt+B clipping of some shader
- Remove old (legacy) shaders dependancy (not using view UBO).
- Less shader variation (less compilation time at first load and less patching needed for vulkan)
- removed some geom shaders when I could
- Remove static e_data (except shaders storage where it is OK)
- Clear the way to fix some anoying limitations (dithered transparency, background image compositing etc...)
- Wireframe drawing now uses the same batching capabilities as workbench & eevee (indirect drawing).
- Reduced complexity, removed ~3000 Lines of code in draw (also removed a lot of unused shader in GPU).
- Post AA to avoid complexity and cost of MSAA.
Remaining issues:
- ~~Armature edits, overlay toggles, (... others?) are not refreshing viewport after AA is complete~~
- FXAA is not the best for wires, maybe investigate SMAA
- Maybe do something more temporally stable for AA.
- ~~Paint overlays are not working with AA.~~
- ~~infront objects are difficult to select.~~
- ~~the infront wires sometimes goes through they solid counterpart (missing clear maybe?) (toggle overlays on-off when using infront+wireframe overlay in solid shading)~~
Note: I made some decision to change slightly the appearance of some objects to simplify their drawing. Namely the empty arrows end (which is now hollow/wire) and distance points of the cameras/spots being done by lines.
Reviewed By: jbakker
Differential Revision: https://developer.blender.org/D6296
Diffstat (limited to 'source/blender/draw/intern/draw_cache_impl_lattice.c')
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_lattice.c | 75 |
1 files changed, 7 insertions, 68 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.c b/source/blender/draw/intern/draw_cache_impl_lattice.c index 01cd2b52ae3..8e5e22a4bcd 100644 --- a/source/blender/draw/intern/draw_cache_impl_lattice.c +++ b/source/blender/draw/intern/draw_cache_impl_lattice.c @@ -212,62 +212,6 @@ static const BPoint *lattice_render_data_vert_bpoint(const LatticeRenderData *rd return &rdata->bp[vert_idx]; } -/* TODO, move into shader? */ -static void rgb_from_weight(float r_rgb[3], const float weight) -{ - const float blend = ((weight / 2.0f) + 0.5f); - - if (weight <= 0.25f) { /* blue->cyan */ - r_rgb[0] = 0.0f; - r_rgb[1] = blend * weight * 4.0f; - r_rgb[2] = blend; - } - else if (weight <= 0.50f) { /* cyan->green */ - r_rgb[0] = 0.0f; - r_rgb[1] = blend; - r_rgb[2] = blend * (1.0f - ((weight - 0.25f) * 4.0f)); - } - else if (weight <= 0.75f) { /* green->yellow */ - r_rgb[0] = blend * ((weight - 0.50f) * 4.0f); - r_rgb[1] = blend; - r_rgb[2] = 0.0f; - } - else if (weight <= 1.0f) { /* yellow->red */ - r_rgb[0] = blend; - r_rgb[1] = blend * (1.0f - ((weight - 0.75f) * 4.0f)); - r_rgb[2] = 0.0f; - } - else { - /* exceptional value, unclamped or nan, - * avoid uninitialized memory use */ - r_rgb[0] = 1.0f; - r_rgb[1] = 0.0f; - r_rgb[2] = 1.0f; - } -} - -static void lattice_render_data_weight_col_get(const LatticeRenderData *rdata, - const int vert_idx, - const int actdef, - float r_col[4]) -{ - if (actdef > -1) { - float weight = defvert_find_weight(rdata->dvert + vert_idx, actdef); - - if (U.flag & USER_CUSTOM_RANGE) { - BKE_colorband_evaluate(&U.coba_weight, weight, r_col); - } - else { - rgb_from_weight(r_col, weight); - } - - r_col[3] = 1.0f; - } - else { - zero_v4(r_col); - } -} - /* ---------------------------------------------------------------------- */ /* Lattice GPUBatch Cache */ @@ -402,18 +346,14 @@ static GPUVertBuf *lattice_batch_cache_get_pos(LatticeRenderData *rdata, BLI_assert(rdata->types & LR_DATATYPE_VERT); if (cache->pos == NULL) { - static GPUVertFormat format = {0}; - static struct { + GPUVertFormat format = {0}; + struct { uint pos, col; } attr_id; - GPU_vertformat_clear(&format); - - /* initialize vertex format */ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); - if (use_weight) { - attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); + attr_id.col = GPU_vertformat_attr_add(&format, "weight", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); } const int vert_len = lattice_render_data_verts_len_get(rdata); @@ -425,11 +365,10 @@ static GPUVertBuf *lattice_batch_cache_get_pos(LatticeRenderData *rdata, GPU_vertbuf_attr_set(cache->pos, attr_id.pos, i, bp->vec); if (use_weight) { - float w_col[4]; - lattice_render_data_weight_col_get(rdata, i, actdef, w_col); - w_col[3] = 1.0f; - - GPU_vertbuf_attr_set(cache->pos, attr_id.col, i, w_col); + const float no_active_weight = 666.0f; + float weight = (actdef > -1) ? defvert_find_weight(rdata->dvert + i, actdef) : + no_active_weight; + GPU_vertbuf_attr_set(cache->pos, attr_id.col, i, &weight); } } } |