diff options
Diffstat (limited to 'source/blender/draw/engines')
12 files changed, 425 insertions, 1 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_engine.cc b/source/blender/draw/engines/overlay/overlay_engine.cc index bbcae92561d..c2c4706138f 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.cc +++ b/source/blender/draw/engines/overlay/overlay_engine.cc @@ -16,6 +16,7 @@ #include "UI_interface.h" +#include "BKE_duplilist.h" #include "BKE_object.h" #include "BKE_paint.h" @@ -204,6 +205,7 @@ static void OVERLAY_cache_init(void *vedata) } OVERLAY_antialiasing_cache_init(data); OVERLAY_armature_cache_init(data); + OVERLAY_viewer_attribute_cache_init(data); OVERLAY_background_cache_init(data); OVERLAY_fade_cache_init(data); OVERLAY_mode_transfer_cache_init(data); @@ -300,8 +302,12 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) } const DRWContextState *draw_ctx = DRW_context_state_get(); + DupliObject *dupli_object = DRW_object_get_dupli(ob); + Object *dupli_parent = DRW_object_get_dupli_parent(ob); const bool is_select = DRW_state_is_select(); const bool renderable = DRW_object_is_renderable(ob); + const bool is_preview = dupli_object != nullptr && + dupli_object->preview_base_geometry != nullptr; const bool in_pose_mode = ob->type == OB_ARMATURE && OVERLAY_armature_is_pose_mode(ob, draw_ctx); const bool in_edit_mode = overlay_object_is_edit_mode(pd, ob); const bool is_instance = (ob->base_flag & BASE_FROM_DUPLI); @@ -313,7 +319,8 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) (pd->ctx_mode == CTX_MODE_PARTICLE); const bool in_paint_mode = (ob == draw_ctx->obact) && (draw_ctx->object_mode & OB_MODE_ALL_PAINT); - const bool in_sculpt_curve_mode = (ob == draw_ctx->obact) && + const bool in_sculpt_curve_mode = (ob == draw_ctx->obact || + (is_preview && dupli_parent == draw_ctx->obact)) && (draw_ctx->object_mode & OB_MODE_SCULPT_CURVES); const bool in_sculpt_mode = (ob == draw_ctx->obact) && (ob->sculpt != nullptr) && (ob->sculpt->mode_type == OB_MODE_SCULPT); @@ -374,6 +381,12 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) OVERLAY_pose_cache_populate(data, ob); } + if (pd->overlay.flag & V3D_OVERLAY_VIEWER_ATTRIBUTE) { + if (is_preview) { + OVERLAY_viewer_attribute_cache_populate(data, ob); + } + } + if (ob->type == OB_VOLUME) { OVERLAY_volume_cache_populate(data, ob); } @@ -627,6 +640,9 @@ static void OVERLAY_draw_scene(void *vedata) OVERLAY_metaball_draw(data); OVERLAY_gpencil_draw(data); OVERLAY_extra_draw(data); + if (pd->overlay.flag & V3D_OVERLAY_VIEWER_ATTRIBUTE) { + OVERLAY_viewer_attribute_draw(data); + } if (DRW_state_is_fbo()) { GPU_framebuffer_bind(fbl->overlay_color_only_fb); diff --git a/source/blender/draw/engines/overlay/overlay_private.hh b/source/blender/draw/engines/overlay/overlay_private.hh index 0a783c44029..b1118e084a6 100644 --- a/source/blender/draw/engines/overlay/overlay_private.hh +++ b/source/blender/draw/engines/overlay/overlay_private.hh @@ -61,6 +61,7 @@ typedef struct OVERLAY_PassList { DRWPass *armature_ps[2]; DRWPass *armature_bone_select_ps; DRWPass *armature_transp_ps[2]; + DRWPass *attribute_ps; DRWPass *background_ps; DRWPass *clipping_frustum_ps; DRWPass *edit_curve_wire_ps[2]; @@ -284,6 +285,12 @@ typedef struct OVERLAY_PrivateData { DRWShadingGroup *pointcloud_dots_grp; DRWShadingGroup *sculpt_mask_grp; DRWShadingGroup *sculpt_curves_selection_grp; + DRWShadingGroup *viewer_attribute_curve_grp; + DRWShadingGroup *viewer_attribute_curves_grp; + DRWShadingGroup *viewer_attribute_mesh_grp; + DRWShadingGroup *viewer_attribute_pointcloud_grp; + DRWShadingGroup *viewer_attribute_instance_grp; + DRWShadingGroup *viewer_attribute_instance_pointcloud_grp; DRWShadingGroup *volume_selection_surface_grp; DRWShadingGroup *wires_grp[2][2]; /* With and without coloring. */ DRWShadingGroup *wires_all_grp[2][2]; /* With and without coloring. */ @@ -678,6 +685,10 @@ void OVERLAY_sculpt_curves_cache_init(OVERLAY_Data *vedata); void OVERLAY_sculpt_curves_cache_populate(OVERLAY_Data *vedata, Object *ob); void OVERLAY_sculpt_curves_draw(OVERLAY_Data *vedata); +void OVERLAY_viewer_attribute_cache_init(OVERLAY_Data *vedata); +void OVERLAY_viewer_attribute_cache_populate(OVERLAY_Data *vedata, Object *object); +void OVERLAY_viewer_attribute_draw(OVERLAY_Data *vedata); + void OVERLAY_wireframe_init(OVERLAY_Data *vedata); void OVERLAY_wireframe_cache_init(OVERLAY_Data *vedata); void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, @@ -745,6 +756,7 @@ GPUShader *OVERLAY_shader_image(void); GPUShader *OVERLAY_shader_motion_path_line(void); GPUShader *OVERLAY_shader_motion_path_vert(void); GPUShader *OVERLAY_shader_uniform_color(void); +GPUShader *OVERLAY_shader_uniform_color_pointcloud(void); GPUShader *OVERLAY_shader_outline_prepass(bool use_wire); GPUShader *OVERLAY_shader_outline_prepass_curves(void); GPUShader *OVERLAY_shader_outline_prepass_gpencil(void); @@ -761,6 +773,10 @@ GPUShader *OVERLAY_shader_particle_dot(void); GPUShader *OVERLAY_shader_particle_shape(void); GPUShader *OVERLAY_shader_sculpt_mask(void); GPUShader *OVERLAY_shader_sculpt_curves_selection(void); +GPUShader *OVERLAY_shader_viewer_attribute_curve(void); +GPUShader *OVERLAY_shader_viewer_attribute_curves(void); +GPUShader *OVERLAY_shader_viewer_attribute_mesh(void); +GPUShader *OVERLAY_shader_viewer_attribute_pointcloud(void); GPUShader *OVERLAY_shader_volume_velocity(bool use_needle, bool use_mac); GPUShader *OVERLAY_shader_volume_gridlines(bool color_with_flags, bool color_range); GPUShader *OVERLAY_shader_wireframe(bool custom_bias); diff --git a/source/blender/draw/engines/overlay/overlay_shader.cc b/source/blender/draw/engines/overlay/overlay_shader.cc index b0a6926a57f..b7e5e8c56b7 100644 --- a/source/blender/draw/engines/overlay/overlay_shader.cc +++ b/source/blender/draw/engines/overlay/overlay_shader.cc @@ -93,6 +93,11 @@ typedef struct OVERLAY_Shaders { GPUShader *sculpt_mask; GPUShader *sculpt_curves_selection; GPUShader *uniform_color; + GPUShader *uniform_color_pointcloud; + GPUShader *viewer_attribute_mesh; + GPUShader *viewer_attribute_pointcloud; + GPUShader *viewer_attribute_curve; + GPUShader *viewer_attribute_curves; GPUShader *volume_velocity_needle_sh; GPUShader *volume_velocity_mac_sh; GPUShader *volume_velocity_sh; @@ -818,6 +823,55 @@ GPUShader *OVERLAY_shader_sculpt_curves_selection(void) return sh_data->sculpt_curves_selection; } +GPUShader *OVERLAY_shader_viewer_attribute_mesh(void) +{ + const DRWContextState *draw_ctx = DRW_context_state_get(); + OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; + if (!sh_data->viewer_attribute_mesh) { + sh_data->viewer_attribute_mesh = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED ? "overlay_viewer_attribute_mesh_clipped" : + "overlay_viewer_attribute_mesh"); + } + return sh_data->viewer_attribute_mesh; +} + +GPUShader *OVERLAY_shader_viewer_attribute_pointcloud(void) +{ + const DRWContextState *draw_ctx = DRW_context_state_get(); + OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; + if (!sh_data->viewer_attribute_pointcloud) { + sh_data->viewer_attribute_pointcloud = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED ? + "overlay_viewer_attribute_pointcloud_clipped" : + "overlay_viewer_attribute_pointcloud"); + } + return sh_data->viewer_attribute_pointcloud; +} + +GPUShader *OVERLAY_shader_viewer_attribute_curve(void) +{ + const DRWContextState *draw_ctx = DRW_context_state_get(); + OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; + if (!sh_data->viewer_attribute_curve) { + sh_data->viewer_attribute_curve = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED ? "overlay_viewer_attribute_curve_clipped" : + "overlay_viewer_attribute_curve"); + } + return sh_data->viewer_attribute_curve; +} + +GPUShader *OVERLAY_shader_viewer_attribute_curves(void) +{ + const DRWContextState *draw_ctx = DRW_context_state_get(); + OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; + if (!sh_data->viewer_attribute_curves) { + sh_data->viewer_attribute_curves = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED ? "overlay_viewer_attribute_curves_clipped" : + "overlay_viewer_attribute_curves"); + } + return sh_data->viewer_attribute_curves; +} + struct GPUShader *OVERLAY_shader_uniform_color(void) { const DRWContextState *draw_ctx = DRW_context_state_get(); @@ -829,6 +883,18 @@ struct GPUShader *OVERLAY_shader_uniform_color(void) return sh_data->uniform_color; } +struct GPUShader *OVERLAY_shader_uniform_color_pointcloud() +{ + const DRWContextState *draw_ctx = DRW_context_state_get(); + OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; + if (!sh_data->uniform_color_pointcloud) { + sh_data->uniform_color_pointcloud = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg ? "overlay_uniform_color_pointcloud_clipped" : + "overlay_uniform_color_pointcloud"); + } + return sh_data->uniform_color_pointcloud; +} + struct GPUShader *OVERLAY_shader_volume_velocity(bool use_needle, bool use_mac) { OVERLAY_Shaders *sh_data = &e_data.sh_data[0]; diff --git a/source/blender/draw/engines/overlay/overlay_viewer_attribute.cc b/source/blender/draw/engines/overlay/overlay_viewer_attribute.cc new file mode 100644 index 00000000000..7e1949c5261 --- /dev/null +++ b/source/blender/draw/engines/overlay/overlay_viewer_attribute.cc @@ -0,0 +1,181 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup draw_engine + */ + +#include "DRW_render.h" + +#include "DNA_mesh_types.h" +#include "DNA_pointcloud_types.h" + +#include "BLI_math_vector.hh" +#include "BLI_span.hh" + +#include "GPU_batch.h" + +#include "BKE_attribute.hh" +#include "BKE_curves.hh" +#include "BKE_duplilist.h" +#include "BKE_geometry_set.hh" + +#include "draw_cache_extract.hh" +#include "draw_cache_impl.h" +#include "overlay_private.hh" + +void OVERLAY_viewer_attribute_cache_init(OVERLAY_Data *vedata) +{ + OVERLAY_PassList *psl = vedata->psl; + OVERLAY_PrivateData *pd = vedata->stl->pd; + + const DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | + DRW_STATE_BLEND_ALPHA; + DRW_PASS_CREATE(psl->attribute_ps, state | pd->clipping_state); + + GPUShader *mesh_sh = OVERLAY_shader_viewer_attribute_mesh(); + GPUShader *pointcloud_sh = OVERLAY_shader_viewer_attribute_pointcloud(); + GPUShader *curve_sh = OVERLAY_shader_viewer_attribute_curve(); + GPUShader *curves_sh = OVERLAY_shader_viewer_attribute_curves(); + GPUShader *uniform_sh = OVERLAY_shader_uniform_color(); + GPUShader *uniform_pointcloud_sh = OVERLAY_shader_uniform_color_pointcloud(); + pd->viewer_attribute_mesh_grp = DRW_shgroup_create(mesh_sh, psl->attribute_ps); + pd->viewer_attribute_pointcloud_grp = DRW_shgroup_create(pointcloud_sh, psl->attribute_ps); + pd->viewer_attribute_curve_grp = DRW_shgroup_create(curve_sh, psl->attribute_ps); + pd->viewer_attribute_curves_grp = DRW_shgroup_create(curves_sh, psl->attribute_ps); + pd->viewer_attribute_instance_grp = DRW_shgroup_create(uniform_sh, psl->attribute_ps); + pd->viewer_attribute_instance_pointcloud_grp = DRW_shgroup_create(uniform_pointcloud_sh, + psl->attribute_ps); +} + +static void populate_cache_for_instance(Object &object, + OVERLAY_PrivateData &pd, + const DupliObject &dupli_object, + const float opacity) +{ + using namespace blender; + using namespace blender::bke; + + const GeometrySet &base_geometry = *dupli_object.preview_base_geometry; + const InstancesComponent &instances = + *base_geometry.get_component_for_read<InstancesComponent>(); + const AttributeAccessor instance_attributes = *instances.attributes(); + const VArray attribute = instance_attributes.lookup<ColorGeometry4f>(".viewer"); + if (!attribute) { + return; + } + ColorGeometry4f color = attribute.get(dupli_object.preview_instance_index); + color.a *= opacity; + switch (object.type) { + case OB_MESH: { + { + DRWShadingGroup *sub_grp = DRW_shgroup_create_sub(pd.viewer_attribute_instance_grp); + DRW_shgroup_uniform_vec4_copy(sub_grp, "ucolor", color); + GPUBatch *batch = DRW_cache_mesh_surface_get(&object); + DRW_shgroup_call(sub_grp, batch, &object); + } + if (GPUBatch *batch = DRW_cache_mesh_loose_edges_get(&object)) { + DRWShadingGroup *sub_grp = DRW_shgroup_create_sub(pd.viewer_attribute_instance_grp); + DRW_shgroup_uniform_vec4_copy(sub_grp, "ucolor", color); + DRW_shgroup_call(sub_grp, batch, &object); + } + break; + } + case OB_POINTCLOUD: { + DRWShadingGroup *sub_grp = DRW_shgroup_create_sub( + pd.viewer_attribute_instance_pointcloud_grp); + DRW_shgroup_uniform_vec4_copy(sub_grp, "ucolor", color); + GPUBatch *batch = DRW_cache_pointcloud_surface_get(&object); + DRW_shgroup_call_instance_range(sub_grp, &object, batch, 0, 0); + break; + } + case OB_CURVES_LEGACY: { + DRWShadingGroup *sub_grp = DRW_shgroup_create_sub(pd.viewer_attribute_instance_grp); + DRW_shgroup_uniform_vec4_copy(sub_grp, "ucolor", color); + GPUBatch *batch = DRW_cache_curve_edge_wire_get(&object); + DRW_shgroup_call(sub_grp, batch, &object); + break; + } + case OB_CURVES: { + /* Not supported yet because instances of this type are currently drawn as legacy curves. + */ + break; + } + } +} + +static void populate_cache_for_geometry(Object &object, + OVERLAY_PrivateData &pd, + const float opacity) +{ + using namespace blender; + using namespace blender::bke; + + switch (object.type) { + case OB_MESH: { + Mesh *mesh = static_cast<Mesh *>(object.data); + if (mesh->attributes().contains(".viewer")) { + GPUBatch *batch = DRW_cache_mesh_surface_viewer_attribute_get(&object); + DRW_shgroup_uniform_float_copy(pd.viewer_attribute_mesh_grp, "opacity", opacity); + DRW_shgroup_call(pd.viewer_attribute_mesh_grp, batch, &object); + } + break; + } + case OB_POINTCLOUD: { + PointCloud *pointcloud = static_cast<PointCloud *>(object.data); + if (pointcloud->attributes().contains(".viewer")) { + GPUBatch *batch = DRW_cache_pointcloud_surface_viewer_attribute_get(&object); + DRW_shgroup_uniform_float_copy(pd.viewer_attribute_pointcloud_grp, "opacity", opacity); + DRW_shgroup_call_instance_range(pd.viewer_attribute_pointcloud_grp, &object, batch, 0, 0); + } + break; + } + case OB_CURVES_LEGACY: { + Curve *curve = static_cast<Curve *>(object.data); + const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curve->curve_eval->geometry); + if (curves.attributes().contains(".viewer")) { + GPUBatch *batch = DRW_cache_curve_edge_wire_viewer_attribute_get(&object); + DRW_shgroup_uniform_float_copy(pd.viewer_attribute_curve_grp, "opacity", opacity); + DRW_shgroup_call(pd.viewer_attribute_curve_grp, batch, &object); + } + break; + } + case OB_CURVES: { + Curves *curves_id = static_cast<Curves *>(object.data); + const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); + if (curves.attributes().contains(".viewer")) { + bool is_point_domain; + GPUTexture **texture = DRW_curves_texture_for_evaluated_attribute( + curves_id, ".viewer", &is_point_domain); + DRWShadingGroup *grp = DRW_shgroup_curves_create_sub( + &object, pd.viewer_attribute_curves_grp, nullptr); + DRW_shgroup_uniform_float_copy(pd.viewer_attribute_curves_grp, "opacity", opacity); + DRW_shgroup_uniform_bool_copy(grp, "is_point_domain", is_point_domain); + DRW_shgroup_uniform_texture(grp, "color_tx", *texture); + } + break; + } + } +} + +void OVERLAY_viewer_attribute_cache_populate(OVERLAY_Data *vedata, Object *object) +{ + OVERLAY_PrivateData *pd = vedata->stl->pd; + const float opacity = vedata->stl->pd->overlay.viewer_attribute_opacity; + DupliObject *dupli_object = DRW_object_get_dupli(object); + + if (dupli_object->preview_instance_index >= 0) { + const InstancesComponent &instances = + *dupli_object->preview_base_geometry->get_component_for_read<InstancesComponent>(); + if (instances.attributes()->contains(".viewer")) { + populate_cache_for_instance(*object, *pd, *dupli_object, opacity); + return; + } + } + populate_cache_for_geometry(*object, *pd, opacity); +} + +void OVERLAY_viewer_attribute_draw(OVERLAY_Data *vedata) +{ + OVERLAY_PassList *psl = vedata->psl; + DRW_draw_pass(psl->attribute_ps); +} diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh index 8c9c943393f..40b7249a997 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh @@ -587,8 +587,20 @@ GPU_SHADER_CREATE_INFO(overlay_uniform_color) .fragment_source("overlay_uniform_color_frag.glsl") .additional_info("draw_mesh"); +GPU_SHADER_CREATE_INFO(overlay_uniform_color_pointcloud) + .do_static_compilation(true) + .push_constant(Type::VEC4, "ucolor") + .fragment_out(0, Type::VEC4, "fragColor") + .vertex_source("overlay_pointcloud_only_vert.glsl") + .fragment_source("overlay_uniform_color_frag.glsl") + .additional_info("draw_pointcloud"); + GPU_SHADER_CREATE_INFO(overlay_uniform_color_clipped) .do_static_compilation(true) .additional_info("overlay_depth_only", "drw_clipped"); +GPU_SHADER_CREATE_INFO(overlay_uniform_color_pointcloud_clipped) + .do_static_compilation(true) + .additional_info("overlay_uniform_color_pointcloud", "drw_clipped"); + /** \} */ diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_viewer_attribute_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_viewer_attribute_info.hh new file mode 100644 index 00000000000..aca80992622 --- /dev/null +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_viewer_attribute_info.hh @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_INTERFACE_INFO(overlay_viewer_attribute_iface, "").smooth(Type::VEC4, "finalColor"); + +GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_common).push_constant(Type::FLOAT, "opacity"); + +GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_mesh) + .do_static_compilation(true) + .vertex_source("overlay_viewer_attribute_mesh_vert.glsl") + .fragment_source("overlay_viewer_attribute_frag.glsl") + .fragment_out(0, Type::VEC4, "out_color") + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::VEC4, "attribute_value") + .vertex_out(overlay_viewer_attribute_iface) + .additional_info("overlay_viewer_attribute_common", "draw_mesh"); + +GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_mesh_clipped) + .do_static_compilation(true) + .additional_info("overlay_viewer_attribute_mesh", "drw_clipped"); + +GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_pointcloud) + .do_static_compilation(true) + .vertex_source("overlay_viewer_attribute_pointcloud_vert.glsl") + .fragment_source("overlay_viewer_attribute_frag.glsl") + .fragment_out(0, Type::VEC4, "out_color") + .vertex_in(3, Type::VEC4, "attribute_value") + .vertex_out(overlay_viewer_attribute_iface) + .additional_info("overlay_viewer_attribute_common", "draw_pointcloud"); + +GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_pointcloud_clipped) + .do_static_compilation(true) + .additional_info("overlay_viewer_attribute_pointcloud", "drw_clipped"); + +GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_curve) + .do_static_compilation(true) + .vertex_source("overlay_viewer_attribute_curve_vert.glsl") + .fragment_source("overlay_viewer_attribute_frag.glsl") + .fragment_out(0, Type::VEC4, "out_color") + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::VEC4, "attribute_value") + .vertex_out(overlay_viewer_attribute_iface) + .additional_info("overlay_viewer_attribute_common", "draw_modelmat", "draw_resource_id"); + +GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_curve_clipped) + .do_static_compilation(true) + .additional_info("overlay_viewer_attribute_curve", "drw_clipped"); + +GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_curves) + .do_static_compilation(true) + .vertex_source("overlay_viewer_attribute_curves_vert.glsl") + .fragment_source("overlay_viewer_attribute_frag.glsl") + .fragment_out(0, Type::VEC4, "out_color") + .sampler(0, ImageType::FLOAT_BUFFER, "color_tx") + .push_constant(Type::BOOL, "is_point_domain") + .vertex_out(overlay_viewer_attribute_iface) + .additional_info("overlay_viewer_attribute_common", "draw_hair"); + +GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_curves_clipped) + .do_static_compilation(true) + .additional_info("overlay_viewer_attribute_curves", "drw_clipped"); diff --git a/source/blender/draw/engines/overlay/shaders/overlay_pointcloud_only_vert.glsl b/source/blender/draw/engines/overlay/shaders/overlay_pointcloud_only_vert.glsl new file mode 100644 index 00000000000..8a7e81028d3 --- /dev/null +++ b/source/blender/draw/engines/overlay/shaders/overlay_pointcloud_only_vert.glsl @@ -0,0 +1,9 @@ +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) +#pragma BLENDER_REQUIRE(common_pointcloud_lib.glsl) + +void main() +{ + vec3 world_pos = pointcloud_get_pos(); + gl_Position = point_world_to_ndc(world_pos); +} diff --git a/source/blender/draw/engines/overlay/shaders/overlay_viewer_attribute_curve_vert.glsl b/source/blender/draw/engines/overlay/shaders/overlay_viewer_attribute_curve_vert.glsl new file mode 100644 index 00000000000..7c2c386b2f5 --- /dev/null +++ b/source/blender/draw/engines/overlay/shaders/overlay_viewer_attribute_curve_vert.glsl @@ -0,0 +1,9 @@ +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) + +void main() +{ + vec3 world_pos = point_object_to_world(pos); + gl_Position = point_world_to_ndc(world_pos); + finalColor = attribute_value; +} diff --git a/source/blender/draw/engines/overlay/shaders/overlay_viewer_attribute_curves_vert.glsl b/source/blender/draw/engines/overlay/shaders/overlay_viewer_attribute_curves_vert.glsl new file mode 100644 index 00000000000..23d313e036f --- /dev/null +++ b/source/blender/draw/engines/overlay/shaders/overlay_viewer_attribute_curves_vert.glsl @@ -0,0 +1,28 @@ +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) +#pragma BLENDER_REQUIRE(common_hair_lib.glsl) + +void main() +{ + bool is_persp = (ProjectionMatrix[3][3] == 0.0); + float time, thick_time, thickness; + vec3 world_pos, tan, binor; + hair_get_pos_tan_binor_time(is_persp, + ModelMatrixInverse, + ViewMatrixInverse[3].xyz, + ViewMatrixInverse[2].xyz, + world_pos, + tan, + binor, + time, + thickness, + thick_time); + gl_Position = point_world_to_ndc(world_pos); + + if (is_point_domain) { + finalColor = texelFetch(color_tx, hair_get_base_id()); + } + else { + finalColor = texelFetch(color_tx, hair_get_strand_id()); + } +} diff --git a/source/blender/draw/engines/overlay/shaders/overlay_viewer_attribute_frag.glsl b/source/blender/draw/engines/overlay/shaders/overlay_viewer_attribute_frag.glsl new file mode 100644 index 00000000000..6176a6b96ba --- /dev/null +++ b/source/blender/draw/engines/overlay/shaders/overlay_viewer_attribute_frag.glsl @@ -0,0 +1,6 @@ + +void main() +{ + out_color = finalColor; + out_color.a *= opacity; +} diff --git a/source/blender/draw/engines/overlay/shaders/overlay_viewer_attribute_mesh_vert.glsl b/source/blender/draw/engines/overlay/shaders/overlay_viewer_attribute_mesh_vert.glsl new file mode 100644 index 00000000000..7c2c386b2f5 --- /dev/null +++ b/source/blender/draw/engines/overlay/shaders/overlay_viewer_attribute_mesh_vert.glsl @@ -0,0 +1,9 @@ +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) + +void main() +{ + vec3 world_pos = point_object_to_world(pos); + gl_Position = point_world_to_ndc(world_pos); + finalColor = attribute_value; +} diff --git a/source/blender/draw/engines/overlay/shaders/overlay_viewer_attribute_pointcloud_vert.glsl b/source/blender/draw/engines/overlay/shaders/overlay_viewer_attribute_pointcloud_vert.glsl new file mode 100644 index 00000000000..e706e8f9033 --- /dev/null +++ b/source/blender/draw/engines/overlay/shaders/overlay_viewer_attribute_pointcloud_vert.glsl @@ -0,0 +1,10 @@ +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) +#pragma BLENDER_REQUIRE(common_pointcloud_lib.glsl) + +void main() +{ + vec3 world_pos = pointcloud_get_pos(); + gl_Position = point_world_to_ndc(world_pos); + finalColor = attribute_value; +} |