36 PassMain images_ps_ = {
"images_ps_"};
45 EmptyInstanceBuf plain_axes_buf = {selection_type_,
"plain_axes_buf"};
46 EmptyInstanceBuf single_arrow_buf = {selection_type_,
"single_arrow_buf"};
47 EmptyInstanceBuf cube_buf = {selection_type_,
"cube_buf"};
48 EmptyInstanceBuf circle_buf = {selection_type_,
"circle_buf"};
49 EmptyInstanceBuf sphere_buf = {selection_type_,
"sphere_buf"};
50 EmptyInstanceBuf cone_buf = {selection_type_,
"cone_buf"};
51 EmptyInstanceBuf arrows_buf = {selection_type_,
"arrows_buf"};
52 EmptyInstanceBuf image_buf = {selection_type_,
"image_buf"};
55 View::OffsetData offset_data_;
69 offset_data_ =
state.offset_data_get();
74 pass.
shader_set(res.shaders->image_plane_depth_bias.get());
78 res.select_bind(pass);
85 res.select_bind(pass, sub);
91 init_pass(images_ps_, draw_state);
94 init_sortable(images_back_ps_, draw_state);
95 init_sortable(images_blend_ps_, draw_state);
98 init_sortable(images_front_ps_, draw_state);
105 call_buffers.plain_axes_buf.clear();
106 call_buffers.single_arrow_buf.clear();
107 call_buffers.cube_buf.clear();
108 call_buffers.circle_buf.clear();
109 call_buffers.sphere_buf.clear();
110 call_buffers.cone_buf.clear();
111 call_buffers.arrows_buf.clear();
112 call_buffers.image_buf.clear();
125 const select::ID select_id = res.select_id(ob_ref);
127 image_sync(ob_ref, select_id, manager, res,
state, call_buffers_.image_buf);
133 const bool empty_has_geometry = ob_ref.object->runtime->geometry_set_eval &&
134 !ob_ref.object->runtime->geometry_set_eval->is_empty();
135 if (empty_has_geometry && ob_ref.object->instance_collection ==
nullptr) {
139 ob_ref.object->object_to_world(),
140 ob_ref.object->empty_drawsize,
141 ob_ref.object->empty_drawtype,
148 const float draw_size,
149 const char empty_drawtype,
151 CallBuffers &call_buffers)
155 switch (empty_drawtype) {
157 call_buffers.plain_axes_buf.append(
data, select_id);
160 call_buffers.single_arrow_buf.append(
data, select_id);
163 call_buffers.cube_buf.append(
data, select_id);
166 call_buffers.circle_buf.append(
data, select_id);
169 call_buffers.sphere_buf.append(
data, select_id);
172 call_buffers.cone_buf.append(
data, select_id);
175 call_buffers.arrows_buf.append(
data, select_id);
187 res.select_bind(ps_);
194 CallBuffers &call_buffers)
197 state.clipping_plane_count);
204 call_buffers.cube_buf.end_sync(ps, res.
shapes.
cube.get());
205 call_buffers.circle_buf.end_sync(ps, res.
shapes.
circle.get());
208 call_buffers.arrows_buf.end_sync(ps, res.
shapes.
arrows.get());
218 manager.generate_commands(images_back_ps_, view);
219 manager.generate_commands(images_ps_, view);
220 manager.generate_commands(images_blend_ps_, view);
221 manager.generate_commands(images_front_ps_, view);
223 depth_bias_winmat_ = offset_data_.winmat_polygon_offset(view.winmat(), -1.0f);
233 manager.submit(ps_, view);
275 EmptyInstanceBuf &empty_image_buf)
283 const bool show_image = show_frame &&
287 const bool use_alpha_premult = ima && (ima->alpha_mode ==
IMA_ALPHA_PREMUL);
297 if (ima !=
nullptr) {
310 calc_image_aspect(ima, size, image_aspect);
312 mat = ob->object_to_world();
324 if (show_image && tex && ((ob->
color[3] > 0.0f) || !use_alpha_blend)) {
331 pass.bind_texture(
"img_tx", tex);
332 pass.push_constant(
"img_premultiplied", use_alpha_premult);
333 pass.push_constant(
"img_alpha_blend", use_alpha_blend);
334 pass.push_constant(
"is_camera_background",
false);
344 const bool use_alpha_blend,
350 return create_subpass(
state, mat, res, images_front_ps_,
true);
354 ob.empty_image_depth;
355 switch (depth_mode) {
357 return create_subpass(
state, mat, res, images_back_ps_,
false);
359 return create_subpass(
state, mat, res, images_front_ps_,
true);
362 return use_alpha_blend ? create_subpass(
state, mat, res, images_blend_ps_,
true) :
370 PassSortable &parent,
377 sub.shader_set(res.shaders->image_plane_depth_bias.get());
378 sub.push_constant(
"depth_bias_winmat", &depth_bias_winmat_);
381 sub.shader_set(res.shaders->image_plane.get());
396 if (ima->aspx > ima->aspy) {
397 sca.y = ima->aspy / ima->aspx;
399 else if (ima->aspx < ima->aspy) {
400 sca.x = ima->aspx / ima->aspy;
404 const float2 scale_inv(ima_dim.
x * sca.x, ima_dim.
y * sca.y);
405 r_image_aspect = (scale_inv.x > scale_inv.y) ?
float2(1.0f, scale_inv.y / scale_inv.x) :
406 float2(scale_inv.x / scale_inv.y, 1.0f);
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
void hold_texture(gpu::Texture *texture)
void submit_only(PassMain &pass, View &view)
ResourceHandleRange resource_handle(const ObjectRef &ref, float inflate_bounds=0.0f)
void shader_set(gpu::Shader *shader)
PassBase< DrawCommandBufType > & sub(const char *name)
void state_set(DRWState state, int clip_plane_count=0)
void bind_ubo(const char *name, gpu::UniformBuf *buffer)
void push_constant(const char *name, const float &data)
detail::PassBase< command::DrawMultiBuf > Sub
void pre_draw(Manager &manager, View &view) final
static void object_sync(const select::ID select_id, const float4x4 &matrix, const float draw_size, const char empty_drawtype, const float4 &color, CallBuffers &call_buffers)
void draw_in_front_images(Framebuffer &framebuffer, Manager &manager, View &view)
void draw_images(Framebuffer &framebuffer, Manager &manager, View &view)
void begin_sync(Resources &res, const State &state) final
void end_sync(Resources &res, const State &state) final
Empties(const SelectionType selection_type)
void draw_line(Framebuffer &framebuffer, Manager &manager, View &view) final
static void begin_sync(CallBuffers &call_buffers)
void object_sync(Manager &manager, const ObjectRef &ob_ref, Resources &res, const State &state) final
static void end_sync(Resources &res, const State &state, PassSimple::Sub &ps, CallBuffers &call_buffers)
void draw_background_images(Framebuffer &framebuffer, Manager &manager, View &view)
static void stereo_setup(const Scene *scene, const View3D *v3d, blender::Image *ima, ImageUser *iuser)
#define DRW_CLIPPING_UBO_SLOT
#define OVERLAY_GLOBALS_SLOT
select::SelectionType SelectionType
detail::Pass< command::DrawCommandBuf > PassSimple
detail::Pass< command::DrawMultiBuf > PassMain
int size(const AssetLibraryReference *library_reference)
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
void GPU_framebuffer_bind(gpu::FrameBuffer *fb)
bool BKE_object_empty_image_frame_is_visible_in_view3d(const Object *ob, const RegionView3D *rv3d)
bool BKE_object_empty_image_data_is_visible_in_view3d(const Object *ob, const RegionView3D *rv3d)
VecBase< int32_t, 2 > int2
BMesh const char void * data
@ DRW_STATE_BLEND_ALPHA_PREMUL
@ DRW_STATE_DEPTH_LESS_EQUAL
@ OB_EMPTY_IMAGE_USE_ALPHA_BLEND
@ OB_EMPTY_IMAGE_DEPTH_DEFAULT
@ OB_EMPTY_IMAGE_DEPTH_BACK
@ OB_EMPTY_IMAGE_DEPTH_FRONT
draw::Manager * DRW_manager_get()
gpu::Texture * BKE_image_acquire_gpu_texture(Image *image, ImageUser *iuser)
int GPU_texture_original_height(const gpu::Texture *texture)
int GPU_texture_original_width(const gpu::Texture *texture)
eObject_EmptyImageDepth empty_image_depth
eObject_EmptyImageFlag empty_image_flag
const float4 & object_wire_color(const ObjectRef &ob_ref, ThemeColorID theme_id) const
draw::UniformArrayBuffer< float4, 6 > clip_planes_buf
const ShapeCache & shapes
draw::UniformBuffer< UniformData > globals_buf