2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2008 Blender Foundation. All rights reserved. */
|
2009-01-28 21:43:43 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup editors
|
2011-02-21 07:25:24 +00:00
|
|
|
*/
|
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#pragma once
|
2009-01-28 21:43:43 +00:00
|
|
|
|
2020-02-07 00:01:50 +01:00
|
|
|
#include "DNA_listBase.h"
|
|
|
|
|
#include "DNA_space_types.h"
|
|
|
|
|
|
2020-03-02 15:09:10 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-01-28 21:08:24 +11:00
|
|
|
struct ARegion;
|
|
|
|
|
struct ImBuf;
|
2009-02-21 19:17:31 +00:00
|
|
|
struct Image;
|
|
|
|
|
struct ImageUser;
|
2020-02-07 00:01:50 +01:00
|
|
|
struct Main;
|
2019-05-16 16:01:11 +02:00
|
|
|
struct ReportList;
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
struct Scene;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct SpaceImage;
|
2022-01-24 21:16:06 +11:00
|
|
|
struct View2D;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct bContext;
|
2022-06-08 12:37:29 -07:00
|
|
|
struct Paint;
|
2020-02-07 00:01:50 +01:00
|
|
|
struct wmOperator;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct wmWindowManager;
|
2021-09-29 17:47:32 +10:00
|
|
|
|
|
|
|
|
/* image_draw.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2022-01-07 11:38:08 +11:00
|
|
|
float ED_space_image_zoom_level(const struct View2D *v2d, int grid_dimension);
|
2021-09-29 17:47:32 +10:00
|
|
|
void ED_space_image_grid_steps(struct SpaceImage *sima,
|
|
|
|
|
float grid_steps[SI_GRID_STEPS_LEN],
|
2022-01-07 11:38:08 +11:00
|
|
|
int grid_dimension);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Calculate the increment snapping value for UV/image editor based on the zoom factor
|
|
|
|
|
* The code in here (except the offset part) is used in `grid_frag.glsl` (see `grid_res`) for
|
|
|
|
|
* drawing the grid overlay for the UV/Image editor.
|
|
|
|
|
*/
|
2022-01-07 11:38:08 +11:00
|
|
|
float ED_space_image_increment_snap_value(int grid_dimesnions,
|
2021-09-29 17:47:32 +10:00
|
|
|
const float grid_steps[SI_GRID_STEPS_LEN],
|
2022-01-07 11:38:08 +11:00
|
|
|
float zoom_factor);
|
2009-01-28 21:43:43 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/* image_edit.c, exported for transform. */
|
|
|
|
|
|
2021-10-19 12:22:06 +11:00
|
|
|
struct Image *ED_space_image(const struct SpaceImage *sima);
|
2019-03-11 12:44:14 +01:00
|
|
|
void ED_space_image_set(struct Main *bmain,
|
|
|
|
|
struct SpaceImage *sima,
|
|
|
|
|
struct Image *ima,
|
|
|
|
|
bool automatic);
|
|
|
|
|
void ED_space_image_auto_set(const struct bContext *C, struct SpaceImage *sima);
|
2021-10-19 12:22:06 +11:00
|
|
|
struct Mask *ED_space_image_get_mask(const struct SpaceImage *sima);
|
2012-07-25 10:39:54 +00:00
|
|
|
void ED_space_image_set_mask(struct bContext *C, struct SpaceImage *sima, struct Mask *mask);
|
2009-02-09 20:58:31 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Returns mouse position in image space.
|
|
|
|
|
*/
|
Compositor: Redesign Cryptomatte node for better usability
In the current implementation, cryptomatte passes are connected to the node
and elements are picked by using the eyedropper tool on a special pick channel.
This design has two disadvantages - both connecting all passes individually
and always having to switch to the picker channel are tedious.
With the new design, the user selects the RenderLayer or Image from which the
Cryptomatte layers are directly loaded (the type of pass is determined by an
enum). This allows the node to automatically detect all relevant passes.
Then, when using the eyedropper tool, the operator looks up the selected
coordinates from the picked Image, Node backdrop or Clip and reads the picked
object directly from the Renderlayer/Image, therefore allowing to pick in any
context (e.g. by clicking on the Combined pass in the Image Viewer). The
sampled color is looked up in the metadata and the actual name is stored
in the cryptomatte node. This also allows to remove a hash by just removing
the name from the matte id.
Technically there is some loss of flexibility because the Cryptomatte pass
inputs can no longer be connected to other nodes, but since any compositing
done on them is likely to break the Cryptomatte system anyways, this isn't
really a concern in practise.
In the future, this would also allow to automatically translate values to names
by looking up the value in the associated metadata of the input, or to get a
better visualization of overlapping areas in the Pick output since we could
blend colors now that the output doesn't have to contain the exact value.
Idea + Original patch: Lucas Stockner
Reviewed By: Brecht van Lommel
Differential Revision: https://developer.blender.org/D3959
2021-03-16 07:37:30 +01:00
|
|
|
bool ED_space_image_get_position(struct SpaceImage *sima,
|
|
|
|
|
struct ARegion *region,
|
|
|
|
|
int mval[2],
|
|
|
|
|
float fpos[2]);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Returns color in linear space, matching #ED_space_node_color_sample().
|
|
|
|
|
*/
|
2022-06-09 21:26:48 +10:00
|
|
|
bool ED_space_image_color_sample(struct SpaceImage *sima,
|
|
|
|
|
struct ARegion *region,
|
|
|
|
|
const int mval[2],
|
|
|
|
|
float r_col[3],
|
|
|
|
|
bool *r_is_data);
|
Add support for tiled images and the UDIM naming scheme
This patch contains the work that I did during my week at the Code Quest - adding support for tiled images to Blender.
With this patch, images now contain a list of tiles. By default, this just contains one tile, but if the source type is set to Tiled, the user can add additional tiles. When acquiring an ImBuf, the tile to be loaded is specified in the ImageUser.
Therefore, code that is not yet aware of tiles will just access the default tile as usual.
The filenames of the additional tiles are derived from the original filename according to the UDIM naming scheme - the filename contains an index that is calculated as (1001 + 10*<y coordinate of the tile> + <x coordinate of the tile>), where the x coordinate never goes above 9.
Internally, the various tiles are stored in a cache just like sequences. When acquired for the first time, the code will try to load the corresponding file from disk. Alternatively, a new operator can be used to initialize the tile similar to the New Image operator.
The following features are supported so far:
- Automatic detection and loading of all tiles when opening the first tile (1001)
- Saving all tiles
- Adding and removing tiles
- Filling tiles with generated images
- Drawing all tiles in the Image Editor
- Viewing a tiled grid even if no image is selected
- Rendering tiled images in Eevee
- Rendering tiled images in Cycles (in SVM mode)
- Automatically skipping loading of unused tiles in Cycles
- 2D texture painting (also across tiles)
- 3D texture painting (also across tiles, only limitation: individual faces can not cross tile borders)
- Assigning custom labels to individual tiles (drawn in the Image Editor instead of the ID)
- Different resolutions between tiles
There still are some missing features that will be added later (see T72390):
- Workbench engine support
- Packing/Unpacking support
- Baking support
- Cycles OSL support
- many other Blender features that rely on images
Thanks to Brecht for the review and to all who tested the intermediate versions!
Differential Revision: https://developer.blender.org/D3509
2019-12-12 16:06:08 +01:00
|
|
|
struct ImBuf *ED_space_image_acquire_buffer(struct SpaceImage *sima, void **r_lock, int tile);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Get the #SpaceImage flag that is valid for the given ibuf.
|
|
|
|
|
*/
|
2020-03-23 13:51:55 +01:00
|
|
|
int ED_space_image_get_display_channel_mask(struct ImBuf *ibuf);
|
2012-11-15 15:59:58 +00:00
|
|
|
void ED_space_image_release_buffer(struct SpaceImage *sima, struct ImBuf *ibuf, void *lock);
|
2014-01-28 03:52:21 +11:00
|
|
|
bool ED_space_image_has_buffer(struct SpaceImage *sima);
|
2009-09-30 18:18:32 +00:00
|
|
|
|
2020-03-25 17:58:58 +11:00
|
|
|
void ED_space_image_get_size(struct SpaceImage *sima, int *r_width, int *r_height);
|
|
|
|
|
void ED_space_image_get_size_fl(struct SpaceImage *sima, float r_size[2]);
|
|
|
|
|
void ED_space_image_get_aspect(struct SpaceImage *sima, float *r_aspx, float *r_aspy);
|
2012-07-25 16:30:53 +00:00
|
|
|
void ED_space_image_get_zoom(struct SpaceImage *sima,
|
2020-05-04 19:32:59 +10:00
|
|
|
const struct ARegion *region,
|
2020-03-25 17:58:58 +11:00
|
|
|
float *r_zoomx,
|
|
|
|
|
float *r_zoomy);
|
|
|
|
|
void ED_space_image_get_uv_aspect(struct SpaceImage *sima, float *r_aspx, float *r_aspy);
|
2009-01-28 21:43:43 +00:00
|
|
|
|
2015-01-12 14:21:23 +01:00
|
|
|
void ED_space_image_scopes_update(const struct bContext *C,
|
|
|
|
|
struct SpaceImage *sima,
|
|
|
|
|
struct ImBuf *ibuf,
|
|
|
|
|
bool use_view_settings);
|
|
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Enable the paint cursor if it isn't already.
|
|
|
|
|
*
|
|
|
|
|
* purpose is to make sure the paint cursor is shown if paint mode is enabled in the image editor.
|
|
|
|
|
* The paint poll will ensure that the cursor is hidden when not in paint mode.
|
|
|
|
|
*/
|
2018-06-11 11:05:37 +02:00
|
|
|
void ED_space_image_paint_update(struct Main *bmain,
|
|
|
|
|
struct wmWindowManager *wm,
|
|
|
|
|
struct Scene *scene);
|
2010-10-20 00:42:19 +00:00
|
|
|
|
2020-03-25 17:58:58 +11:00
|
|
|
void ED_image_get_uv_aspect(struct Image *ima,
|
|
|
|
|
struct ImageUser *iuser,
|
|
|
|
|
float *r_aspx,
|
|
|
|
|
float *r_aspy);
|
2021-12-09 00:55:11 +11:00
|
|
|
/** Takes `event->mval`. */
|
2012-07-27 15:15:55 +00:00
|
|
|
void ED_image_mouse_pos(struct SpaceImage *sima,
|
2020-05-04 19:32:59 +10:00
|
|
|
const struct ARegion *region,
|
2012-07-27 15:15:55 +00:00
|
|
|
const int mval[2],
|
|
|
|
|
float co[2]);
|
2019-10-01 20:19:44 +10:00
|
|
|
void ED_image_view_center_to_point(struct SpaceImage *sima, float x, float y);
|
2020-05-04 19:32:59 +10:00
|
|
|
void ED_image_point_pos(struct SpaceImage *sima,
|
|
|
|
|
const struct ARegion *region,
|
|
|
|
|
float x,
|
|
|
|
|
float y,
|
|
|
|
|
float *r_x,
|
|
|
|
|
float *r_y);
|
2012-07-26 09:54:52 +00:00
|
|
|
void ED_image_point_pos__reverse(struct SpaceImage *sima,
|
2020-05-04 19:32:59 +10:00
|
|
|
const struct ARegion *region,
|
2012-07-26 09:54:52 +00:00
|
|
|
const float co[2],
|
|
|
|
|
float r_co[2]);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* This is more a user-level functionality, for going to `next/prev` used slot,
|
|
|
|
|
* Stepping onto the last unused slot too.
|
|
|
|
|
*/
|
2015-11-16 07:13:40 +11:00
|
|
|
bool ED_image_slot_cycle(struct Image *image, int direction);
|
2009-02-09 20:58:31 +00:00
|
|
|
|
2021-10-08 17:07:56 +11:00
|
|
|
bool ED_space_image_show_render(const struct SpaceImage *sima);
|
|
|
|
|
bool ED_space_image_show_paint(const struct SpaceImage *sima);
|
|
|
|
|
bool ED_space_image_show_uvedit(const struct SpaceImage *sima, struct Object *obedit);
|
2009-02-09 20:58:31 +00:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
bool ED_space_image_paint_curve(const struct bContext *C);
|
|
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Matches clip function.
|
|
|
|
|
*/
|
2020-09-02 12:44:37 +10:00
|
|
|
bool ED_space_image_check_show_maskedit(struct SpaceImage *sima, struct Object *obedit);
|
2022-06-20 11:25:38 +02:00
|
|
|
|
|
|
|
|
/* Returns true when the following conditions are met:
|
|
|
|
|
* - Current space is Image Editor.
|
2022-06-20 10:14:00 -05:00
|
|
|
* - The image editor is not a UV Editor.
|
2022-06-20 11:25:38 +02:00
|
|
|
* - It is set to Mask mode.
|
|
|
|
|
*
|
|
|
|
|
* It is not required to have mask opened for editing. */
|
2018-07-02 11:47:00 +02:00
|
|
|
bool ED_space_image_maskedit_poll(struct bContext *C);
|
2022-06-20 11:25:38 +02:00
|
|
|
|
|
|
|
|
/* Returns true when the following conditions are met:
|
|
|
|
|
* - Current space is Image Editor.
|
2022-06-20 10:14:00 -05:00
|
|
|
* - The image editor is not a UV Editor.
|
2022-06-20 11:25:38 +02:00
|
|
|
* - It is set to Mask mode.
|
2022-06-16 10:13:03 +02:00
|
|
|
* - Mask has visible and editable splines.
|
|
|
|
|
*
|
|
|
|
|
* It is not required to have mask opened for editing. */
|
|
|
|
|
bool ED_space_image_maskedit_visible_splines_poll(struct bContext *C);
|
|
|
|
|
|
|
|
|
|
/* Returns true when the following conditions are met:
|
|
|
|
|
* - Current space is Image Editor.
|
|
|
|
|
* - The image editor is not an UV Editor.
|
|
|
|
|
* - It is set to Mask mode.
|
2022-06-20 11:25:38 +02:00
|
|
|
* - The space has mask opened. */
|
2018-07-02 11:47:00 +02:00
|
|
|
bool ED_space_image_maskedit_mask_poll(struct bContext *C);
|
2022-06-20 11:25:38 +02:00
|
|
|
|
2022-06-16 10:13:03 +02:00
|
|
|
/* Returns true when the following conditions are met:
|
|
|
|
|
* - Current space is Image Editor.
|
|
|
|
|
* - The image editor is not an UV Editor.
|
|
|
|
|
* - It is set to Mask mode.
|
|
|
|
|
* - The space has mask opened.
|
|
|
|
|
* - Mask has visible and editable splines. */
|
|
|
|
|
bool ED_space_image_maskedit_mask_visible_splines_poll(struct bContext *C);
|
|
|
|
|
|
2019-10-01 20:19:44 +10:00
|
|
|
bool ED_space_image_cursor_poll(struct bContext *C);
|
2012-07-25 10:39:54 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Used by node view too.
|
|
|
|
|
*/
|
2014-03-31 23:39:08 +11:00
|
|
|
void ED_image_draw_info(struct Scene *scene,
|
2020-03-06 16:56:42 +01:00
|
|
|
struct ARegion *region,
|
2014-03-31 23:39:08 +11:00
|
|
|
bool color_manage,
|
|
|
|
|
bool use_default_view,
|
|
|
|
|
int channels,
|
|
|
|
|
int x,
|
|
|
|
|
int y,
|
2013-03-18 11:34:05 +00:00
|
|
|
const unsigned char cp[4],
|
|
|
|
|
const float fp[4],
|
|
|
|
|
const float linearcol[4],
|
2020-07-13 11:27:09 +02:00
|
|
|
const int *zp,
|
|
|
|
|
const float *zpf);
|
2012-01-12 05:46:45 +00:00
|
|
|
|
2021-10-19 12:22:06 +11:00
|
|
|
bool ED_space_image_show_cache(const struct SpaceImage *sima);
|
|
|
|
|
bool ED_space_image_show_cache_and_mval_over(const struct SpaceImage *sima,
|
|
|
|
|
struct ARegion *region,
|
|
|
|
|
const int mval[2]);
|
2014-12-09 20:33:19 +05:00
|
|
|
|
2020-03-06 16:22:28 +01:00
|
|
|
bool ED_image_should_save_modified(const struct Main *bmain);
|
|
|
|
|
int ED_image_save_all_modified_info(const struct Main *bmain, struct ReportList *reports);
|
2019-05-16 16:01:11 +02:00
|
|
|
bool ED_image_save_all_modified(const struct bContext *C, struct ReportList *reports);
|
|
|
|
|
|
2020-02-07 00:01:50 +01:00
|
|
|
/* image_sequence.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2020-02-07 00:01:50 +01:00
|
|
|
typedef struct ImageFrameRange {
|
|
|
|
|
struct ImageFrameRange *next, *prev;
|
|
|
|
|
|
|
|
|
|
/** Absolute file path of the first file in the range. */
|
|
|
|
|
char filepath[FILE_MAX];
|
|
|
|
|
/* Sequence parameters. */
|
|
|
|
|
int length;
|
|
|
|
|
int offset;
|
|
|
|
|
/* UDIM tiles. */
|
2022-05-27 22:11:52 -07:00
|
|
|
bool udims_detected;
|
2020-02-07 00:01:50 +01:00
|
|
|
ListBase udim_tiles;
|
|
|
|
|
|
|
|
|
|
/* Temporary data. */
|
|
|
|
|
ListBase frames;
|
|
|
|
|
} ImageFrameRange;
|
|
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Used for both images and volume file loading.
|
|
|
|
|
*/
|
2020-02-07 00:01:50 +01:00
|
|
|
ListBase ED_image_filesel_detect_sequences(struct Main *bmain,
|
|
|
|
|
struct wmOperator *op,
|
2022-01-07 11:38:08 +11:00
|
|
|
bool detect_udim);
|
2020-02-07 00:01:50 +01:00
|
|
|
|
2022-06-08 12:37:29 -07:00
|
|
|
bool ED_image_tools_paint_poll(struct bContext *C);
|
|
|
|
|
void ED_paint_cursor_start(struct Paint *p, bool (*poll)(struct bContext *C));
|
|
|
|
|
|
2020-03-02 15:09:10 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|