3D View: Support light probe data clipping
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) ||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -1319,13 +1319,17 @@ GPUShader *GPU_shader_get_builtin_shader_with_config(eGPUBuiltinShader shader,
|
||||
GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA,
|
||||
GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR,
|
||||
GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED,
|
||||
|
||||
GPU_SHADER_3D_GROUNDLINE,
|
||||
GPU_SHADER_3D_GROUNDPOINT,
|
||||
GPU_SHADER_DISTANCE_LINES,
|
||||
GPU_SHADER_INSTANCE_EDGES_VARIYING_COLOR,
|
||||
GPU_SHADER_3D_FLAT_SELECT_ID,
|
||||
GPU_SHADER_3D_UNIFORM_SELECT_ID) ||
|
||||
ELEM(shader, GPU_SHADER_3D_FLAT_COLOR, GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR));
|
||||
ELEM(shader,
|
||||
GPU_SHADER_3D_FLAT_COLOR,
|
||||
GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR,
|
||||
GPU_SHADER_INSTANCE_VARIYING_ID_VARIYING_SIZE));
|
||||
const char *world_clip_lib = datatoc_gpu_shader_cfg_world_clip_lib_glsl;
|
||||
const char *world_clip_def = "#define USE_WORLD_CLIP_PLANES\n";
|
||||
/* In rare cases geometry shaders calculate clipping themselves. */
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
|
||||
uniform mat4 ViewProjectionMatrix;
|
||||
#ifdef USE_WORLD_CLIP_PLANES
|
||||
uniform mat4 ModelMatrix;
|
||||
#endif
|
||||
uniform int baseId;
|
||||
|
||||
/* ---- Instantiated Attrs ---- */
|
||||
@@ -18,6 +21,11 @@ flat out uint finalId;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ViewProjectionMatrix * InstanceModelMatrix * vec4(pos * size, 1.0);
|
||||
vec4 pos_4d = vec4(pos * size, 1.0);
|
||||
gl_Position = ViewProjectionMatrix * InstanceModelMatrix * pos_4d;
|
||||
finalId = uint(baseId + callId);
|
||||
|
||||
#ifdef USE_WORLD_CLIP_PLANES
|
||||
world_clip_planes_calc_clip_distance((ModelMatrix * InstanceModelMatrix * pos_4d).xyz);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user