From d63829117c21c0d926cf0a9df645c3ed5cd8057a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 1 Mar 2018 19:27:38 +0100 Subject: DRW: Refactor simple instancing. Instead of creating a new instancing shading group without attrib, we now have instancing calls. The benefits is that they can be culled. They can be used in conjuction with the standard and generate calls but shader must support it (which is generally not the case). We store a pointer to the actual count so that the number can be tweaked between redraw. This will makes multi layer rendering more efficient. --- source/blender/draw/modes/object_mode.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source/blender/draw/modes/object_mode.c') diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 0ae5352f4c9..ded2bc68062 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -1547,6 +1547,7 @@ typedef struct OBJECT_LightProbeEngineData { float increment_y[3]; float increment_z[3]; float corner[3]; + unsigned int cell_count; } OBJECT_LightProbeEngineData; static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl, Object *ob, ViewLayer *view_layer) @@ -1600,9 +1601,8 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl mul_m4_v3(ob->obmat, prb_data->increment_z); sub_v3_v3(prb_data->increment_z, prb_data->corner); - DRWShadingGroup *grp = DRW_shgroup_instance_create(e_data.lightprobe_grid_sh, psl->lightprobes, - DRW_cache_sphere_get(), NULL); - DRW_shgroup_set_instance_count(grp, prb->grid_resolution_x * prb->grid_resolution_y * prb->grid_resolution_z); + prb_data->cell_count = prb->grid_resolution_x * prb->grid_resolution_y * prb->grid_resolution_z; + DRWShadingGroup *grp = DRW_shgroup_create(e_data.lightprobe_grid_sh, psl->lightprobes); DRW_shgroup_uniform_vec4(grp, "color", color, 1); DRW_shgroup_uniform_vec3(grp, "corner", prb_data->corner, 1); DRW_shgroup_uniform_vec3(grp, "increment_x", prb_data->increment_x, 1); @@ -1610,6 +1610,7 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl DRW_shgroup_uniform_vec3(grp, "increment_z", prb_data->increment_z, 1); DRW_shgroup_uniform_ivec3(grp, "grid_resolution", &prb->grid_resolution_x, 1); DRW_shgroup_uniform_float(grp, "sphere_size", &prb->data_draw_size, 1); + DRW_shgroup_call_instances_add(grp, DRW_cache_sphere_get(), NULL, &prb_data->cell_count); } else if (prb->type == LIGHTPROBE_TYPE_CUBE) { prb_data->draw_size = prb->data_draw_size * 0.1f; -- cgit v1.2.3