75 mat44[0] = ob_mat[0] * radius;
76 mat44[1] = ob_mat[1] * radius;
77 mat44[2] = ob_mat[2] * radius;
97 color_a = encode_2f_to_float(bone_color[0], bone_color[1]);
98 color_b = encode_2f_to_float(bone_color[2], bone_color[3]);
104 color_hint_a = encode_2f_to_float(hint_color[0], hint_color[1]);
105 color_hint_b = encode_2f_to_float(hint_color[2], hint_color[3]);
110 float encode_2f_to_float(
float a,
float b)
const
185 if (
rv3d ==
nullptr) {
329 struct BatchDeleter {
335 using BatchPtr = std::unique_ptr<gpu::Batch, BatchDeleter>;
436 static StaticCache &get_static_cache()
439 static StaticCache static_cache;
446 const bool clipping_enabled_;
454 "overlay_viewer_attribute_pointcloud");
555 "overlay_volume_gridlines_flags");
558 "overlay_volume_gridlines_range");
560 "overlay_volume_velocity_streamline");
570 ShaderModule(
const SelectionType selection_type,
const bool clipping_enabled)
571 : selection_type_(selection_type), clipping_enabled_(clipping_enabled) {};
573 StaticShader shader_clippable(
const char *create_info_name);
574 StaticShader shader_selectable(
const char *create_info_name);
575 StaticShader shader_selectable_no_clip(
const char *create_info_name);
684 void init(
bool clipping_enabled)
687 shaders->anti_aliasing.ensure_compile_async();
688 shaders->armature_degrees_of_freedom.ensure_compile_async();
689 shaders->armature_envelope_fill.ensure_compile_async();
690 shaders->armature_envelope_outline.ensure_compile_async();
691 shaders->armature_shape_fill.ensure_compile_async();
692 shaders->armature_shape_outline.ensure_compile_async();
693 shaders->armature_shape_wire_strip.ensure_compile_async();
694 shaders->armature_shape_wire.ensure_compile_async();
695 shaders->armature_sphere_fill.ensure_compile_async();
696 shaders->armature_sphere_outline.ensure_compile_async();
697 shaders->armature_stick.ensure_compile_async();
698 shaders->armature_wire.ensure_compile_async();
699 shaders->attribute_viewer_curve.ensure_compile_async();
700 shaders->attribute_viewer_curves.ensure_compile_async();
701 shaders->attribute_viewer_mesh.ensure_compile_async();
702 shaders->attribute_viewer_pointcloud.ensure_compile_async();
703 shaders->background_fill.ensure_compile_async();
704 shaders->curve_edit_handles.ensure_compile_async();
705 shaders->curve_edit_line.ensure_compile_async();
706 shaders->curve_edit_points.ensure_compile_async();
707 shaders->depth_curves.ensure_compile_async();
708 shaders->depth_grease_pencil.ensure_compile_async();
709 shaders->depth_mesh.ensure_compile_async();
710 shaders->depth_pointcloud.ensure_compile_async();
711 shaders->extra_grid.ensure_compile_async();
712 shaders->extra_ground_line.ensure_compile_async();
713 shaders->extra_loose_points.ensure_compile_async();
714 shaders->extra_point.ensure_compile_async();
715 shaders->extra_shape.ensure_compile_async();
716 shaders->extra_wire_object.ensure_compile_async();
717 shaders->extra_wire.ensure_compile_async();
718 shaders->fluid_grid_lines_flags.ensure_compile_async();
719 shaders->fluid_grid_lines_flat.ensure_compile_async();
720 shaders->fluid_grid_lines_range.ensure_compile_async();
721 shaders->fluid_velocity_mac.ensure_compile_async();
722 shaders->fluid_velocity_needle.ensure_compile_async();
723 shaders->fluid_velocity_streamline.ensure_compile_async();
724 shaders->grid.ensure_compile_async();
725 shaders->image_plane_depth_bias.ensure_compile_async();
726 shaders->lattice_points.ensure_compile_async();
727 shaders->lattice_wire.ensure_compile_async();
728 shaders->legacy_curve_edit_handles.ensure_compile_async();
729 shaders->legacy_curve_edit_points.ensure_compile_async();
730 shaders->legacy_curve_edit_wires.ensure_compile_async();
731 shaders->light_spot_cone.ensure_compile_async();
732 shaders->mesh_analysis.ensure_compile_async();
733 shaders->mesh_edit_depth.ensure_compile_async();
734 shaders->mesh_edit_edge.ensure_compile_async();
735 shaders->mesh_edit_face.ensure_compile_async();
736 shaders->mesh_edit_facedot.ensure_compile_async();
737 shaders->mesh_edit_skin_root.ensure_compile_async();
738 shaders->mesh_edit_vert.ensure_compile_async();
739 shaders->motion_path_line.ensure_compile_async();
740 shaders->motion_path_vert.ensure_compile_async();
741 shaders->outline_detect.ensure_compile_async();
742 shaders->outline_prepass_curves.ensure_compile_async();
743 shaders->outline_prepass_gpencil.ensure_compile_async();
744 shaders->outline_prepass_mesh.ensure_compile_async();
745 shaders->outline_prepass_pointcloud.ensure_compile_async();
746 shaders->outline_prepass_wire.ensure_compile_async();
747 shaders->paint_weight_fake_shading.ensure_compile_async();
748 shaders->particle_dot.ensure_compile_async();
749 shaders->particle_edit_edge.ensure_compile_async();
750 shaders->particle_edit_vert.ensure_compile_async();
751 shaders->particle_hair.ensure_compile_async();
752 shaders->particle_shape.ensure_compile_async();
753 shaders->pointcloud_points.ensure_compile_async();
754 shaders->uniform_color.ensure_compile_async();
755 shaders->wireframe_curve.ensure_compile_async();
756 shaders->wireframe_mesh.ensure_compile_async();
757 shaders->wireframe_points.ensure_compile_async();
770 this->depth_tx.
wrap(viewport_textures.
depth);
773 this->color_render_tx.
wrap(viewport_textures.
color);
775 this->render_fb = viewport_framebuffers.
default_fb;
776 this->render_in_front_fb = viewport_framebuffers.
in_front_fb;
780 if (
state.xray_enabled) {
782 this->xray_depth_tx.
acquire(render_size, gpu::TextureFormat::SFLOAT_32_DEPTH_UINT_8);
783 this->depth_target_tx.
wrap(this->xray_depth_tx);
785 this->xray_depth_in_front_tx.
acquire(render_size,
786 gpu::TextureFormat::SFLOAT_32_DEPTH_UINT_8);
787 this->depth_target_in_front_tx.
wrap(this->xray_depth_in_front_tx);
791 if (!this->depth_in_front_tx.
is_valid()) {
792 this->depth_in_front_alloc_tx.
acquire(render_size,
793 gpu::TextureFormat::SFLOAT_32_DEPTH_UINT_8);
794 this->depth_in_front_tx.
wrap(this->depth_in_front_alloc_tx);
796 this->depth_target_tx.
wrap(this->depth_tx);
797 this->depth_target_in_front_tx.
wrap(this->depth_in_front_tx);
801 if (!this->color_overlay_tx.
is_valid()) {
803 this->color_overlay_alloc_tx.
acquire(
int2(1, 1), gpu::TextureFormat::SRGBA_8_8_8_8);
804 this->color_render_alloc_tx.
acquire(
int2(1, 1), gpu::TextureFormat::SRGBA_8_8_8_8);
806 this->color_overlay_tx.
wrap(this->color_overlay_alloc_tx);
807 this->color_render_tx.
wrap(this->color_render_alloc_tx);
809 this->line_tx.
acquire(
int2(1, 1), gpu::TextureFormat::UNORM_8_8_8_8);
810 this->overlay_tx.
acquire(
int2(1, 1), gpu::TextureFormat::SRGBA_8_8_8_8);
820 this->line_tx.
acquire(render_size, gpu::TextureFormat::UNORM_8_8_8_8, usage);
821 this->overlay_tx.
acquire(render_size, gpu::TextureFormat::SRGBA_8_8_8_8, usage);
852 this->xray_depth_in_front_tx.
release();
853 this->depth_in_front_alloc_tx.
release();
854 this->color_overlay_alloc_tx.
release();
855 this->color_render_alloc_tx.
release();
898 return theme.colors.wire;
902 return theme.colors.wire_edit;
904 return theme.colors.active_object;
906 return theme.colors.object_select;
908 return theme.colors.transform;
910 return theme.colors.speaker;
912 return theme.colors.camera;
914 return theme.colors.empty;
916 return theme.colors.light;
918 return theme.colors.wire;
944 if (
state.scene->world) {
949 return state.v3d->shading.background_color;
1005 if (dim[0] == 0.0f) {
1008 if (dim[1] == 0.0f) {
1011 if (dim[2] == 0.0f) {
1025 manager.
matrix_buf.current().get_or_resize(resource_index.resource_index()).model;
1029 object_to_world.
x_axis();
1031 object_to_world.
y_axis();
1035 callback(
geom, resource_index);
void BKE_movieclip_free_gputexture(struct MovieClip *clip)
General operations, lookup, etc. for blender objects.
void BKE_object_dimensions_get(const Object *ob, float r_vec[3])
MINLINE float max_ff(float a, float b)
MINLINE float clamp_f(float value, float min, float max)
#define BASE_SELECTED(v3d, base)
@ V3D_SHADING_BACKGROUND_VIEWPORT
@ V3D_SHADING_BACKGROUND_WORLD
@ V3D_OVERLAY_SCULPT_SHOW_FACE_SETS
@ V3D_OVERLAY_FACE_ORIENTATION
@ V3D_OVERLAY_VIEWER_ATTRIBUTE
@ V3D_OVERLAY_HIDE_OBJECT_ORIGINS
@ V3D_OVERLAY_HIDE_MOTION_PATHS
@ V3D_OVERLAY_SHOW_LIGHT_COLORS
@ V3D_OVERLAY_SCULPT_SHOW_MASK
@ V3D_OVERLAY_HIDE_OBJECT_XTRAS
@ V3D_OVERLAY_FADE_INACTIVE
@ V3D_OVERLAY_SCULPT_CURVES_CAGE
@ V3D_OVERLAY_VIEWER_ATTRIBUTE_TEXT
@ V3D_OVERLAY_BONE_SELECT
#define GPU_BATCH_DISCARD_SAFE(batch)
#define GPU_ATTACHMENT_TEXTURE(_texture)
#define GPU_ATTACHMENT_NONE
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_SHADER_WRITE
@ GPU_TEXTURE_USAGE_ATTACHMENT
static blender::gpu::VertBuf * GPU_vertbuf_create_with_format(const GPUVertFormat &format)
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
void UI_GetThemeColor3fv(int colorid, float col[3])
void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int offset, float col[4])
float UI_GetThemeValuef(int colorid)
BMesh const char void * data
void ensure(GPUAttachment depth=GPU_ATTACHMENT_NONE, GPUAttachment color1=GPU_ATTACHMENT_NONE, GPUAttachment color2=GPU_ATTACHMENT_NONE, GPUAttachment color3=GPU_ATTACHMENT_NONE, GPUAttachment color4=GPU_ATTACHMENT_NONE, GPUAttachment color5=GPU_ATTACHMENT_NONE, GPUAttachment color6=GPU_ATTACHMENT_NONE, GPUAttachment color7=GPU_ATTACHMENT_NONE, GPUAttachment color8=GPU_ATTACHMENT_NONE)
SwapChain< ObjectMatricesBuf, 2 > matrix_buf
bool is_active(const Object *active_object) const
void acquire(int2 extent, blender::gpu::TextureFormat format, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL)
void wrap(gpu::Texture *tex)
int3 size(int miplvl=0) const
void draw_procedural(GPUPrimType primitive, uint instance_len, uint vertex_len, uint vertex_first=-1, ResourceIndexRange res_index={}, uint custom_id=0)
void draw_expand(gpu::Batch *batch, GPUPrimType primitive_type, uint primitive_len, uint instance_len, uint vertex_len, uint vertex_first, ResourceIndexRange res_index={}, uint custom_id=0)
void draw(gpu::Batch *batch, uint instance_len=-1, uint vertex_len=-1, uint vertex_first=-1, ResourceIndexRange res_index={}, uint custom_id=0)
void push_constant(const char *name, const float &data)
void bind_ssbo(const char *name, gpu::StorageBuf *buffer)
detail::PassBase< command::DrawCommandBuf > Sub
StaticShader attribute_viewer_curves
StaticShader wireframe_points
StaticShader mesh_edit_edge
StaticShader uv_edit_facedot
StaticShader mesh_edit_facedot
StaticShader paint_weight_fake_shading
static ShaderModule & module_get(SelectionType selection_type, bool clipping_enabled)
StaticShader lattice_points
StaticShader attribute_viewer_pointcloud
StaticShader motion_path_vert
StaticShader armature_envelope_outline
StaticShader mesh_loop_normal
StaticShader uv_edit_edge
StaticShader pointcloud_points
StaticShader particle_edit_vert
StaticShader particle_hair
StaticShader armature_sphere_outline
StaticShader armature_degrees_of_freedom
StaticShader fluid_grid_lines_range
StaticShader armature_shape_fill
StaticShader extra_loose_points
StaticShader mesh_vert_normal_subdiv
StaticShader depth_pointcloud
StaticShader mesh_face_normal
StaticShader legacy_curve_edit_points
StaticShader outline_detect
StaticShader armature_wire
StaticShader legacy_curve_edit_handles
StaticShader light_spot_cone
StaticShader paint_weight
StaticShader particle_shape
StaticShader mesh_loop_normal_subdiv
StaticShader outline_prepass_curves
StaticShader armature_stick
StaticShader legacy_curve_edit_wires
StaticShader armature_envelope_fill
StaticShader armature_sphere_fill
StaticShader anti_aliasing
StaticShader extra_ground_line
StaticShader mesh_edit_face
StaticShader lattice_wire
StaticShader image_plane_depth_bias
StaticShader curve_edit_handles
StaticShader motion_path_line
StaticShader fluid_velocity_needle
StaticShader particle_dot
StaticShader wireframe_curve
static void module_free()
StaticShader legacy_curve_edit_normals
StaticShader sculpt_curves_cage
StaticShader attribute_viewer_mesh
StaticShader armature_shape_wire_strip
StaticShader fluid_velocity_streamline
StaticShader paint_region_edge
StaticShader outline_prepass_mesh
StaticShader uv_image_borders
StaticShader uv_brush_stencil
StaticShader extra_wire_object
StaticShader paint_region_face
StaticShader mesh_edit_depth
StaticShader grid_grease_pencil
StaticShader curve_edit_points
StaticShader outline_prepass_wire
StaticShader mesh_face_normal_subdiv
StaticShader wireframe_mesh
StaticShader outline_prepass_pointcloud
StaticShader mesh_vert_normal
StaticShader uv_analysis_stretch_area
StaticShader paint_region_vert
StaticShader particle_edit_edge
StaticShader depth_mesh_conservative
StaticShader fluid_grid_lines_flat
StaticShader armature_shape_outline
StaticShader armature_shape_wire
StaticShader background_clip_bound
StaticShader uv_paint_mask
StaticShader grid_background
StaticShader uv_edit_face
StaticShader attribute_viewer_curve
StaticShader mesh_edit_vert
StaticShader sculpt_curves
StaticShader depth_grease_pencil
StaticShader background_fill
StaticShader uv_edit_vert
StaticShader uv_analysis_stretch_angle
StaticShader depth_curves
StaticShader mesh_edit_skin_root
StaticShader curve_edit_line
StaticShader uniform_color
StaticShader fluid_grid_lines_flags
StaticShader outline_prepass_gpencil
StaticShader fluid_velocity_mac
StaticShader mesh_analysis
StaticShader uv_wireframe
StaticShader paint_texture
BatchPtr light_point_lines
BatchPtr camera_volume_wire
BatchPtr camera_tria_wire
BatchPtr field_tube_limit
BatchPtr light_area_square_lines
BatchPtr bone_degrees_of_freedom_wire
BatchPtr bone_degrees_of_freedom
BatchPtr field_sphere_limit
BatchPtr light_icon_sun_rays
BatchPtr light_icon_inner_lines
BatchPtr light_area_disk_lines
BatchPtr bone_sphere_wire
BatchPtr lightprobe_planar
BatchPtr metaball_wire_circle
BatchPtr sphere_low_detail
BatchPtr light_spot_lines
BatchPtr light_icon_outer_lines
BatchPtr light_spot_volume
BatchPtr field_cone_limit
BatchPtr camera_distances
BatchPtr bone_octahedron_wire
BatchPtr bone_envelope_wire
gpu::StaticShader StaticShader
select::SelectionType SelectionType
static bool is_from_dupli_or_set(const Object *ob)
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
AxisSigned cross(const AxisSigned a, const AxisSigned b)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< float, 3 > float3
DefaultFramebufferList * viewport_framebuffer_list_get() const
DefaultTextureList * viewport_texture_list_get() const
blender::gpu::FrameBuffer * default_fb
blender::gpu::FrameBuffer * in_front_fb
blender::gpu::Texture * depth
blender::gpu::Texture * color
blender::gpu::Texture * color_overlay
blender::gpu::Texture * depth_in_front
void set_color(const float4 &bone_color)
BoneInstanceData()=default
BoneInstanceData(const float4x4 &ob_mat, const float3 &pos, const float radius, const float color[4])
void set_hint_color(const float4 &hint_color)
BoneInstanceData(const float4x4 &bone_mat, const float4 &bone_color, const float4 &hint_color)
BoneInstanceData(const float4x4 &bone_mat, const float4 &bone_color)
void if_flat_axis_orthogonal_to_view(Manager &manager, const View &view, Callback callback) const
FunctionRef< void(gpu::Batch *geom, ResourceIndex handle)> Callback
ResourceHandleRange handle
static int flat_axis_index_get(const Object *ob)
ResourceHandleRange handle
void append(const float3 &start, const float3 &end, const float4 &color, select::ID select_id=select::SelectMap::select_invalid_id())
void append(const float3 &start, const float3 &end, const int color_id, select::ID select_id=select::SelectMap::select_invalid_id())
void end_sync(PassSimple::Sub &pass)
LinePrimitiveBuf(const SelectionType selection_type, const char *name=nullptr)
void end_sync(PassSimple::Sub &pass)
PointPrimitiveBuf(const SelectionType selection_type, const char *name=nullptr)
void append(const float3 &position, const int color_id, select::ID select_id)
void append(const float3 &position, const float4 &color, select::ID select_id=select::SelectMap::select_invalid_id())
Framebuffer overlay_line_in_front_fb
Framebuffer overlay_line_only_fb
float4 background_color_get(const State &state)
TextureRef depth_target_tx
Framebuffer overlay_color_only_fb
const float4 & object_wire_color(const ObjectRef &ob_ref, ThemeColorID theme_id) const
const float4 & object_wire_color(const ObjectRef &ob_ref, const State &state) const
TextureFromPool color_render_alloc_tx
Framebuffer overlay_output_color_only_fb
TextureRef depth_target_in_front_tx
Framebuffer overlay_output_fb
TextureFromPool xray_depth_tx
Vector< MovieClip * > bg_movie_clips
gpu::FrameBuffer * render_fb
ColorBand weight_ramp_copy
TextureFromPool overlay_tx
void begin_sync(int clipping_plane_count)
Framebuffer overlay_in_front_fb
void acquire(const DRWContext *draw_ctx, const State &state)
void update_theme_settings(const DRWContext *ctx, const State &state)
TextureRef color_render_tx
detail::SubPassVector< GreasePencilDepthPlane, 16 > depth_planes
gpu::FrameBuffer * render_in_front_fb
int64_t depth_planes_count
float4 object_background_blend_color(const ObjectRef &ob_ref, const State &state) const
TextureRef color_overlay_tx
TextureFromPool depth_in_front_alloc_tx
draw::UniformArrayBuffer< float4, 6 > clip_planes_buf
void init(bool clipping_enabled)
bool is_selection() const
TextureRef depth_in_front_tx
static float vertex_size_get()
float4 background_blend_color(ThemeColorID theme_id) const
const ShapeCache & shapes
TextureFromPool xray_depth_in_front_tx
ThemeColorID object_wire_theme_id(const ObjectRef &ob_ref, const State &state) const
TextureFromPool color_overlay_alloc_tx
draw::UniformBuffer< UniformData > globals_buf
Resources(const SelectionType selection_type_, const ShapeCache &shapes_)
void update_clip_planes(const State &state)
Framebuffer overlay_line_fb
void free_movieclips_textures()
ShapeInstanceBuf(const SelectionType selection_type, const char *name=nullptr)
void end_sync(PassSimple::Sub &pass, gpu::Batch *shape)
StorageVectorBuffer< ExtraInstanceData > data_buf
void append(const InstanceDataT &data, select::ID select_id)
void end_sync(PassSimple::Sub &pass, gpu::Batch *shape, GPUPrimType primitive_type, uint primitive_len)
const ViewLayer * view_layer
View::OffsetData offset_data_get() const
bool xray_enabled_and_not_wire
const SpaceLink * space_data
const Object * object_active
bool show_sculpt_curves_cage() const
bool show_bone_selection() const
bool is_space_node() const
bool is_viewport_image_render
bool show_sculpt_mask() const
bool show_object_origins() const
bool show_fade_inactive() const
bool show_sculpt_face_sets() const
bool show_wireframes() const
bool is_render_depth_available
eContextObjectMode ctx_mode
bool show_motion_paths() const
bool show_face_orientation() const
bool is_depth_only_drawing
bool show_light_colors() const
const RegionView3D * rv3d
bool show_attribute_viewer_text() const
bool show_attribute_viewer() const
bool is_space_v3d() const
bool is_space_image() const
GPU_VERTEX_FORMAT_FUNC(VertShaded, pos, vclass, nor)
GPU_VERTEX_FORMAT_FUNC(VertexBone, pos, vclass)
void end_sync(PassSimple::Sub &pass, GPUPrimType primitive)
select::SelectBuf select_buf
void append(const float3 &position, const float4 &color)
VertexPrimitiveBuf(const SelectionType selection_type, const char *name=nullptr)
StorageVectorBuffer< VertexData > data_buf
GPU_VERTEX_FORMAT_FUNC(VertexTriple, pos0, pos1, pos2)
GPU_VERTEX_FORMAT_FUNC(VertexWithColor, pos, color)
GPU_VERTEX_FORMAT_FUNC(Vertex, pos, vclass)
void select_append(ID select_id)
void select_bind(PassSimple::Sub &pass)
SelectBuf(const SelectionType selection_type)
const SelectionType selection_type
static const ID select_invalid_id()
SelectMap(const SelectionType selection_type)
const SelectionType selection_type
static constexpr VertAttrType type
static constexpr VertAttrType type