diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-07-15 21:10:45 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-07-15 21:10:45 +0300 |
commit | 058514aa0abfbbeb87a89d863a2cdc85b5bdb5c4 (patch) | |
tree | 5eeb9adf61396e50046f53f10a77d1fbb4a397e5 /source/blender/draw/engines/workbench/workbench_engine.c | |
parent | d4d810f817afc61618bec6f3b0a0ade5d0111d3c (diff) |
PointCloud: Initial rendering support for Workbench
Also includes outline overlays. Removes the temp overlay drawing
We make the geometry follow camera like billboards this uses less
geometry. Currently we use half octahedron for now. Goal would be
to use icospheres.
This patch also optimize the case when pointcloud has uniform radius.
However we should premultiply the radius prop by the default radius
beforehand to avoid a multiplication on CPU.
Using geometry instead of pseudo raytraced spheres is more scalable as
we can render as low as 1 or 2 triangle to a full half sphere and can
integrate easily in the render pipeline using a low amount of code.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D8301
Diffstat (limited to 'source/blender/draw/engines/workbench/workbench_engine.c')
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_engine.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c index 5b06cb03c59..5fff55e2f26 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.c +++ b/source/blender/draw/engines/workbench/workbench_engine.c @@ -130,6 +130,17 @@ static void workbench_cache_sculpt_populate(WORKBENCH_PrivateData *wpd, } } +BLI_INLINE void workbench_object_drawcall(DRWShadingGroup *grp, struct GPUBatch *geom, Object *ob) +{ + if (ob->type == OB_POINTCLOUD) { + /* Draw range to avoid drawcall batching messing up the instance attrib. */ + DRW_shgroup_call_instance_range(grp, ob, geom, 0, 0); + } + else { + DRW_shgroup_call(grp, geom, ob); + } +} + static void workbench_cache_texpaint_populate(WORKBENCH_PrivateData *wpd, Object *ob) { const DRWContextState *draw_ctx = DRW_context_state_get(); @@ -145,7 +156,7 @@ static void workbench_cache_texpaint_populate(WORKBENCH_PrivateData *wpd, Object SET_FLAG_FROM_TEST(state, imapaint->interp == IMAGEPAINT_INTERP_LINEAR, GPU_SAMPLER_FILTER); DRWShadingGroup *grp = workbench_image_setup(wpd, ob, 0, ima, NULL, state); - DRW_shgroup_call(grp, geom, ob); + workbench_object_drawcall(grp, geom, ob); } } else { @@ -157,7 +168,7 @@ static void workbench_cache_texpaint_populate(WORKBENCH_PrivateData *wpd, Object continue; } DRWShadingGroup *grp = workbench_image_setup(wpd, ob, i + 1, NULL, NULL, 0); - DRW_shgroup_call(grp, geoms[i], ob); + workbench_object_drawcall(grp, geoms[i], ob); } } } @@ -194,7 +205,7 @@ static void workbench_cache_common_populate(WORKBENCH_PrivateData *wpd, if (geom) { DRWShadingGroup *grp = workbench_material_setup(wpd, ob, 0, color_type, r_transp); - DRW_shgroup_call(grp, geom, ob); + workbench_object_drawcall(grp, geom, ob); } } else { @@ -207,7 +218,7 @@ static void workbench_cache_common_populate(WORKBENCH_PrivateData *wpd, continue; } DRWShadingGroup *grp = workbench_material_setup(wpd, ob, i + 1, color_type, r_transp); - DRW_shgroup_call(grp, geoms[i], ob); + workbench_object_drawcall(grp, geoms[i], ob); } } } @@ -450,7 +461,7 @@ void workbench_cache_finish(void *ved) /* TODO don't free reuse next redraw. */ for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { - for (int k = 0; k < 2; k++) { + for (int k = 0; k < WORKBENCH_DATATYPE_MAX; k++) { if (wpd->prepass[i][j][k].material_hash) { BLI_ghash_free(wpd->prepass[i][j][k].material_hash, NULL, NULL); wpd->prepass[i][j][k].material_hash = NULL; |