75 float sca_x = 1.0f, sca_y = 1.0f;
85 const float scale_x_inv = ima_x * sca_x;
86 const float scale_y_inv = ima_y * sca_y;
87 if (scale_x_inv > scale_y_inv) {
88 r_image_aspect[0] = 1.0f;
89 r_image_aspect[1] = scale_y_inv / scale_x_inv;
92 r_image_aspect[0] = scale_x_inv / scale_y_inv;
93 r_image_aspect[1] = 1.0f;
121 iuser->
flag &= ~IMA_SHOW_STEREO;
129 bool *r_use_alpha_premult,
130 bool *r_use_view_transform)
135 GPUTexture *
tex =
nullptr;
137 float aspect_x, aspect_y;
140 *r_use_alpha_premult =
false;
141 *r_use_view_transform =
false;
145 if (image ==
nullptr) {
161 iuser->
scene =
nullptr;
163 if (
tex ==
nullptr) {
185 if (clip ==
nullptr) {
191 if (
tex ==
nullptr) {
195 aspect_x = clip->aspx;
196 aspect_y = clip->aspy;
197 *r_use_view_transform =
true;
211 *r_aspect = (width * aspect_x) / (height * aspect_y);
228 const float image_aspect,
231 float rotate[4][4], scale[4][4], translate[4][4];
238 float cam_corners[4][3];
240 float cam_width =
fabsf(cam_corners[0][0] - cam_corners[3][0]);
241 float cam_height =
fabsf(cam_corners[0][1] - cam_corners[1][1]);
242 float cam_aspect = cam_width / cam_height;
246 if (image_aspect > cam_aspect) {
247 scale[0][0] *= cam_height * image_aspect;
248 scale[1][1] *= cam_height;
251 scale[0][0] *= cam_width;
252 scale[1][1] *= cam_width / image_aspect;
257 if (image_aspect > cam_aspect) {
258 scale[0][0] *= cam_width;
259 scale[1][1] *= cam_width / image_aspect;
262 scale[0][0] *= cam_height * image_aspect;
263 scale[1][1] *= cam_height;
268 scale[0][0] *= cam_width;
269 scale[1][1] *= cam_height;
272 translate[3][0] = bgpic->
offset[0];
273 translate[3][1] = bgpic->
offset[1];
274 translate[3][2] = cam_corners[0][2];
279 translate[3][0] *=
min_ff(1.0f, cam_aspect);
280 translate[3][1] /=
max_ff(1.0f, cam_aspect) * (image_aspect / cam_aspect);
285 translate[3][0] += (cam_corners[0][0] + cam_corners[2][0]) * 0.5f;
286 translate[3][1] += (cam_corners[0][1] + cam_corners[2][1]) * 0.5f;
308 float modelmat[4][4];
317 bool use_alpha_premult;
318 bool use_view_transform =
false;
323 bgpic, draw_ctx, pd, &aspect, &use_alpha_premult, &use_view_transform);
332 const float color_premult_alpha[4] = {1.0f, 1.0f, 1.0f, std::min(bgpic->alpha, 0.999999f)};
357 GPUTexture *
tex =
nullptr;
374 if (ima !=
nullptr) {
386 float image_aspect[2];
405 switch (depth_mode) {
425 if (show_image &&
tex && ((ob->
color[3] > 0.0f) || !use_alpha_blend)) {
Camera data-block and utility functions.
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_view_frame(const struct Scene *scene, const struct Camera *camera, 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)
bool BKE_image_is_stereo(const Image *ima)
GPUTexture * BKE_image_get_gpu_texture(Image *image, ImageUser *iuser)
void BKE_image_multiview_index(const Image *ima, ImageUser *iuser)
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)
void BKE_movieclip_free_gputexture(struct MovieClip *clip)
General operations, lookup, etc. for blender objects.
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)
bool BKE_object_empty_image_data_is_visible_in_view3d(const Object *ob, const RegionView3D *rv3d)
#define LISTBASE_FOREACH(type, var, list)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
struct LinkData * BLI_genericNodeN(void *data)
void * BLI_pophead(ListBase *listbase) ATTR_NONNULL(1)
MINLINE float max_ff(float a, float b)
MINLINE float min_ff(float a, float b)
void unit_m4(float m[4][4])
#define mul_m4_series(...)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void axis_angle_to_mat4_single(float R[4][4], char axis, float angle)
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void mul_v3_fl(float r[3], float f)
float DEG_get_ctime(const Depsgraph *graph)
@ 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
@ OB_EMPTY_IMAGE_DEPTH_DEFAULT
@ OB_EMPTY_IMAGE_DEPTH_FRONT
@ OB_EMPTY_IMAGE_DEPTH_BACK
@ OB_EMPTY_IMAGE_USE_ALPHA_BLEND
#define STEREO_RIGHT_NAME
#define DRW_PASS_CREATE(pass, state)
#define DRW_shgroup_call_obmat(shgroup, geom, obmat)
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
int GPU_texture_original_height(const GPUTexture *texture)
int GPU_texture_original_width(const GPUTexture *texture)
Contains defines and structs used throughout the imbuf module.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
struct GPUShader GPUShader
blender::gpu::Batch * DRW_cache_quad_get()
int DRW_object_wire_theme_get(Object *ob, ViewLayer *view_layer, float **r_color)
DRWView * DRW_view_create_with_zoffset(const DRWView *parent_view, const RegionView3D *rv3d, float offset)
DefaultFramebufferList * DRW_viewport_framebuffer_list_get()
const DRWContextState * DRW_context_state_get()
bool DRW_state_is_select()
bool DRW_state_is_depth()
const DRWView * DRW_view_default_get()
DRWShadingGroup * DRW_shgroup_create(GPUShader *shader, DRWPass *pass)
void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
void DRW_pass_sort_shgroup_z(DRWPass *pass)
bool DRW_pass_is_empty(DRWPass *pass)
void DRW_shgroup_uniform_vec4_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
void DRW_shgroup_uniform_bool_copy(DRWShadingGroup *shgroup, const char *name, const bool value)
void DRW_draw_pass(DRWPass *pass)
void DRW_view_set_active(const DRWView *view)
@ 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
void MEM_freeN(void *vmemh)
static eStereoViews camera_background_images_stereo_eye(const Scene *scene, const View3D *v3d)
static void OVERLAY_image_free_movieclips_textures(OVERLAY_Data *data)
void OVERLAY_image_cache_init(OVERLAY_Data *vedata)
void OVERLAY_image_background_draw(OVERLAY_Data *vedata)
void OVERLAY_image_in_front_draw(OVERLAY_Data *vedata)
void OVERLAY_image_scene_background_draw(OVERLAY_Data *vedata)
void OVERLAY_image_camera_cache_populate(OVERLAY_Data *vedata, Object *ob)
void OVERLAY_image_cache_finish(OVERLAY_Data *vedata)
static void overlay_image_calc_aspect(Image *ima, const int size[2], float r_image_aspect[2])
void OVERLAY_image_draw(OVERLAY_Data *vedata)
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)
void OVERLAY_image_empty_cache_populate(OVERLAY_Data *vedata, Object *ob)
void OVERLAY_image_init(OVERLAY_Data *vedata)
static void camera_background_images_stereo_setup(const Scene *scene, const View3D *v3d, Image *ima, ImageUser *iuser)
GPUShader * OVERLAY_shader_image()
struct MovieClipUser cuser
struct ListBase bg_images
GPUFrameBuffer * default_fb
OVERLAY_StorageList * stl
DRWPass * image_background_scene_ps
DRWPass * image_empties_front_ps
DRWPass * image_empties_ps
DRWPass * image_foreground_scene_ps
DRWPass * image_background_ps
DRWPass * image_empties_blend_ps
DRWPass * image_foreground_ps
DRWPass * image_empties_back_ps
DRWView * view_reference_images