diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-05-30 13:02:05 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-05-30 13:02:05 +0300 |
commit | 671827549a3d013a2037e0b9814708214c59271c (patch) | |
tree | 7f15acb0cfbc4a5ad6b49cd072d9c7564f8df95b /source/blender/draw | |
parent | 8cc1154aa257f1cc7fe6c5e0d139cdc0afd6b604 (diff) |
3D View: Support light probe data clipping
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/intern/draw_common.c | 12 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_common.h | 3 | ||||
-rw-r--r-- | source/blender/draw/modes/object_mode.c | 33 | ||||
-rw-r--r-- | source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl | 4 |
4 files changed, 34 insertions, 18 deletions
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index de860607a2e..a2a3ea61a1e 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -549,10 +549,13 @@ struct DRWCallBuffer *buffer_instance_empty_axes(DRWPass *pass, return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_sized, geom); } -struct DRWCallBuffer *buffer_instance_outline(DRWPass *pass, struct GPUBatch *geom, int *baseid) +struct DRWCallBuffer *buffer_instance_outline(DRWPass *pass, + struct GPUBatch *geom, + int *baseid, + eGPUShaderConfig sh_cfg) { - GPUShader *sh_inst = GPU_shader_get_builtin_shader( - GPU_SHADER_INSTANCE_VARIYING_ID_VARIYING_SIZE); + GPUShader *sh_inst = GPU_shader_get_builtin_shader_with_config( + GPU_SHADER_INSTANCE_VARIYING_ID_VARIYING_SIZE, sh_cfg); DRW_shgroup_instance_format(g_formats.instance_outline, { @@ -564,6 +567,9 @@ struct DRWCallBuffer *buffer_instance_outline(DRWPass *pass, struct GPUBatch *ge DRWShadingGroup *grp = DRW_shgroup_create(sh_inst, pass); DRW_shgroup_uniform_int(grp, "baseId", baseid, 1); + if (sh_cfg == GPU_SHADER_CFG_CLIPPED) { + DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES); + } return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_outline, geom); } diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h index d0717888525..506061d79fe 100644 --- a/source/blender/draw/intern/draw_common.h +++ b/source/blender/draw/intern/draw_common.h @@ -156,7 +156,8 @@ struct DRWCallBuffer *buffer_instance(struct DRWPass *pass, struct DRWCallBuffer *buffer_instance_alpha(struct DRWShadingGroup *grp, struct GPUBatch *geom); struct DRWCallBuffer *buffer_instance_outline(struct DRWPass *pass, struct GPUBatch *geom, - int *baseid); + int *baseid, + eGPUShaderConfig sh_cfg); struct DRWCallBuffer *buffer_camera_instance(struct DRWPass *pass, struct GPUBatch *geom, eGPUShaderConfig sh_cfg); diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 8f0dc63fb1c..ed757424444 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -516,10 +516,11 @@ static void OBJECT_engine_init(void *vedata) NULL); /* Lightprobes */ - sh_data->lightprobe_grid = DRW_shader_create(datatoc_object_lightprobe_grid_vert_glsl, - NULL, - datatoc_gpu_shader_flat_id_frag_glsl, - NULL); + sh_data->lightprobe_grid = GPU_shader_create_from_arrays({ + .vert = (const char *[]){sh_cfg_data->lib, datatoc_object_lightprobe_grid_vert_glsl, NULL}, + .frag = (const char *[]){datatoc_gpu_shader_flat_id_frag_glsl, NULL}, + .defs = (const char *[]){sh_cfg_data->def, NULL}, + }); /* Loose Points */ sh_data->loose_points = GPU_shader_create_from_arrays({ @@ -1102,23 +1103,23 @@ static void OBJECT_cache_init(void *vedata) /* Cubemap */ g_data->lightprobes_cube_select = buffer_instance_outline( - pass, sphere, &g_data->id_ofs_prb_select); + pass, sphere, &g_data->id_ofs_prb_select, draw_ctx->sh_cfg); g_data->lightprobes_cube_select_dupli = buffer_instance_outline( - pass, sphere, &g_data->id_ofs_prb_select_dupli); + pass, sphere, &g_data->id_ofs_prb_select_dupli, draw_ctx->sh_cfg); g_data->lightprobes_cube_active = buffer_instance_outline( - pass, sphere, &g_data->id_ofs_prb_active); + pass, sphere, &g_data->id_ofs_prb_active, draw_ctx->sh_cfg); g_data->lightprobes_cube_transform = buffer_instance_outline( - pass, sphere, &g_data->id_ofs_prb_transform); + pass, sphere, &g_data->id_ofs_prb_transform, draw_ctx->sh_cfg); /* Planar */ g_data->lightprobes_planar_select = buffer_instance_outline( - pass, quad, &g_data->id_ofs_prb_select); + pass, quad, &g_data->id_ofs_prb_select, draw_ctx->sh_cfg); g_data->lightprobes_planar_select_dupli = buffer_instance_outline( - pass, quad, &g_data->id_ofs_prb_select_dupli); + pass, quad, &g_data->id_ofs_prb_select_dupli, draw_ctx->sh_cfg); g_data->lightprobes_planar_active = buffer_instance_outline( - pass, quad, &g_data->id_ofs_prb_active); + pass, quad, &g_data->id_ofs_prb_active, draw_ctx->sh_cfg); g_data->lightprobes_planar_transform = buffer_instance_outline( - pass, quad, &g_data->id_ofs_prb_transform); + pass, quad, &g_data->id_ofs_prb_transform, draw_ctx->sh_cfg); g_data->id_ofs_prb_select = 0; g_data->id_ofs_prb_select_dupli = 0; @@ -2500,7 +2501,8 @@ static void DRW_shgroup_lightprobe(OBJECT_Shaders *sh_data, OBJECT_StorageList *stl, OBJECT_PassList *psl, Object *ob, - ViewLayer *view_layer) + ViewLayer *view_layer, + const eGPUShaderConfig sh_cfg) { float *color; static float one = 1.0f; @@ -2560,6 +2562,9 @@ static void DRW_shgroup_lightprobe(OBJECT_Shaders *sh_data, 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_call_procedural_points(grp, cell_count, NULL); + if (sh_cfg == GPU_SHADER_CFG_CLIPPED) { + DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES); + } } else if (prb->type == LIGHTPROBE_TYPE_CUBE) { float draw_size = 1.0f; @@ -3319,7 +3324,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if (hide_object_extra) { break; } - DRW_shgroup_lightprobe(sh_data, stl, psl, ob, view_layer); + DRW_shgroup_lightprobe(sh_data, stl, psl, ob, view_layer, draw_ctx->sh_cfg); break; case OB_ARMATURE: { if ((v3d->flag2 & V3D_HIDE_OVERLAYS) || (v3d->overlay.flag & V3D_OVERLAY_HIDE_BONES) || diff --git a/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl b/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl index 61da94dd433..d27d55c3fd6 100644 --- a/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl +++ b/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl @@ -30,4 +30,8 @@ void main() gl_PointSize = 2.0f; finalId = uint(baseId + call_id); + +#ifdef USE_WORLD_CLIP_PLANES + world_clip_planes_calc_clip_distance(ws_cell_location); +#endif } |