36 const float delta_shiftx = shiftx - cam->
shiftx;
37 const float width = corner_x * 2.0f;
38 return delta_shiftx * width;
79 PassMain background_ps_ = {
"background_ps_"};
82 PassMain foreground_ps_ = {
"foreground_ps_"};
85 PassMain background_scene_ps_ = {
"background_scene_ps_"};
87 PassMain foreground_scene_ps_ = {
"foreground_scene_ps_"};
89 View view_reference_images = {
"view_reference_images"};
90 float view_dist = 0.0f;
94 CameraInstanceBuf distances_buf = {selection_type_,
"camera_distances_buf"};
95 CameraInstanceBuf frame_buf = {selection_type_,
"camera_frame_buf"};
96 CameraInstanceBuf tria_buf = {selection_type_,
"camera_tria_buf"};
97 CameraInstanceBuf tria_wire_buf = {selection_type_,
"camera_tria_wire_buf"};
98 CameraInstanceBuf volume_buf = {selection_type_,
"camera_volume_buf"};
99 CameraInstanceBuf volume_wire_buf = {selection_type_,
"camera_volume_wire_buf"};
100 CameraInstanceBuf sphere_solid_buf = {selection_type_,
"camera_sphere_solid_buf"};
101 LinePrimitiveBuf stereo_connect_lines = {selection_type_,
"camera_dashed_lines_buf"};
102 LinePrimitiveBuf tracking_path = {selection_type_,
"camera_tracking_path_buf"};
103 Empties::CallBuffers empties{selection_type_};
106 static void view3d_reconstruction(
const select::ID select_id,
111 const bool is_select,
113 CallBuffers &call_buffers)
119 if (clip ==
nullptr) {
130 float4 bundle_color_custom;
131 float *bundle_color_solid =
G_draw.block.color_bundle_solid;
132 float *bundle_color_unselected =
G_draw.block.color_wire;
133 uchar4 text_color_selected, text_color_unselected;
141 const float4x4 object_to_world{ob->object_to_world().ptr()};
149 tracking_object_mat = camera_mat;
157 tracking, tracking_object, framenr, object_mat.
ptr());
159 tracking_object_mat = object_to_world *
math::invert(object_mat);
172 const float *bundle_color;
177 bundle_color_custom[3] = 1.0;
179 bundle_color = bundle_color_custom;
181 else if (is_solid_bundle) {
182 bundle_color = bundle_color_solid;
184 else if (is_selected) {
185 bundle_color =
color;
188 bundle_color = bundle_color_unselected;
191 const select::ID track_select_id = is_select ? res.
select_id(ob_ref, track_index++ << 16) :
193 if (is_solid_bundle) {
200 call_buffers.empties);
203 call_buffers.sphere_solid_buf.
append(
213 call_buffers.empties);
226 is_selected ? text_color_selected : text_color_unselected);
235 if (reconstruction->
camnr) {
238 for (
int a = 0; a < reconstruction->
camnr; a++,
camera++) {
260 const bool is_select,
263 CallBuffers &call_buffers)
274 if (!is_stereo3d_cameras) {
276 call_buffers.frame_buf.
append(instdata, select_id);
290 if (is_stereo3d_cameras) {
291 call_buffers.frame_buf.
append(stereodata, select_id);
300 if (is_stereo3d_volume && !is_select) {
301 float r = (eye == 1) ? 2.0f : 1.0f;
307 call_buffers.volume_wire_buf.
append(stereodata, select_id);
312 call_buffers.volume_buf.
append(stereodata, select_id);
319 if (is_stereo3d_plane && !is_select) {
350 stereodata.
volume_start = -cam->stereo.convergence_distance;
351 stereodata.
volume_end = -cam->stereo.convergence_distance;
354 call_buffers.volume_wire_buf.
append(stereodata, select_id);
359 call_buffers.volume_buf.
append(stereodata, select_id);
364 bool enabled_ =
false;
377 view_dist =
state.view_dist_get(
view.winmat());
379 call_buffers_.distances_buf.clear();
380 call_buffers_.frame_buf.clear();
381 call_buffers_.tria_buf.clear();
382 call_buffers_.tria_wire_buf.clear();
383 call_buffers_.volume_buf.clear();
384 call_buffers_.volume_wire_buf.clear();
385 call_buffers_.sphere_solid_buf.clear();
386 call_buffers_.stereo_connect_lines.clear();
387 call_buffers_.tracking_path.clear();
401 init_pass(background_ps_, draw_state);
404 init_pass(background_scene_ps_, draw_state);
407 init_pass(foreground_ps_, draw_state);
408 init_pass(foreground_scene_ps_, draw_state);
428 const bool is_select = call_buffers_.selection_type_ == SelectionType::ENABLED;
429 const bool is_active = (ob == camera_object);
430 const bool is_camera_view = (is_active && (rv3d->
persp ==
RV3D_CAMOB));
434 const bool is_stereo3d_display_extra = is_active && is_multiview && (!is_camera_view) &&
436 const bool is_selection_camera_stereo = is_select && is_camera_view && is_multiview &&
441 if (is_selection_camera_stereo) {
464 for (
int i = 0; i < 4; i++) {
467 mul_v2_fl(vecs[i], 1.0f / std::abs(vecs[i].
z));
471 const float2 center = (vecs[0].xy() + vecs[2].
xy()) * 0.5f;
472 const float2 corner = vecs[0].xy() - center.
xy();
473 data.corner_x = corner.x;
474 data.corner_y = corner.y;
475 data.center_x = center.x;
476 data.center_y = center.y;
477 data.depth = vecs[0].z;
479 if (is_camera_view) {
495 call_buffers_.frame_buf.append(
data, select_id);
500 if (is_stereo3d_display_extra) {
501 stereoscopy_extra(
data, select_id, scene, v3d, is_select, res, ob, call_buffers_);
504 call_buffers_.frame_buf.append(
data, select_id);
508 if (!is_camera_view) {
510 float tria_size = 0.7f * drawsize /
fabsf(
data.depth);
511 float tria_margin = 0.1f * drawsize /
fabsf(
data.depth);
512 data.center_x = center.x;
513 data.center_y = center.y +
data.corner_y + tria_margin + tria_size;
514 data.corner_x =
data.corner_y = -tria_size;
515 (is_active ? call_buffers_.tria_buf : call_buffers_.tria_wire_buf).append(
data, select_id);
520 data.matrix.x_axis() *= cam->drawsize;
521 data.matrix.y_axis() *= cam->drawsize;
523 data.dist_color_id = (is_active) ? 3 : 2;
525 data.clip_start = cam->clip_start;
526 data.clip_end = cam->clip_end;
527 call_buffers_.distances_buf.append(
data, select_id);
533 data.dist_color_id = (is_active) ? 1 : 0;
537 call_buffers_.distances_buf.append(
data, select_id);
543 view3d_reconstruction(select_id,
557 ob_ref, select_id, shapes, manager,
state, res, call_buffers_.selection_type_);
574 state.clipping_plane_count);
577 call_buffers_.volume_buf.end_sync(sub_pass, shapes.
camera_volume.get());
583 state.clipping_plane_count);
593 state.clipping_plane_count);
596 call_buffers_.distances_buf.end_sync(sub_pass, shapes.
camera_distances.get());
597 call_buffers_.frame_buf.end_sync(sub_pass, shapes.
camera_frame.get());
598 call_buffers_.tria_buf.end_sync(sub_pass, shapes.
camera_tria.get());
599 call_buffers_.tria_wire_buf.end_sync(sub_pass, shapes.
camera_tria_wire.get());
600 call_buffers_.sphere_solid_buf.end_sync(sub_pass, shapes.
sphere_low_detail.get());
606 state.clipping_plane_count);
609 call_buffers_.stereo_connect_lines.end_sync(sub_pass);
610 call_buffers_.tracking_path.end_sync(sub_pass);
655 view_reference_images.sync(
view.viewmat(),
658 manager.
submit(foreground_ps_, view_reference_images);
662 void sync_camera_images(
const ObjectRef &ob_ref,
675 if (!show_frame || selection_type != SelectionType::DISABLED) {
690 bool use_alpha_premult;
691 bool use_view_transform =
false;
696 bgpic,
state, res, aspect, use_alpha_premult, use_view_transform);
705 const float4 color_premult_alpha{1.0f, 1.0f, 1.0f, std::min(bgpic->alpha, 0.999999f)};
708 (use_view_transform ? foreground_scene_ps_ : foreground_ps_) :
709 (use_view_transform ? background_scene_ps_ : background_ps_);
710 pass.bind_texture(
"imgTexture", tex);
711 pass.push_constant(
"imgPremultiplied", use_alpha_premult);
712 pass.push_constant(
"imgAlphaBlend",
true);
713 pass.push_constant(
"isCameraBackground",
true);
714 pass.push_constant(
"depthSet",
true);
715 pass.push_constant(
"ucolor", color_premult_alpha);
717 pass.draw(shapes.
quad_solid.get(), res_handle, select_id.
get());
722 static void image_camera_background_matrix_get(
const Camera *cam,
725 const float image_aspect,
733 float cam_corners[4][3];
735 float cam_width =
fabsf(cam_corners[0][0] - cam_corners[3][0]);
736 float cam_height =
fabsf(cam_corners[0][1] - cam_corners[1][1]);
737 float cam_aspect = cam_width / cam_height;
741 if (image_aspect > cam_aspect) {
742 scale[0][0] *= cam_height * image_aspect;
743 scale[1][1] *= cam_height;
746 scale[0][0] *= cam_width;
747 scale[1][1] *= cam_width / image_aspect;
752 if (image_aspect > cam_aspect) {
753 scale[0][0] *= cam_width;
754 scale[1][1] *= cam_width / image_aspect;
757 scale[0][0] *= cam_height * image_aspect;
758 scale[1][1] *= cam_height;
763 scale[0][0] *= cam_width;
764 scale[1][1] *= cam_height;
775 translate[3][1] /=
max_ff(1.0f, cam_aspect) * (image_aspect / cam_aspect);
780 translate[3][0] += (cam_corners[0][0] + cam_corners[2][0]) * 0.5f;
781 translate[3][1] += (cam_corners[0][1] + cam_corners[2][1]) * 0.5f;
786 GPUTexture *image_camera_background_texture_get(
const CameraBGImage *bgpic,
790 bool &r_use_alpha_premult,
791 bool &r_use_view_transform)
796 GPUTexture *tex =
nullptr;
797 float aspect_x, aspect_y;
800 r_use_alpha_premult =
false;
801 r_use_view_transform =
false;
805 if (
image ==
nullptr) {
821 iuser->scene =
nullptr;
823 if (tex ==
nullptr) {
837 if (
state.scene->camera) {
845 if (clip ==
nullptr) {
851 if (tex ==
nullptr) {
855 aspect_x = clip->
aspx;
856 aspect_y = clip->
aspy;
857 r_use_view_transform =
true;
871 r_aspect = (width * aspect_x) / (height * aspect_y);
Camera data-block and utility functions.
float BKE_camera_multiview_shift_x(const struct RenderData *rd, const struct Object *camera, const char *viewname)
float BKE_camera_object_dof_distance(const struct Object *ob)
struct Object * BKE_camera_multiview_render(const struct Scene *scene, struct Object *camera, const char *viewname)
void BKE_camera_multiview_model_matrix(const struct RenderData *rd, const struct Object *camera, const char *viewname, float r_modelmat[4][4])
void BKE_camera_multiview_model_matrix_scaled(const struct RenderData *rd, const struct Object *camera, const char *viewname, float r_modelmat[4][4])
void BKE_camera_view_frame(const struct Scene *scene, const struct Camera *camera, float r_vec[4][3])
void BKE_camera_view_frame_ex(const struct Scene *scene, const struct Camera *camera, float drawsize, bool do_clip, const float scale[3], float r_asp[2], float r_shift[2], float *r_drawsize, float r_vec[4][3])
void BKE_image_user_frame_calc(Image *ima, ImageUser *iuser, int cfra)
GPUTexture * BKE_image_get_gpu_viewer_texture(Image *image, ImageUser *iuser)
float BKE_movieclip_remap_scene_to_clip_frame(const struct MovieClip *clip, float framenr)
void BKE_movieclip_user_set_frame(struct MovieClipUser *user, int framenr)
void BKE_movieclip_get_size(struct MovieClip *clip, const struct MovieClipUser *user, int *r_width, int *r_height)
struct GPUTexture * BKE_movieclip_get_gpu_texture(struct MovieClip *clip, struct MovieClipUser *cuser)
MovieClip * BKE_object_movieclip_get(Scene *scene, const Object *ob, bool use_default)
bool BKE_object_empty_image_frame_is_visible_in_view3d(const Object *ob, const RegionView3D *rv3d)
void BKE_tracking_get_camera_object_matrix(const struct Object *camera_object, float mat[4][4])
#define TRACK_SELECTED(track)
void BKE_tracking_camera_get_reconstructed_interpolate(struct MovieTracking *tracking, struct MovieTrackingObject *tracking_object, float framenr, float mat[4][4])
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
MINLINE float max_ff(float a, float b)
MINLINE float min_ff(float a, float b)
void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
void axis_angle_to_mat4_single(float R[4][4], char axis, float angle)
MINLINE void copy_v2_fl2(float v[2], float x, float y)
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
float DEG_get_ctime(const Depsgraph *graph)
Object * DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
struct CameraBGImage CameraBGImage
@ CAM_BGIMG_FLAG_CAMERA_CROP
@ CAM_BGIMG_FLAG_CAMERACLIP
@ CAM_BGIMG_FLAG_CAMERA_ASPECT
@ CAM_BGIMG_FLAG_DISABLED
@ CAM_BGIMG_FLAG_FOREGROUND
@ IMA_USER_FRAME_IN_RANGE
struct ImageUser ImageUser
struct MovieClipUser MovieClipUser
struct MovieClip MovieClip
@ SCE_VIEWS_FORMAT_STEREO_3D
#define STEREO_RIGHT_NAME
@ V3D_SHOW_RECONSTRUCTION
#define XRAY_FLAG_ENABLED(v3d)
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
int GPU_texture_original_height(const GPUTexture *texture)
int GPU_texture_original_width(const GPUTexture *texture)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between world
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between camera
void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
void append(const T &value)
void submit(PassSimple &pass, View &view)
ResourceHandle resource_handle(const ObjectRef &ref, float inflate_bounds=0.0f)
void state_set(DRWState state, int clip_plane_count=0)
void bind_ubo(const char *name, GPUUniformBuf *buffer)
void shader_set(GPUShader *shader)
detail::PassBase< command::DrawCommandBuf > Sub
void begin_sync(Resources &res, State &state, View &view)
void draw_background_images(Framebuffer &framebuffer, Manager &manager, View &view)
void draw(Framebuffer &framebuffer, Manager &manager, View &view)
void draw_scene_background_images(Framebuffer &framebuffer, Manager &manager, View &view)
void object_sync(const ObjectRef &ob_ref, ShapeCache &shapes, Manager &manager, Resources &res, State &state)
void draw_in_front(Framebuffer &framebuffer, Manager &manager, View &view)
void end_sync(Resources &res, ShapeCache &shapes, const State &state)
Cameras(const SelectionType selection_type)
void end_sync(Resources &res, ShapeCache &shapes, const State &state)
void object_sync(const ObjectRef &ob_ref, ShapeCache &shapes, Manager &manager, Resources &res, const State &state)
void begin_sync(Resources &res, const State &state, const View &view)
static void stereo_setup(const Scene *scene, const View3D *v3d, ::Image *ima, ImageUser *iuser)
static eStereoViews images_stereo_eye(const Scene *scene, const View3D *v3d)
BatchPtr camera_volume_wire
BatchPtr camera_tria_wire
BatchPtr sphere_low_detail
BatchPtr camera_distances
input_tx image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "preview_img") .compute_source("compositor_compute_preview.glsl") .do_static_compilation(true)
DRWTextStore * DRW_text_cache_ensure()
bool DRW_state_is_image_render()
const DRWContextState * DRW_context_state_get()
void DRW_text_cache_add(DRWTextStore *dt, const float co[3], const char *str, const int str_len, short xoffs, short yoffs, short flag, const uchar col[4], const bool shadow, const bool align_center)
@ DRW_TEXT_CACHE_GLOBALSPACE
@ DRW_TEXT_CACHE_STRING_PTR
@ DRW_STATE_BLEND_ALPHA_UNDER_PREMUL
@ DRW_STATE_DEPTH_LESS_EQUAL
@ DRW_STATE_BLEND_ALPHA_PREMUL
@ DRW_STATE_DEPTH_GREATER
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
static float4x4 winmat_polygon_offset(float4x4 winmat, float view_dist, float offset)
select::SelectionType SelectionType
detail::Pass< command::DrawCommandBuf > PassSimple
detail::Pass< command::DrawMultiBuf > PassMain
MatBase< T, NumCol, NumRow > scale(const MatBase< T, NumCol, NumRow > &mat, const VectorT &scale)
CartesianBasis invert(const CartesianBasis &basis)
AxisSigned cross(const AxisSigned a, const AxisSigned b)
MatBase< T, NumCol, NumRow > translate(const MatBase< T, NumCol, NumRow > &mat, const VectorT &translation)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
VecBase< T, 3 > to_scale(const MatBase< T, NumCol, NumRow > &mat)
MatBase< T, NumCol, NumRow > rotate(const MatBase< T, NumCol, NumRow > &mat, const RotationT &rotation)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
MatBase< float, 4, 4 > float4x4
blender::VecBase< uint8_t, 4 > uchar4
ListBaseWrapperTemplate< const ListBase, const T > ConstListBaseWrapper
VecBase< float, 4 > float4
VecBase< float, 2 > float2
ListBaseWrapperTemplate< ListBase, T > ListBaseWrapper
MatBase< float, 4, 3 > float4x3
VecBase< float, 3 > float3
static void image_camera_background_matrix_get(const Camera *cam, const CameraBGImage *bgpic, const DRWContextState *draw_ctx, const float image_aspect, float rmat[4][4])
static GPUTexture * image_camera_background_texture_get(CameraBGImage *bgpic, const DRWContextState *draw_ctx, OVERLAY_PrivateData *pd, float *r_aspect, bool *r_use_alpha_premult, bool *r_use_view_transform)
static float camera_offaxis_shiftx_get(const Scene *scene, const Object *ob, float corner_x, bool right_eye)
struct MovieClipUser cuser
struct CameraStereoSettings stereo
struct MovieTracking tracking
struct MovieReconstructedCamera * cameras
float stereo3d_volume_alpha
float stereo3d_convergence_alpha
const c_style_mat & ptr() const
static MatBase identity()
VecBase< T, 2 > xy() const
CameraInstanceData(const float4x4 &p_matrix, const float4 &color)
CameraInstanceData(const CameraInstanceData &data)
void append(const float3 &start, const float3 &end, const float4 &color, select::ID select_id=select::SelectMap::select_invalid_id())
const float4 & object_wire_color(const ObjectRef &ob_ref, ThemeColorID theme_id) const
GPUUniformBuf * globals_buf
Vector< MovieClip * > bg_movie_clips
GlobalsUboStorage theme_settings
void append(const InstanceDataT &data, select::ID select_id)
void select_bind(PassSimple &pass)
const ID select_id(const ObjectRef &ob_ref, uint sub_object_id=0)