2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-11-30 18:39:49 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-11-30 18:39:49 +00:00
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup RNA
|
2011-02-27 20:20:01 +00:00
|
|
|
*/
|
|
|
|
|
|
2008-11-30 18:39:49 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#include "DNA_image_types.h"
|
2019-02-18 13:23:49 +01:00
|
|
|
#include "DNA_node_types.h"
|
2008-11-30 18:39:49 +00:00
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
2013-03-07 02:44:55 +00:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
2008-11-30 18:39:49 +00:00
|
|
|
#include "BKE_image.h"
|
|
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
2019-02-20 13:52:10 +01:00
|
|
|
#include "DEG_depsgraph_build.h"
|
2017-06-08 10:14:53 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
#include "RNA_access.h"
|
2013-03-07 02:44:55 +00:00
|
|
|
#include "RNA_define.h"
|
|
|
|
|
#include "RNA_enum_types.h"
|
|
|
|
|
|
|
|
|
|
#include "rna_internal.h"
|
|
|
|
|
|
2011-12-30 14:17:11 +00:00
|
|
|
#include "WM_api.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "WM_types.h"
|
2009-06-23 00:45:41 +00:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem rna_enum_image_generated_type_items[] = {
|
2012-08-29 08:17:38 +00:00
|
|
|
{IMA_GENTYPE_BLANK, "BLANK", 0, "Blank", "Generate a blank image"},
|
|
|
|
|
{IMA_GENTYPE_GRID, "UV_GRID", 0, "UV Grid", "Generated grid to test UV mappings"},
|
|
|
|
|
{IMA_GENTYPE_GRID_COLOR,
|
|
|
|
|
"COLOR_GRID",
|
|
|
|
|
0,
|
|
|
|
|
"Color Grid",
|
|
|
|
|
"Generated improved UV grid to test UV mappings"},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2012-08-29 08:17:38 +00:00
|
|
|
};
|
|
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem image_source_items[] = {
|
2011-04-28 12:43:28 +00:00
|
|
|
{IMA_SRC_FILE, "FILE", 0, "Single Image", "Single image file"},
|
|
|
|
|
{IMA_SRC_SEQUENCE, "SEQUENCE", 0, "Image Sequence", "Multiple image files, as a sequence"},
|
2012-03-02 21:14:37 +00:00
|
|
|
{IMA_SRC_MOVIE, "MOVIE", 0, "Movie", "Movie file"},
|
2009-09-16 19:27:08 +00:00
|
|
|
{IMA_SRC_GENERATED, "GENERATED", 0, "Generated", "Generated image"},
|
|
|
|
|
{IMA_SRC_VIEWER, "VIEWER", 0, "Viewer", "Compositing node viewer"},
|
2020-03-25 23:27:44 +01:00
|
|
|
{IMA_SRC_TILED, "TILED", 0, "UDIM Tiles", "Tiled UDIM image texture"},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2009-09-16 19:27:08 +00:00
|
|
|
|
2008-11-30 18:39:49 +00:00
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
|
|
2019-01-26 20:41:52 +11:00
|
|
|
# include "BLI_math_base.h"
|
|
|
|
|
|
2016-03-08 14:56:22 +05:00
|
|
|
# include "BKE_global.h"
|
|
|
|
|
|
2018-06-11 22:30:59 +02:00
|
|
|
# include "GPU_texture.h"
|
2016-03-08 14:56:22 +05:00
|
|
|
|
2012-05-26 14:53:33 +00:00
|
|
|
# include "IMB_imbuf.h"
|
2009-06-30 19:10:14 +00:00
|
|
|
# include "IMB_imbuf_types.h"
|
|
|
|
|
|
2019-02-18 13:23:49 +01:00
|
|
|
# include "ED_node.h"
|
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Image_is_stereo_3d_get(PointerRNA *ptr)
|
2015-10-11 01:14:02 +02:00
|
|
|
{
|
|
|
|
|
return BKE_image_is_stereo((Image *)ptr->data);
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Image_is_multiview_get(PointerRNA *ptr)
|
2015-10-11 01:14:02 +02:00
|
|
|
{
|
|
|
|
|
return BKE_image_is_multiview((Image *)ptr->data);
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Image_dirty_get(PointerRNA *ptr)
|
2009-06-30 19:10:14 +00:00
|
|
|
{
|
2013-12-13 16:22:08 +06:00
|
|
|
return BKE_image_is_dirty((Image *)ptr->data);
|
2009-06-30 19:10:14 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-24 17:21:22 +00:00
|
|
|
static void rna_Image_source_set(PointerRNA *ptr, int value)
|
2009-09-16 19:27:08 +00:00
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
Image *ima = (Image *)ptr->owner_id;
|
2013-01-24 17:21:22 +00:00
|
|
|
|
|
|
|
|
if (value != ima->source) {
|
|
|
|
|
ima->source = value;
|
2018-11-09 10:44:02 -02:00
|
|
|
BLI_assert(BKE_id_is_in_global_main(&ima->id));
|
2018-06-22 12:35:41 +02:00
|
|
|
BKE_image_signal(G_MAIN, ima, NULL, IMA_SIGNAL_SRC_CHANGE);
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&ima->id, 0);
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ima->id, ID_RECALC_EDITORS);
|
2019-02-20 13:52:10 +01:00
|
|
|
DEG_relations_tag_update(G_MAIN);
|
2013-01-24 17:21:22 +00:00
|
|
|
}
|
2009-09-16 19:27:08 +00:00
|
|
|
}
|
|
|
|
|
|
2018-06-11 15:40:37 +02:00
|
|
|
static void rna_Image_reload_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
|
2009-09-16 19:27:08 +00:00
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
Image *ima = (Image *)ptr->owner_id;
|
2018-06-11 15:40:37 +02:00
|
|
|
BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_RELOAD);
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id);
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&ima->id, 0);
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ima->id, ID_RECALC_EDITORS);
|
2009-09-16 19:27:08 +00:00
|
|
|
}
|
|
|
|
|
|
2018-06-11 15:40:37 +02:00
|
|
|
static void rna_Image_generated_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
|
2012-12-31 13:52:13 +00:00
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
Image *ima = (Image *)ptr->owner_id;
|
2018-06-11 15:40:37 +02:00
|
|
|
BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_FREE);
|
2012-12-31 13:52:13 +00:00
|
|
|
}
|
|
|
|
|
|
2018-06-11 15:40:37 +02:00
|
|
|
static void rna_Image_colormanage_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
|
2009-09-16 19:27:08 +00:00
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
Image *ima = (Image *)ptr->owner_id;
|
2018-06-11 15:40:37 +02:00
|
|
|
BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_COLORMANAGE);
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&ima->id, 0);
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ima->id, ID_RECALC_EDITORS);
|
2012-12-31 15:45:31 +00:00
|
|
|
WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id);
|
|
|
|
|
WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id);
|
2009-09-16 19:27:08 +00:00
|
|
|
}
|
|
|
|
|
|
2018-06-11 15:40:37 +02:00
|
|
|
static void rna_Image_views_format_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
Image *ima = (Image *)ptr->owner_id;
|
2015-04-06 10:40:12 -03:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
void *lock;
|
|
|
|
|
|
|
|
|
|
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
|
|
|
|
|
|
|
|
|
if (ibuf) {
|
|
|
|
|
ImageUser iuser = {NULL};
|
|
|
|
|
iuser.scene = scene;
|
2018-06-11 15:40:37 +02:00
|
|
|
BKE_image_signal(bmain, ima, &iuser, IMA_SIGNAL_FREE);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_image_release_ibuf(ima, ibuf, lock);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-18 13:23:49 +01:00
|
|
|
static void rna_ImageUser_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
2009-09-16 19:27:08 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ImageUser *iuser = ptr->data;
|
2019-08-23 09:52:12 +02:00
|
|
|
ID *id = ptr->owner_id;
|
2009-09-16 19:27:08 +00:00
|
|
|
|
2019-06-17 11:39:52 +02:00
|
|
|
BKE_image_user_frame_calc(NULL, iuser, scene->r.cfra);
|
2017-11-07 02:27:27 +01:00
|
|
|
|
2019-02-18 13:23:49 +01:00
|
|
|
if (id) {
|
|
|
|
|
if (GS(id->name) == ID_NT) {
|
|
|
|
|
/* Special update for nodetrees to find parent datablock. */
|
|
|
|
|
ED_node_tag_update_nodetree(bmain, (bNodeTree *)id, NULL);
|
|
|
|
|
}
|
2019-02-20 08:26:17 +11:00
|
|
|
else {
|
2019-02-18 13:23:49 +01:00
|
|
|
/* Update material or texture for render preview. */
|
|
|
|
|
DEG_id_tag_update(id, 0);
|
|
|
|
|
DEG_id_tag_update(id, ID_RECALC_EDITORS);
|
|
|
|
|
}
|
2017-11-07 02:27:27 +01:00
|
|
|
}
|
2009-09-16 19:27:08 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-01 02:12:40 +01:00
|
|
|
static void rna_ImageUser_relations_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
rna_ImageUser_update(bmain, scene, ptr);
|
|
|
|
|
DEG_relations_tag_update(bmain);
|
|
|
|
|
}
|
2010-09-20 09:52:29 +00:00
|
|
|
|
2012-09-22 14:07:55 +00:00
|
|
|
static char *rna_ImageUser_path(PointerRNA *ptr)
|
2010-09-20 09:52:29 +00:00
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
if (ptr->owner_id) {
|
2012-10-26 04:14:10 +00:00
|
|
|
/* ImageUser *iuser = ptr->data; */
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2019-08-23 09:52:12 +02:00
|
|
|
switch (GS(ptr->owner_id->name)) {
|
2014-01-13 21:57:05 +01:00
|
|
|
case ID_OB:
|
2013-07-19 10:40:43 +00:00
|
|
|
case ID_TE: {
|
2012-05-12 11:01:29 +00:00
|
|
|
return BLI_strdup("image_user");
|
2013-07-02 15:56:32 +00:00
|
|
|
}
|
2013-07-19 10:40:43 +00:00
|
|
|
case ID_NT: {
|
2013-07-02 15:56:32 +00:00
|
|
|
return rna_Node_ImageUser_path(ptr);
|
|
|
|
|
}
|
2017-08-28 11:19:58 +02:00
|
|
|
default:
|
|
|
|
|
break;
|
2010-09-20 09:52:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2010-09-20 09:52:29 +00:00
|
|
|
return BLI_strdup("");
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-25 17:18:25 +01:00
|
|
|
static void rna_Image_gpu_texture_update(Main *UNUSED(bmain),
|
|
|
|
|
Scene *UNUSED(scene),
|
|
|
|
|
PointerRNA *ptr)
|
2020-02-25 15:05:53 +01:00
|
|
|
{
|
|
|
|
|
Image *ima = (Image *)ptr->owner_id;
|
|
|
|
|
|
|
|
|
|
if (!G.background) {
|
2020-07-29 18:13:19 +02:00
|
|
|
BKE_image_free_gputextures(ima);
|
2020-02-25 15:05:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id);
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-02 17:03:45 +11:00
|
|
|
static const EnumPropertyItem *rna_Image_source_itemf(bContext *UNUSED(C),
|
|
|
|
|
PointerRNA *ptr,
|
|
|
|
|
PropertyRNA *UNUSED(prop),
|
|
|
|
|
bool *r_free)
|
2009-09-16 19:27:08 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Image *ima = (Image *)ptr->data;
|
2012-03-05 23:30:41 +00:00
|
|
|
EnumPropertyItem *item = NULL;
|
|
|
|
|
int totitem = 0;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ima->source == IMA_SRC_VIEWER) {
|
2009-09-16 19:27:08 +00:00
|
|
|
RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_VIEWER);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_FILE);
|
|
|
|
|
RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_SEQUENCE);
|
|
|
|
|
RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_MOVIE);
|
|
|
|
|
RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_GENERATED);
|
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
|
|
|
RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_TILED);
|
2009-09-16 19:27:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RNA_enum_item_end(&item, &totitem);
|
2014-01-04 18:08:43 +11:00
|
|
|
*r_free = true;
|
2009-09-16 19:27:08 +00:00
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-07 20:27:40 +00:00
|
|
|
static int rna_Image_file_format_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Image *image = (Image *)ptr->data;
|
2012-11-15 15:59:58 +00:00
|
|
|
ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL);
|
2020-11-13 20:25:21 +11:00
|
|
|
int imtype = BKE_image_ftype_to_imtype(ibuf ? ibuf->ftype : IMB_FTYPE_NONE,
|
|
|
|
|
ibuf ? &ibuf->foptions : NULL);
|
2012-11-15 15:59:58 +00:00
|
|
|
|
|
|
|
|
BKE_image_release_ibuf(image, ibuf, NULL);
|
|
|
|
|
|
|
|
|
|
return imtype;
|
2010-03-07 20:27:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Image_file_format_set(PointerRNA *ptr, int value)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Image *image = (Image *)ptr->data;
|
2012-03-05 23:30:41 +00:00
|
|
|
if (BKE_imtype_is_movie(value) == 0) { /* should be able to throw an error here */
|
2015-07-13 13:58:17 +02:00
|
|
|
ImbFormatOptions options;
|
|
|
|
|
int ftype = BKE_image_imtype_to_ftype(value, &options);
|
|
|
|
|
BKE_image_file_format_set(image, ftype, &options);
|
2010-03-07 20:27:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
static void rna_UDIMTile_label_get(PointerRNA *ptr, char *value)
|
|
|
|
|
{
|
|
|
|
|
ImageTile *tile = (ImageTile *)ptr->data;
|
|
|
|
|
Image *image = (Image *)ptr->owner_id;
|
|
|
|
|
|
|
|
|
|
/* We don't know the length of the target string here, so we assume
|
|
|
|
|
* that it has been allocated according to what rna_UDIMTile_label_length returned. */
|
|
|
|
|
BKE_image_get_tile_label(image, tile, value, sizeof(tile->label));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int rna_UDIMTile_label_length(PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
ImageTile *tile = (ImageTile *)ptr->data;
|
|
|
|
|
Image *image = (Image *)ptr->owner_id;
|
|
|
|
|
|
|
|
|
|
char label[sizeof(tile->label)];
|
|
|
|
|
BKE_image_get_tile_label(image, tile, label, sizeof(label));
|
|
|
|
|
|
|
|
|
|
return strlen(label);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_UDIMTile_tile_number_set(PointerRNA *ptr, int value)
|
|
|
|
|
{
|
|
|
|
|
ImageTile *tile = (ImageTile *)ptr->data;
|
|
|
|
|
Image *image = (Image *)ptr->owner_id;
|
|
|
|
|
|
|
|
|
|
/* The index of the first tile can't be changed. */
|
|
|
|
|
if (tile->tile_number == 1001) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check that no other tile already has that number. */
|
|
|
|
|
ImageTile *cur_tile = BKE_image_get_tile(image, value);
|
|
|
|
|
if (cur_tile == NULL || cur_tile == tile) {
|
|
|
|
|
tile->tile_number = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int rna_Image_active_tile_index_get(PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
Image *image = (Image *)ptr->data;
|
|
|
|
|
return image->active_tile_index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Image_active_tile_index_set(PointerRNA *ptr, int value)
|
|
|
|
|
{
|
|
|
|
|
Image *image = (Image *)ptr->data;
|
|
|
|
|
int num_tiles = BLI_listbase_count(&image->tiles);
|
|
|
|
|
|
|
|
|
|
image->active_tile_index = min_ii(value, num_tiles - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Image_active_tile_index_range(
|
|
|
|
|
PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
|
|
|
|
|
{
|
|
|
|
|
Image *image = (Image *)ptr->data;
|
|
|
|
|
int num_tiles = BLI_listbase_count(&image->tiles);
|
|
|
|
|
|
|
|
|
|
*min = 0;
|
|
|
|
|
*max = max_ii(0, num_tiles - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PointerRNA rna_Image_active_tile_get(PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
Image *image = (Image *)ptr->data;
|
|
|
|
|
ImageTile *tile = BLI_findlink(&image->tiles, image->active_tile_index);
|
|
|
|
|
|
|
|
|
|
return rna_pointer_inherit_refine(ptr, &RNA_UDIMTile, tile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Image_active_tile_set(PointerRNA *ptr,
|
|
|
|
|
PointerRNA value,
|
|
|
|
|
struct ReportList *UNUSED(reports))
|
|
|
|
|
{
|
|
|
|
|
Image *image = (Image *)ptr->data;
|
|
|
|
|
ImageTile *tile = (ImageTile *)value.data;
|
|
|
|
|
const int index = BLI_findindex(&image->tiles, tile);
|
2019-12-17 09:51:38 +11:00
|
|
|
if (index != -1) {
|
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
|
|
|
image->active_tile_index = index;
|
2019-12-17 09:51:38 +11:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Image_has_data_get(PointerRNA *ptr)
|
2009-07-03 17:44:20 +00:00
|
|
|
{
|
2013-12-13 16:22:08 +06:00
|
|
|
Image *image = (Image *)ptr->data;
|
2009-07-03 17:44:20 +00:00
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
return BKE_image_has_loaded_ibuf(image);
|
2009-07-03 17:44:20 +00:00
|
|
|
}
|
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
static void rna_Image_size_get(PointerRNA *ptr, int *values)
|
2010-01-06 10:46:49 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Image *im = (Image *)ptr->data;
|
2010-01-06 10:46:49 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
void *lock;
|
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(im, NULL, &lock);
|
2010-01-06 10:46:49 +00:00
|
|
|
if (ibuf) {
|
2012-03-05 23:30:41 +00:00
|
|
|
values[0] = ibuf->x;
|
|
|
|
|
values[1] = ibuf->y;
|
2010-01-06 10:46:49 +00:00
|
|
|
}
|
2010-03-22 09:30:00 +00:00
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
values[0] = 0;
|
|
|
|
|
values[1] = 0;
|
2010-01-06 10:46:49 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_image_release_ibuf(im, ibuf, lock);
|
2010-01-06 10:46:49 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-13 14:27:12 +00:00
|
|
|
static void rna_Image_resolution_get(PointerRNA *ptr, float *values)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Image *im = (Image *)ptr->data;
|
2011-05-13 14:27:12 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
void *lock;
|
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(im, NULL, &lock);
|
2011-05-13 14:27:12 +00:00
|
|
|
if (ibuf) {
|
2012-03-05 23:30:41 +00:00
|
|
|
values[0] = ibuf->ppm[0];
|
|
|
|
|
values[1] = ibuf->ppm[1];
|
2011-05-13 14:27:12 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
values[0] = 0;
|
|
|
|
|
values[1] = 0;
|
2011-05-13 14:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_image_release_ibuf(im, ibuf, lock);
|
2011-05-13 14:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Image_resolution_set(PointerRNA *ptr, const float *values)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Image *im = (Image *)ptr->data;
|
2011-05-13 14:27:12 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
void *lock;
|
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(im, NULL, &lock);
|
2011-05-13 14:27:12 +00:00
|
|
|
if (ibuf) {
|
2012-03-05 23:30:41 +00:00
|
|
|
ibuf->ppm[0] = values[0];
|
|
|
|
|
ibuf->ppm[1] = values[1];
|
2011-05-13 14:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_image_release_ibuf(im, ibuf, lock);
|
2011-05-13 14:27:12 +00:00
|
|
|
}
|
2010-01-06 10:46:49 +00:00
|
|
|
|
2018-06-11 22:30:59 +02:00
|
|
|
static int rna_Image_bindcode_get(PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
Image *ima = (Image *)ptr->data;
|
2020-07-26 20:20:03 +02:00
|
|
|
GPUTexture *tex = ima->gputexture[TEXTARGET_2D][0];
|
2018-06-11 22:30:59 +02:00
|
|
|
return (tex) ? GPU_texture_opengl_bindcode(tex) : 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-03 17:44:20 +00:00
|
|
|
static int rna_Image_depth_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Image *im = (Image *)ptr->data;
|
2009-09-30 18:18:32 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
void *lock;
|
2011-11-21 20:47:19 +00:00
|
|
|
int planes;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(im, NULL, &lock);
|
2009-07-03 17:44:20 +00:00
|
|
|
|
2019-06-04 00:21:57 +10:00
|
|
|
if (!ibuf) {
|
2012-03-05 23:30:41 +00:00
|
|
|
planes = 0;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
|
|
|
|
else if (ibuf->rect_float) {
|
2012-03-05 23:30:41 +00:00
|
|
|
planes = ibuf->planes * 4;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
planes = ibuf->planes;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
2009-07-03 17:44:20 +00:00
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_image_release_ibuf(im, ibuf, lock);
|
2009-07-03 17:44:20 +00:00
|
|
|
|
2011-11-21 20:47:19 +00:00
|
|
|
return planes;
|
2009-07-03 17:44:20 +00:00
|
|
|
}
|
|
|
|
|
|
2012-05-26 14:53:33 +00:00
|
|
|
static int rna_Image_frame_duration_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
Image *ima = (Image *)ptr->owner_id;
|
2015-01-02 22:49:00 +01:00
|
|
|
int duration = 1;
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (BKE_image_has_anim(ima)) {
|
2019-05-20 13:43:25 +02:00
|
|
|
struct anim *anim = ((ImageAnim *)ima->anims.first)->anim;
|
|
|
|
|
if (anim) {
|
|
|
|
|
duration = IMB_anim_get_duration(anim, IMB_TC_RECORD_RUN);
|
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
else {
|
2015-01-02 22:49:00 +01:00
|
|
|
/* acquire ensures ima->anim is set, if possible! */
|
|
|
|
|
void *lock;
|
|
|
|
|
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
|
|
|
|
BKE_image_release_ibuf(ima, ibuf, lock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return duration;
|
2012-05-26 14:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
2011-04-03 16:17:39 +00:00
|
|
|
static int rna_Image_pixels_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
|
|
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
Image *ima = (Image *)ptr->owner_id;
|
2011-04-03 16:17:39 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
void *lock;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
2011-04-03 16:17:39 +00:00
|
|
|
|
2019-06-04 00:21:57 +10:00
|
|
|
if (ibuf) {
|
2012-05-12 11:01:29 +00:00
|
|
|
length[0] = ibuf->x * ibuf->y * ibuf->channels;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
length[0] = 0;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
2011-04-03 16:17:39 +00:00
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_image_release_ibuf(ima, ibuf, lock);
|
2011-04-03 16:17:39 +00:00
|
|
|
|
2011-04-04 17:10:48 +00:00
|
|
|
return length[0];
|
2011-04-03 16:17:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Image_pixels_get(PointerRNA *ptr, float *values)
|
|
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
Image *ima = (Image *)ptr->owner_id;
|
2011-04-03 16:17:39 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
void *lock;
|
|
|
|
|
int i, size;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
2011-04-03 16:17:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ibuf) {
|
2012-05-12 11:01:29 +00:00
|
|
|
size = ibuf->x * ibuf->y * ibuf->channels;
|
2011-04-03 16:17:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ibuf->rect_float) {
|
2012-05-12 11:01:29 +00:00
|
|
|
memcpy(values, ibuf->rect_float, sizeof(float) * size);
|
2011-04-03 16:17:39 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2019-06-04 00:21:57 +10:00
|
|
|
for (i = 0; i < size; i++) {
|
2012-05-12 11:01:29 +00:00
|
|
|
values[i] = ((unsigned char *)ibuf->rect)[i] * (1.0f / 255.0f);
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
2011-04-03 16:17:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_image_release_ibuf(ima, ibuf, lock);
|
2011-04-03 16:17:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Image_pixels_set(PointerRNA *ptr, const float *values)
|
|
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
Image *ima = (Image *)ptr->owner_id;
|
2011-04-03 16:17:39 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
void *lock;
|
|
|
|
|
int i, size;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
2011-04-03 16:17:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ibuf) {
|
2012-05-12 11:01:29 +00:00
|
|
|
size = ibuf->x * ibuf->y * ibuf->channels;
|
2011-04-03 16:17:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ibuf->rect_float) {
|
2012-05-12 11:01:29 +00:00
|
|
|
memcpy(ibuf->rect_float, values, sizeof(float) * size);
|
2011-04-03 16:17:39 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2019-06-04 00:21:57 +10:00
|
|
|
for (i = 0; i < size; i++) {
|
2018-05-07 17:31:28 +02:00
|
|
|
((unsigned char *)ibuf->rect)[i] = unit_float_to_uchar_clamp(values[i]);
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
2011-04-03 16:17:39 +00:00
|
|
|
}
|
2011-04-06 12:54:47 +00:00
|
|
|
|
2019-05-14 17:28:13 +02:00
|
|
|
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID | IB_MIPMAP_INVALID;
|
|
|
|
|
BKE_image_mark_dirty(ima, ibuf);
|
2016-03-08 14:56:22 +05:00
|
|
|
if (!G.background) {
|
2020-07-29 18:13:19 +02:00
|
|
|
BKE_image_free_gputextures(ima);
|
2016-03-08 14:56:22 +05:00
|
|
|
}
|
|
|
|
|
WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id);
|
2011-04-03 16:17:39 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_image_release_ibuf(ima, ibuf, lock);
|
2011-04-03 16:17:39 +00:00
|
|
|
}
|
|
|
|
|
|
Packed and generated images support for Cycles
This commit adds support of packed and generated images
for Cycles when using SVM backend. Movies are still not
supported. This changes also doesn't touch OSL which is
much less trivial to adopt for any images which are not
saved to disk.
Implementation details:
- When adding images to Image Manager is now possible
to mark image as builtin. Builtin images will bypass
OIIO loader and will use special loading callbacks.
- Callbacks are set by Blender Session and they're
using C++ RNA interface to obtain needed data (pixels,
dimensions, is_float flag).
- Image Manager assumes file path is used as reference
to a builtin images, but in fact currently image
datablock name is used for reference. This makes it
easy to find an image in BlendData database.
- Added some extra properties to Image RNA:
* channels, which denotes actual number of channels
in ImBuf. This is needed to treat image's pixels
correct (before it wasn't possible because API
used internal number of channels for pixels which
is in fact doesn't correlate with image depth)
* is_float, which is truth if image is stored in
float buffer of ImBuf.
- Implemented string lookup for C++ RNA collections
for cases there's no manual lookup function.
OSL is not supported because it used own image loading
and filtering routines and there's seems to be no API
to feed pre-loaded pixels directly to the library.
Think we'll either need to add some API to support
such kind of feeding or consider OSL does not have
support of packed images at all.
Movies are not supported at this moment because of lack
of RNA API to load specified frame. It's not difficult
to solve, just need to consider what to best here:
* Either write some general python interface for ImBuf
and use it via C++ API, or
* Write a PY API function which will return pixels for
given frame, or
* Use bad-level BKE_* call
Anyway, small steps, further improvements later.
Reviewed by Brecht, thanks!
2013-01-12 10:59:13 +00:00
|
|
|
static int rna_Image_channels_get(PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
Image *im = (Image *)ptr->data;
|
|
|
|
|
ImBuf *ibuf;
|
|
|
|
|
void *lock;
|
|
|
|
|
int channels = 0;
|
|
|
|
|
|
|
|
|
|
ibuf = BKE_image_acquire_ibuf(im, NULL, &lock);
|
2019-06-04 00:21:57 +10:00
|
|
|
if (ibuf) {
|
Packed and generated images support for Cycles
This commit adds support of packed and generated images
for Cycles when using SVM backend. Movies are still not
supported. This changes also doesn't touch OSL which is
much less trivial to adopt for any images which are not
saved to disk.
Implementation details:
- When adding images to Image Manager is now possible
to mark image as builtin. Builtin images will bypass
OIIO loader and will use special loading callbacks.
- Callbacks are set by Blender Session and they're
using C++ RNA interface to obtain needed data (pixels,
dimensions, is_float flag).
- Image Manager assumes file path is used as reference
to a builtin images, but in fact currently image
datablock name is used for reference. This makes it
easy to find an image in BlendData database.
- Added some extra properties to Image RNA:
* channels, which denotes actual number of channels
in ImBuf. This is needed to treat image's pixels
correct (before it wasn't possible because API
used internal number of channels for pixels which
is in fact doesn't correlate with image depth)
* is_float, which is truth if image is stored in
float buffer of ImBuf.
- Implemented string lookup for C++ RNA collections
for cases there's no manual lookup function.
OSL is not supported because it used own image loading
and filtering routines and there's seems to be no API
to feed pre-loaded pixels directly to the library.
Think we'll either need to add some API to support
such kind of feeding or consider OSL does not have
support of packed images at all.
Movies are not supported at this moment because of lack
of RNA API to load specified frame. It's not difficult
to solve, just need to consider what to best here:
* Either write some general python interface for ImBuf
and use it via C++ API, or
* Write a PY API function which will return pixels for
given frame, or
* Use bad-level BKE_* call
Anyway, small steps, further improvements later.
Reviewed by Brecht, thanks!
2013-01-12 10:59:13 +00:00
|
|
|
channels = ibuf->channels;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
Packed and generated images support for Cycles
This commit adds support of packed and generated images
for Cycles when using SVM backend. Movies are still not
supported. This changes also doesn't touch OSL which is
much less trivial to adopt for any images which are not
saved to disk.
Implementation details:
- When adding images to Image Manager is now possible
to mark image as builtin. Builtin images will bypass
OIIO loader and will use special loading callbacks.
- Callbacks are set by Blender Session and they're
using C++ RNA interface to obtain needed data (pixels,
dimensions, is_float flag).
- Image Manager assumes file path is used as reference
to a builtin images, but in fact currently image
datablock name is used for reference. This makes it
easy to find an image in BlendData database.
- Added some extra properties to Image RNA:
* channels, which denotes actual number of channels
in ImBuf. This is needed to treat image's pixels
correct (before it wasn't possible because API
used internal number of channels for pixels which
is in fact doesn't correlate with image depth)
* is_float, which is truth if image is stored in
float buffer of ImBuf.
- Implemented string lookup for C++ RNA collections
for cases there's no manual lookup function.
OSL is not supported because it used own image loading
and filtering routines and there's seems to be no API
to feed pre-loaded pixels directly to the library.
Think we'll either need to add some API to support
such kind of feeding or consider OSL does not have
support of packed images at all.
Movies are not supported at this moment because of lack
of RNA API to load specified frame. It's not difficult
to solve, just need to consider what to best here:
* Either write some general python interface for ImBuf
and use it via C++ API, or
* Write a PY API function which will return pixels for
given frame, or
* Use bad-level BKE_* call
Anyway, small steps, further improvements later.
Reviewed by Brecht, thanks!
2013-01-12 10:59:13 +00:00
|
|
|
|
|
|
|
|
BKE_image_release_ibuf(im, ibuf, lock);
|
|
|
|
|
|
|
|
|
|
return channels;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_Image_is_float_get(PointerRNA *ptr)
|
Packed and generated images support for Cycles
This commit adds support of packed and generated images
for Cycles when using SVM backend. Movies are still not
supported. This changes also doesn't touch OSL which is
much less trivial to adopt for any images which are not
saved to disk.
Implementation details:
- When adding images to Image Manager is now possible
to mark image as builtin. Builtin images will bypass
OIIO loader and will use special loading callbacks.
- Callbacks are set by Blender Session and they're
using C++ RNA interface to obtain needed data (pixels,
dimensions, is_float flag).
- Image Manager assumes file path is used as reference
to a builtin images, but in fact currently image
datablock name is used for reference. This makes it
easy to find an image in BlendData database.
- Added some extra properties to Image RNA:
* channels, which denotes actual number of channels
in ImBuf. This is needed to treat image's pixels
correct (before it wasn't possible because API
used internal number of channels for pixels which
is in fact doesn't correlate with image depth)
* is_float, which is truth if image is stored in
float buffer of ImBuf.
- Implemented string lookup for C++ RNA collections
for cases there's no manual lookup function.
OSL is not supported because it used own image loading
and filtering routines and there's seems to be no API
to feed pre-loaded pixels directly to the library.
Think we'll either need to add some API to support
such kind of feeding or consider OSL does not have
support of packed images at all.
Movies are not supported at this moment because of lack
of RNA API to load specified frame. It's not difficult
to solve, just need to consider what to best here:
* Either write some general python interface for ImBuf
and use it via C++ API, or
* Write a PY API function which will return pixels for
given frame, or
* Use bad-level BKE_* call
Anyway, small steps, further improvements later.
Reviewed by Brecht, thanks!
2013-01-12 10:59:13 +00:00
|
|
|
{
|
|
|
|
|
Image *im = (Image *)ptr->data;
|
|
|
|
|
ImBuf *ibuf;
|
|
|
|
|
void *lock;
|
2014-04-01 11:34:00 +11:00
|
|
|
bool is_float = false;
|
Packed and generated images support for Cycles
This commit adds support of packed and generated images
for Cycles when using SVM backend. Movies are still not
supported. This changes also doesn't touch OSL which is
much less trivial to adopt for any images which are not
saved to disk.
Implementation details:
- When adding images to Image Manager is now possible
to mark image as builtin. Builtin images will bypass
OIIO loader and will use special loading callbacks.
- Callbacks are set by Blender Session and they're
using C++ RNA interface to obtain needed data (pixels,
dimensions, is_float flag).
- Image Manager assumes file path is used as reference
to a builtin images, but in fact currently image
datablock name is used for reference. This makes it
easy to find an image in BlendData database.
- Added some extra properties to Image RNA:
* channels, which denotes actual number of channels
in ImBuf. This is needed to treat image's pixels
correct (before it wasn't possible because API
used internal number of channels for pixels which
is in fact doesn't correlate with image depth)
* is_float, which is truth if image is stored in
float buffer of ImBuf.
- Implemented string lookup for C++ RNA collections
for cases there's no manual lookup function.
OSL is not supported because it used own image loading
and filtering routines and there's seems to be no API
to feed pre-loaded pixels directly to the library.
Think we'll either need to add some API to support
such kind of feeding or consider OSL does not have
support of packed images at all.
Movies are not supported at this moment because of lack
of RNA API to load specified frame. It's not difficult
to solve, just need to consider what to best here:
* Either write some general python interface for ImBuf
and use it via C++ API, or
* Write a PY API function which will return pixels for
given frame, or
* Use bad-level BKE_* call
Anyway, small steps, further improvements later.
Reviewed by Brecht, thanks!
2013-01-12 10:59:13 +00:00
|
|
|
|
|
|
|
|
ibuf = BKE_image_acquire_ibuf(im, NULL, &lock);
|
2019-06-04 00:21:57 +10:00
|
|
|
if (ibuf) {
|
Packed and generated images support for Cycles
This commit adds support of packed and generated images
for Cycles when using SVM backend. Movies are still not
supported. This changes also doesn't touch OSL which is
much less trivial to adopt for any images which are not
saved to disk.
Implementation details:
- When adding images to Image Manager is now possible
to mark image as builtin. Builtin images will bypass
OIIO loader and will use special loading callbacks.
- Callbacks are set by Blender Session and they're
using C++ RNA interface to obtain needed data (pixels,
dimensions, is_float flag).
- Image Manager assumes file path is used as reference
to a builtin images, but in fact currently image
datablock name is used for reference. This makes it
easy to find an image in BlendData database.
- Added some extra properties to Image RNA:
* channels, which denotes actual number of channels
in ImBuf. This is needed to treat image's pixels
correct (before it wasn't possible because API
used internal number of channels for pixels which
is in fact doesn't correlate with image depth)
* is_float, which is truth if image is stored in
float buffer of ImBuf.
- Implemented string lookup for C++ RNA collections
for cases there's no manual lookup function.
OSL is not supported because it used own image loading
and filtering routines and there's seems to be no API
to feed pre-loaded pixels directly to the library.
Think we'll either need to add some API to support
such kind of feeding or consider OSL does not have
support of packed images at all.
Movies are not supported at this moment because of lack
of RNA API to load specified frame. It's not difficult
to solve, just need to consider what to best here:
* Either write some general python interface for ImBuf
and use it via C++ API, or
* Write a PY API function which will return pixels for
given frame, or
* Use bad-level BKE_* call
Anyway, small steps, further improvements later.
Reviewed by Brecht, thanks!
2013-01-12 10:59:13 +00:00
|
|
|
is_float = ibuf->rect_float != NULL;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
Packed and generated images support for Cycles
This commit adds support of packed and generated images
for Cycles when using SVM backend. Movies are still not
supported. This changes also doesn't touch OSL which is
much less trivial to adopt for any images which are not
saved to disk.
Implementation details:
- When adding images to Image Manager is now possible
to mark image as builtin. Builtin images will bypass
OIIO loader and will use special loading callbacks.
- Callbacks are set by Blender Session and they're
using C++ RNA interface to obtain needed data (pixels,
dimensions, is_float flag).
- Image Manager assumes file path is used as reference
to a builtin images, but in fact currently image
datablock name is used for reference. This makes it
easy to find an image in BlendData database.
- Added some extra properties to Image RNA:
* channels, which denotes actual number of channels
in ImBuf. This is needed to treat image's pixels
correct (before it wasn't possible because API
used internal number of channels for pixels which
is in fact doesn't correlate with image depth)
* is_float, which is truth if image is stored in
float buffer of ImBuf.
- Implemented string lookup for C++ RNA collections
for cases there's no manual lookup function.
OSL is not supported because it used own image loading
and filtering routines and there's seems to be no API
to feed pre-loaded pixels directly to the library.
Think we'll either need to add some API to support
such kind of feeding or consider OSL does not have
support of packed images at all.
Movies are not supported at this moment because of lack
of RNA API to load specified frame. It's not difficult
to solve, just need to consider what to best here:
* Either write some general python interface for ImBuf
and use it via C++ API, or
* Write a PY API function which will return pixels for
given frame, or
* Use bad-level BKE_* call
Anyway, small steps, further improvements later.
Reviewed by Brecht, thanks!
2013-01-12 10:59:13 +00:00
|
|
|
|
|
|
|
|
BKE_image_release_ibuf(im, ibuf, lock);
|
|
|
|
|
|
|
|
|
|
return is_float;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static PointerRNA rna_Image_packed_file_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
Image *ima = (Image *)ptr->owner_id;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
if (BKE_image_has_packedfile(ima)) {
|
|
|
|
|
ImagePackedFile *imapf = ima->packedfiles.first;
|
|
|
|
|
return rna_pointer_inherit_refine(ptr, &RNA_PackedFile, imapf->packedfile);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return PointerRNA_NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-14 22:46:30 +02:00
|
|
|
static void rna_RenderSlot_clear(ID *id, RenderSlot *slot, ImageUser *iuser)
|
2014-10-09 11:15:47 +02:00
|
|
|
{
|
2018-06-14 22:46:30 +02:00
|
|
|
Image *image = (Image *)id;
|
|
|
|
|
int index = BLI_findindex(&image->renderslots, slot);
|
|
|
|
|
BKE_image_clear_renderslot(image, iuser, index);
|
|
|
|
|
|
|
|
|
|
WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, image);
|
2014-10-09 11:15:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PointerRNA rna_render_slots_active_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
Image *image = (Image *)ptr->owner_id;
|
2018-06-14 22:46:30 +02:00
|
|
|
RenderSlot *render_slot = BKE_image_get_renderslot(image, image->render_slot);
|
2014-10-09 11:15:47 +02:00
|
|
|
|
|
|
|
|
return rna_pointer_inherit_refine(ptr, &RNA_RenderSlot, render_slot);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-20 18:06:09 +10:00
|
|
|
static void rna_render_slots_active_set(PointerRNA *ptr,
|
|
|
|
|
PointerRNA value,
|
|
|
|
|
struct ReportList *UNUSED(reports))
|
2014-10-09 11:15:47 +02:00
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
Image *image = (Image *)ptr->owner_id;
|
|
|
|
|
if (value.owner_id == &image->id) {
|
2018-06-14 22:46:30 +02:00
|
|
|
RenderSlot *slot = (RenderSlot *)value.data;
|
|
|
|
|
int index = BLI_findindex(&image->renderslots, slot);
|
2019-06-04 00:21:57 +10:00
|
|
|
if (index != -1) {
|
2018-06-14 22:46:30 +02:00
|
|
|
image->render_slot = index;
|
2020-12-18 09:15:55 +01:00
|
|
|
image->gpuflag |= IMA_GPU_REFRESH;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
2014-10-09 11:15:47 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int rna_render_slots_active_index_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
Image *image = (Image *)ptr->owner_id;
|
2014-10-09 11:15:47 +02:00
|
|
|
return image->render_slot;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_render_slots_active_index_set(PointerRNA *ptr, int value)
|
|
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
Image *image = (Image *)ptr->owner_id;
|
2018-06-14 22:46:30 +02:00
|
|
|
int num_slots = BLI_listbase_count(&image->renderslots);
|
2014-10-09 11:15:47 +02:00
|
|
|
image->render_slot = value;
|
2020-12-18 09:15:55 +01:00
|
|
|
image->gpuflag |= IMA_GPU_REFRESH;
|
2018-06-14 22:46:30 +02:00
|
|
|
CLAMP(image->render_slot, 0, num_slots - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_render_slots_active_index_range(
|
|
|
|
|
PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
|
|
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
Image *image = (Image *)ptr->owner_id;
|
2018-06-14 22:46:30 +02:00
|
|
|
*min = 0;
|
|
|
|
|
*max = max_ii(0, BLI_listbase_count(&image->renderslots) - 1);
|
2014-10-09 11:15:47 +02:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
static ImageTile *rna_UDIMTile_new(Image *image, int tile_number, const char *label)
|
|
|
|
|
{
|
|
|
|
|
ImageTile *tile = BKE_image_add_tile(image, tile_number, label);
|
|
|
|
|
|
|
|
|
|
WM_main_add_notifier(NC_IMAGE | ND_DRAW, NULL);
|
|
|
|
|
|
|
|
|
|
return tile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_UDIMTile_remove(Image *image, PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
ImageTile *tile = (ImageTile *)ptr->data;
|
|
|
|
|
BKE_image_remove_tile(image, tile);
|
|
|
|
|
|
|
|
|
|
WM_main_add_notifier(NC_IMAGE | ND_DRAW, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-30 18:39:49 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
static void rna_def_imageuser(BlenderRNA *brna)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "ImageUser", NULL);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_struct_ui_text(
|
|
|
|
|
srna,
|
|
|
|
|
"Image User",
|
2015-10-24 02:44:43 +11:00
|
|
|
"Parameters defining how an Image data-block is used by another data-block");
|
2010-09-20 09:52:29 +00:00
|
|
|
RNA_def_struct_path_func(srna, "rna_ImageUser_path");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "use_auto_refresh", PROP_BOOLEAN, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_ANIM_ALWAYS);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Auto Refresh", "Always refresh image on frame changes");
|
2019-03-01 02:12:40 +01:00
|
|
|
RNA_def_property_update(prop, 0, "rna_ImageUser_relations_update");
|
2012-10-26 09:13:26 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Movies support for Cycles
This adds support of movie textures for Cycles rendering.
Uses the same builtin images routines as packed/generated images,
but with some extra non-rna hookups from blender_session side.
Basically, it's not so clear how to give access to video frames
via C++ RNA -- it'll require exposing ImBuf to API, doing some
threading locks and so. Ended up adding two more functions which
are actually bad level call, but don't consider it's so much bad
-- we have few bad calls already, which are actually related.
Changed a bit how builtin images names are passing to image
manager. Now it's not just an ID datablock name, but also a frame
number concatenated via '@' character, which makes itpossible to
easily know frame number to be used for movie images, without
adding extra descriptors to image manager.
Decoding of builtin name is a bit slower now, but it should be
still nothing in comparison with rendering complexity.
Also exposed image user's frame_current to python API, which
is needed to get absolute frame number of movie from node's
image user.
P.S. Generated/packed images are also using bad level call but
only does it to make things more clear here. Either all images
are using C++ RNA here or no images does. That's the most clear
for now.
2013-01-16 17:07:25 +00:00
|
|
|
prop = RNA_def_property(srna, "frame_current", PROP_INT, PROP_TIME);
|
|
|
|
|
RNA_def_property_int_sdna(prop, NULL, "framenr");
|
|
|
|
|
RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
|
|
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Current Frame", "Current frame number in image sequence or movie");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-11-30 18:39:49 +00:00
|
|
|
/* animation */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "use_cyclic", PROP_BOOLEAN, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "cycl", 0);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Cyclic", "Cycle the images in the movie");
|
2009-09-16 19:27:08 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
|
2012-10-26 09:13:26 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE);
|
2010-08-21 04:51:00 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "frames");
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_range(prop, 0, MAXFRAMEF);
|
2011-10-20 07:56:04 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Frames", "Number of images of a movie to use");
|
2009-09-16 19:27:08 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
|
2012-10-26 09:13:26 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
|
2010-08-21 04:51:00 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "offset");
|
2011-10-20 07:56:04 +00:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Offset", "Offset the number of the frame to use in the animation");
|
2009-09-16 19:27:08 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "sfra");
|
2010-09-15 03:45:33 +00:00
|
|
|
RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Start Frame",
|
|
|
|
|
"Global starting frame of the movie/sequence, assuming first picture has a #1");
|
2009-09-16 19:27:08 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
|
2012-10-26 09:13:26 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "multilayer_layer", PROP_INT, PROP_UNSIGNED);
|
2008-12-18 23:34:19 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "layer");
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Layer", "Layer in multilayer image");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-09-09 19:41:46 +05:00
|
|
|
prop = RNA_def_property(srna, "multilayer_pass", PROP_INT, PROP_UNSIGNED);
|
|
|
|
|
RNA_def_property_int_sdna(prop, NULL, "pass");
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */
|
|
|
|
|
RNA_def_property_ui_text(prop, "Pass", "Pass in multilayer image");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
prop = RNA_def_property(srna, "multilayer_view", PROP_INT, PROP_UNSIGNED);
|
|
|
|
|
RNA_def_property_int_sdna(prop, NULL, "view");
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */
|
|
|
|
|
RNA_def_property_ui_text(prop, "View", "View in multilayer image");
|
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
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "tile", PROP_INT, PROP_UNSIGNED);
|
|
|
|
|
RNA_def_property_int_sdna(prop, NULL, "tile");
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Tile", "Tile in tiled image");
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* image.packed_files */
|
|
|
|
|
static void rna_def_image_packed_files(BlenderRNA *brna)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
srna = RNA_def_struct(brna, "ImagePackedFile", NULL);
|
|
|
|
|
RNA_def_struct_sdna(srna, "ImagePackedFile");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
|
|
|
|
|
RNA_def_property_pointer_sdna(prop, NULL, "packedfile");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Packed File", "");
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
|
|
|
|
|
RNA_def_property_string_sdna(prop, NULL, "filepath");
|
|
|
|
|
RNA_def_struct_name_property(srna, prop);
|
2015-10-21 02:26:23 +11:00
|
|
|
|
|
|
|
|
RNA_api_image_packed_file(srna);
|
2008-11-30 18:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
2014-10-09 11:15:47 +02:00
|
|
|
static void rna_def_render_slot(BlenderRNA *brna)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
2018-06-14 22:46:30 +02:00
|
|
|
PropertyRNA *prop, *parm;
|
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
|
2014-10-09 11:15:47 +02:00
|
|
|
srna = RNA_def_struct(brna, "RenderSlot", NULL);
|
|
|
|
|
RNA_def_struct_ui_text(srna, "Render Slot", "Parameters defining the render slot");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
|
|
|
|
|
RNA_def_property_string_sdna(prop, NULL, "name");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Name", "Render slot name");
|
|
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2018-06-14 22:46:30 +02:00
|
|
|
|
|
|
|
|
func = RNA_def_function(srna, "clear", "rna_RenderSlot_clear");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_SELF_ID);
|
|
|
|
|
RNA_def_function_ui_description(func, "Clear the render slot");
|
|
|
|
|
parm = RNA_def_pointer(func, "iuser", "ImageUser", "ImageUser", "");
|
|
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2014-10-09 11:15:47 +02:00
|
|
|
}
|
|
|
|
|
|
2018-06-14 22:46:30 +02:00
|
|
|
static void rna_def_render_slots(BlenderRNA *brna, PropertyRNA *cprop)
|
2014-10-09 11:15:47 +02:00
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
2018-06-14 22:46:30 +02:00
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *prop, *parm;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-14 22:46:30 +02:00
|
|
|
RNA_def_property_srna(cprop, "RenderSlots");
|
2014-10-09 11:15:47 +02:00
|
|
|
srna = RNA_def_struct(brna, "RenderSlots", NULL);
|
2018-06-14 22:46:30 +02:00
|
|
|
RNA_def_struct_sdna(srna, "Image");
|
|
|
|
|
RNA_def_struct_ui_text(srna, "Render Layers", "Collection of render layers");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-14 22:46:30 +02:00
|
|
|
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
|
|
|
|
|
RNA_def_property_int_sdna(prop, NULL, "render_slot");
|
|
|
|
|
RNA_def_property_int_funcs(prop,
|
|
|
|
|
"rna_render_slots_active_index_get",
|
|
|
|
|
"rna_render_slots_active_index_set",
|
|
|
|
|
"rna_render_slots_active_index_range");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Active", "Active render slot of the image");
|
|
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-09 11:15:47 +02:00
|
|
|
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
|
|
|
|
|
RNA_def_property_struct_type(prop, "RenderSlot");
|
|
|
|
|
RNA_def_property_pointer_funcs(
|
|
|
|
|
prop, "rna_render_slots_active_get", "rna_render_slots_active_set", NULL, NULL);
|
2018-06-19 16:07:10 +02:00
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE);
|
2014-10-09 11:15:47 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Active", "Active render slot of the image");
|
|
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-14 22:46:30 +02:00
|
|
|
func = RNA_def_function(srna, "new", "BKE_image_add_renderslot");
|
|
|
|
|
RNA_def_function_ui_description(func, "Add a render slot to the image");
|
|
|
|
|
parm = RNA_def_string(func, "name", NULL, 0, "Name", "New name for the render slot");
|
|
|
|
|
parm = RNA_def_pointer(func, "result", "RenderSlot", "", "Newly created render layer");
|
|
|
|
|
RNA_def_function_return(func, parm);
|
2014-10-09 11:15:47 +02:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
static void rna_def_udim_tile(BlenderRNA *brna)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
srna = RNA_def_struct(brna, "UDIMTile", NULL);
|
|
|
|
|
RNA_def_struct_sdna(srna, "ImageTile");
|
|
|
|
|
RNA_def_struct_ui_text(srna, "UDIM Tile", "Properties of the UDIM tile");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "label", PROP_STRING, PROP_NONE);
|
|
|
|
|
RNA_def_property_string_sdna(prop, NULL, "label");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Label", "Tile label");
|
|
|
|
|
RNA_def_property_string_funcs(prop, "rna_UDIMTile_label_get", "rna_UDIMTile_label_length", NULL);
|
|
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "number", PROP_INT, PROP_NONE);
|
|
|
|
|
RNA_def_property_int_sdna(prop, NULL, "tile_number");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Number", "Number of the position that this tile covers");
|
|
|
|
|
RNA_def_property_int_funcs(prop, NULL, "rna_UDIMTile_tile_number_set", NULL);
|
|
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_def_udim_tiles(BlenderRNA *brna, PropertyRNA *cprop)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *parm;
|
|
|
|
|
|
|
|
|
|
RNA_def_property_srna(cprop, "UDIMTiles");
|
|
|
|
|
srna = RNA_def_struct(brna, "UDIMTiles", NULL);
|
|
|
|
|
RNA_def_struct_sdna(srna, "Image");
|
|
|
|
|
RNA_def_struct_ui_text(srna, "UDIM Tiles", "Collection of UDIM tiles");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
|
|
|
|
|
RNA_def_property_int_sdna(prop, NULL, "active_tile_index");
|
|
|
|
|
RNA_def_property_int_funcs(prop,
|
|
|
|
|
"rna_Image_active_tile_index_get",
|
|
|
|
|
"rna_Image_active_tile_index_set",
|
|
|
|
|
"rna_Image_active_tile_index_range");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Active Tile Index", "Active index in tiles array");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
|
|
|
|
|
RNA_def_property_struct_type(prop, "UDIMTile");
|
|
|
|
|
RNA_def_property_pointer_funcs(
|
|
|
|
|
prop, "rna_Image_active_tile_get", "rna_Image_active_tile_set", NULL, NULL);
|
|
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Active Image Tile", "Active Image Tile");
|
|
|
|
|
|
|
|
|
|
func = RNA_def_function(srna, "new", "rna_UDIMTile_new");
|
|
|
|
|
RNA_def_function_ui_description(func, "Add a tile to the image");
|
|
|
|
|
parm = RNA_def_int(
|
|
|
|
|
func, "tile_number", 1, 1, INT_MAX, "", "Number of the newly created tile", 1, 100);
|
|
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
|
|
|
|
parm = RNA_def_string(func, "label", NULL, 0, "", "Optional label for the tile");
|
|
|
|
|
parm = RNA_def_pointer(func, "result", "UDIMTile", "", "Newly created image tile");
|
|
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
|
|
|
|
|
func = RNA_def_function(srna, "get", "BKE_image_get_tile");
|
|
|
|
|
RNA_def_function_ui_description(func, "Get a tile based on its tile number");
|
|
|
|
|
parm = RNA_def_int(func, "tile_number", 0, 0, INT_MAX, "", "Number of the tile", 0, 100);
|
|
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
|
|
|
|
parm = RNA_def_pointer(func, "result", "UDIMTile", "", "The tile");
|
|
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
|
|
|
|
|
func = RNA_def_function(srna, "remove", "rna_UDIMTile_remove");
|
|
|
|
|
RNA_def_function_ui_description(func, "Remove an image tile");
|
|
|
|
|
parm = RNA_def_pointer(func, "tile", "UDIMTile", "", "Image tile to remove");
|
|
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
|
|
|
|
|
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-30 18:39:49 +00:00
|
|
|
static void rna_def_image(BlenderRNA *brna)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
2012-03-05 23:30:41 +00:00
|
|
|
static const EnumPropertyItem prop_type_items[] = {
|
2009-06-16 00:52:21 +00:00
|
|
|
{IMA_TYPE_IMAGE, "IMAGE", 0, "Image", ""},
|
|
|
|
|
{IMA_TYPE_MULTILAYER, "MULTILAYER", 0, "Multilayer", ""},
|
2009-09-16 19:27:08 +00:00
|
|
|
{IMA_TYPE_UV_TEST, "UV_TEST", 0, "UV Test", ""},
|
|
|
|
|
{IMA_TYPE_R_RESULT, "RENDER_RESULT", 0, "Render Result", ""},
|
2009-06-16 00:52:21 +00:00
|
|
|
{IMA_TYPE_COMPOSITE, "COMPOSITING", 0, "Compositing", ""},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2012-12-31 13:52:13 +00:00
|
|
|
static const EnumPropertyItem alpha_mode_items[] = {
|
|
|
|
|
{IMA_ALPHA_STRAIGHT,
|
|
|
|
|
"STRAIGHT",
|
|
|
|
|
0,
|
|
|
|
|
"Straight",
|
2019-05-18 20:52:20 +02:00
|
|
|
"Store RGB and alpha channels separately with alpha acting as a mask, also known as "
|
|
|
|
|
"unassociated alpha. Commonly used by image editing applications and file formats like "
|
|
|
|
|
"PNG"},
|
2012-12-31 13:52:13 +00:00
|
|
|
{IMA_ALPHA_PREMUL,
|
|
|
|
|
"PREMUL",
|
|
|
|
|
0,
|
|
|
|
|
"Premultiplied",
|
2019-08-01 13:53:25 +10:00
|
|
|
"Store RGB channels with alpha multiplied in, also known as associated alpha. The natural "
|
2019-05-18 20:52:20 +02:00
|
|
|
"format for renders and used by file formats like OpenEXR"},
|
|
|
|
|
{IMA_ALPHA_CHANNEL_PACKED,
|
|
|
|
|
"CHANNEL_PACKED",
|
|
|
|
|
0,
|
|
|
|
|
"Channel Packed",
|
|
|
|
|
"Different images are packed in the RGB and alpha channels, and they should not "
|
|
|
|
|
"affect each other. Channel packing is commonly used by game engines to save memory"},
|
|
|
|
|
{IMA_ALPHA_IGNORE,
|
|
|
|
|
"NONE",
|
|
|
|
|
0,
|
|
|
|
|
"None",
|
|
|
|
|
"Ignore alpha channel from the file and make image fully opaque"},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2012-12-31 13:52:13 +00:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "Image", "ID");
|
2015-10-24 02:44:43 +11:00
|
|
|
RNA_def_struct_ui_text(
|
|
|
|
|
srna, "Image", "Image data-block referencing an external or packed image");
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_IMAGE_DATA);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
|
2019-06-14 23:16:04 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2020-06-23 09:54:14 +10:00
|
|
|
RNA_def_property_string_sdna(prop, NULL, "filepath");
|
2010-06-02 17:58:28 +00:00
|
|
|
RNA_def_property_ui_text(prop, "File Name", "Image/Movie file name");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_reload_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-03-06 21:47:16 +00:00
|
|
|
/* eek. this is horrible but needed so we can save to a new name without blanking the data :( */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "filepath_raw", PROP_STRING, PROP_FILEPATH);
|
2020-06-23 09:54:14 +10:00
|
|
|
RNA_def_property_string_sdna(prop, NULL, "filepath");
|
2010-06-02 17:58:28 +00:00
|
|
|
RNA_def_property_ui_text(prop, "File Name", "Image/Movie file name (without data refreshing)");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "file_format", PROP_ENUM, PROP_NONE);
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(prop, rna_enum_image_type_items);
|
2010-03-07 20:27:40 +00:00
|
|
|
RNA_def_property_enum_funcs(
|
|
|
|
|
prop, "rna_Image_file_format_get", "rna_Image_file_format_set", NULL);
|
|
|
|
|
RNA_def_property_ui_text(prop, "File Format", "Format used for re-saving this file");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE);
|
2009-09-16 19:27:08 +00:00
|
|
|
RNA_def_property_enum_items(prop, image_source_items);
|
2013-01-24 17:21:22 +00:00
|
|
|
RNA_def_property_enum_funcs(prop, NULL, "rna_Image_source_set", "rna_Image_source_itemf");
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Source", "Where the image comes from");
|
2013-01-24 17:21:22 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_enum_items(prop, prop_type_items);
|
2009-09-16 19:27:08 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Type", "How to generate the image");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
|
2015-04-06 10:40:12 -03:00
|
|
|
RNA_def_property_struct_type(prop, "PackedFile");
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_pointer_sdna(prop, NULL, "packedfile");
|
2015-04-06 10:40:12 -03:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_Image_packed_file_get", NULL, NULL, NULL);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Packed File", "First packed file of the image");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
prop = RNA_def_property(srna, "packed_files", PROP_COLLECTION, PROP_NONE);
|
|
|
|
|
RNA_def_property_collection_sdna(prop, NULL, "packedfiles", NULL);
|
|
|
|
|
RNA_def_property_struct_type(prop, "ImagePackedFile");
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Packed Files", "Collection of packed images");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-23 07:06:29 +00:00
|
|
|
prop = RNA_def_property(srna, "use_view_as_render", PROP_BOOLEAN, PROP_NONE);
|
2019-06-14 23:16:04 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
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
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_VIEW_AS_RENDER);
|
|
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"View as Render",
|
|
|
|
|
"Apply render part of display transformation when displaying this image on the screen");
|
|
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-02-03 18:17:12 +05:00
|
|
|
prop = RNA_def_property(srna, "use_deinterlace", PROP_BOOLEAN, PROP_NONE);
|
2019-06-14 23:16:04 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2015-02-03 18:17:12 +05:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_DEINTERLACE);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Deinterlace", "Deinterlace movie file on load");
|
|
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_reload_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
prop = RNA_def_property(srna, "use_multiview", PROP_BOOLEAN, PROP_NONE);
|
2019-06-14 23:16:04 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2015-04-06 10:40:12 -03:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_USE_VIEWS);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Use Multi-View", "Use Multiple Views (when available)");
|
|
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_views_format_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
prop = RNA_def_property(srna, "is_stereo_3d", PROP_BOOLEAN, PROP_NONE);
|
2019-06-14 23:16:04 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2015-10-11 01:14:02 +02:00
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Image_is_stereo_3d_get", NULL);
|
2015-04-06 10:40:12 -03:00
|
|
|
RNA_def_property_ui_text(prop, "Stereo 3D", "Image has left and right views");
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
prop = RNA_def_property(srna, "is_multiview", PROP_BOOLEAN, PROP_NONE);
|
2019-06-14 23:16:04 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2015-10-11 01:14:02 +02:00
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Image_is_multiview_get", NULL);
|
2015-04-06 10:40:12 -03:00
|
|
|
RNA_def_property_ui_text(prop, "Multiple Views", "Image has more than one view");
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE);
|
2019-06-14 23:16:04 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2009-06-30 19:10:14 +00:00
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Image_dirty_get", NULL);
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Dirty", "Image has changed and is not saved");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-11-30 18:39:49 +00:00
|
|
|
/* generated image (image_generated_change_cb) */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "generated_type", PROP_ENUM, PROP_NONE);
|
2008-12-03 20:17:12 +00:00
|
|
|
RNA_def_property_enum_sdna(prop, NULL, "gen_type");
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(prop, rna_enum_image_generated_type_items);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Generated Type", "Generated image type");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
|
2012-10-26 09:13:26 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-27 00:47:45 +01:00
|
|
|
prop = RNA_def_property(srna, "generated_width", PROP_INT, PROP_PIXEL);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "gen_x");
|
2014-02-09 08:42:45 +11:00
|
|
|
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
|
2013-02-21 18:07:56 +00:00
|
|
|
RNA_def_property_range(prop, 1, 65536);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Generated Width", "Generated image width");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
|
2012-10-26 09:13:26 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-27 00:47:45 +01:00
|
|
|
prop = RNA_def_property(srna, "generated_height", PROP_INT, PROP_PIXEL);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "gen_y");
|
2014-02-09 08:42:45 +11:00
|
|
|
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
|
2013-02-21 18:07:56 +00:00
|
|
|
RNA_def_property_range(prop, 1, 65536);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Generated Height", "Generated image height");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
|
2012-10-26 09:13:26 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "use_generated_float", PROP_BOOLEAN, PROP_NONE);
|
2011-07-21 00:41:00 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "gen_flag", IMA_GEN_FLOAT);
|
2020-12-24 13:11:22 -06:00
|
|
|
RNA_def_property_ui_text(prop, "Float Buffer", "Generate floating-point buffer");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
|
2012-10-26 09:13:26 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-06 15:48:02 +01:00
|
|
|
prop = RNA_def_property(srna, "generated_color", PROP_FLOAT, PROP_COLOR_GAMMA);
|
2014-10-02 19:04:38 +06:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "gen_color");
|
|
|
|
|
RNA_def_property_array(prop, 4);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Color", "Fill color for the generated image");
|
|
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_XYZ);
|
2019-06-14 23:16:04 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "aspx");
|
|
|
|
|
RNA_def_property_array(prop, 2);
|
2013-11-25 05:26:25 +01:00
|
|
|
RNA_def_property_range(prop, 0.1f, FLT_MAX);
|
2020-11-06 11:25:27 +11:00
|
|
|
RNA_def_property_ui_range(prop, 0.1f, 5000.0f, 1, 2);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Display Aspect", "Display Aspect for this image, does not affect rendering");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "bindcode", PROP_INT, PROP_UNSIGNED);
|
2018-06-11 22:30:59 +02:00
|
|
|
RNA_def_property_int_funcs(prop, "rna_Image_bindcode_get", NULL, NULL);
|
2010-06-03 16:26:04 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Bindcode", "OpenGL bindcode");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-09 11:15:47 +02:00
|
|
|
prop = RNA_def_property(srna, "render_slots", PROP_COLLECTION, PROP_NONE);
|
|
|
|
|
RNA_def_property_struct_type(prop, "RenderSlot");
|
2018-06-14 22:46:30 +02:00
|
|
|
RNA_def_property_collection_sdna(prop, NULL, "renderslots", NULL);
|
2014-10-09 11:15:47 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Render Slots", "Render slots of the image");
|
2018-06-14 22:46:30 +02:00
|
|
|
rna_def_render_slots(brna, prop);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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
|
|
|
prop = RNA_def_property(srna, "tiles", PROP_COLLECTION, PROP_NONE);
|
|
|
|
|
RNA_def_property_struct_type(prop, "UDIMTile");
|
|
|
|
|
RNA_def_property_collection_sdna(prop, NULL, "tiles", NULL);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Image Tiles", "Tiles of the image");
|
|
|
|
|
rna_def_udim_tiles(brna, prop);
|
|
|
|
|
|
2009-07-03 17:44:20 +00:00
|
|
|
/*
|
2012-04-22 11:54:53 +00:00
|
|
|
* Image.has_data and Image.depth are temporary,
|
|
|
|
|
* Update import_obj.py when they are replaced (Arystan)
|
|
|
|
|
*/
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "has_data", PROP_BOOLEAN, PROP_NONE);
|
2009-07-03 17:44:20 +00:00
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Image_has_data_get", NULL);
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2017-05-25 19:54:54 +10:00
|
|
|
RNA_def_property_ui_text(prop, "Has Data", "True if the image data is loaded into memory");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
|
2009-07-03 17:44:20 +00:00
|
|
|
RNA_def_property_int_funcs(prop, "rna_Image_depth_get", NULL, NULL);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Depth", "Image bit depth");
|
2009-07-03 17:44:20 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
prop = RNA_def_int_vector(srna,
|
|
|
|
|
"size",
|
|
|
|
|
2,
|
|
|
|
|
NULL,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
"Size",
|
|
|
|
|
"Width and height in pixels, zero when image data cant be loaded",
|
|
|
|
|
0,
|
|
|
|
|
0);
|
2013-12-13 04:39:15 +11:00
|
|
|
RNA_def_property_subtype(prop, PROP_PIXEL);
|
2012-04-29 15:47:02 +00:00
|
|
|
RNA_def_property_int_funcs(prop, "rna_Image_size_get", NULL, NULL);
|
2010-01-06 10:46:49 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
prop = RNA_def_float_vector(
|
|
|
|
|
srna, "resolution", 2, NULL, 0, 0, "Resolution", "X/Y pixels per meter", 0, 0);
|
2019-06-14 23:16:04 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2012-04-29 15:47:02 +00:00
|
|
|
RNA_def_property_float_funcs(prop, "rna_Image_resolution_get", "rna_Image_resolution_set", NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-26 14:53:33 +00:00
|
|
|
prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_UNSIGNED);
|
|
|
|
|
RNA_def_property_int_funcs(prop, "rna_Image_frame_duration_get", NULL, NULL);
|
|
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Duration", "Duration (in frames) of the image (1 when not a video/sequence)");
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-06 15:51:01 +02:00
|
|
|
/* NOTE about pixels/channels/is_float:
|
|
|
|
|
* These properties describe how the image is stored internally (inside of ImBuf),
|
|
|
|
|
* not how it was saved to disk or how it'll be saved on disk.
|
Packed and generated images support for Cycles
This commit adds support of packed and generated images
for Cycles when using SVM backend. Movies are still not
supported. This changes also doesn't touch OSL which is
much less trivial to adopt for any images which are not
saved to disk.
Implementation details:
- When adding images to Image Manager is now possible
to mark image as builtin. Builtin images will bypass
OIIO loader and will use special loading callbacks.
- Callbacks are set by Blender Session and they're
using C++ RNA interface to obtain needed data (pixels,
dimensions, is_float flag).
- Image Manager assumes file path is used as reference
to a builtin images, but in fact currently image
datablock name is used for reference. This makes it
easy to find an image in BlendData database.
- Added some extra properties to Image RNA:
* channels, which denotes actual number of channels
in ImBuf. This is needed to treat image's pixels
correct (before it wasn't possible because API
used internal number of channels for pixels which
is in fact doesn't correlate with image depth)
* is_float, which is truth if image is stored in
float buffer of ImBuf.
- Implemented string lookup for C++ RNA collections
for cases there's no manual lookup function.
OSL is not supported because it used own image loading
and filtering routines and there's seems to be no API
to feed pre-loaded pixels directly to the library.
Think we'll either need to add some API to support
such kind of feeding or consider OSL does not have
support of packed images at all.
Movies are not supported at this moment because of lack
of RNA API to load specified frame. It's not difficult
to solve, just need to consider what to best here:
* Either write some general python interface for ImBuf
and use it via C++ API, or
* Write a PY API function which will return pixels for
given frame, or
* Use bad-level BKE_* call
Anyway, small steps, further improvements later.
Reviewed by Brecht, thanks!
2013-01-12 10:59:13 +00:00
|
|
|
*/
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "pixels", PROP_FLOAT, PROP_NONE);
|
2011-04-03 16:17:39 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_DYNAMIC);
|
2011-04-04 17:10:48 +00:00
|
|
|
RNA_def_property_multi_array(prop, 1, NULL);
|
2020-12-24 13:11:22 -06:00
|
|
|
RNA_def_property_ui_text(prop, "Pixels", "Image pixels in floating-point values");
|
2011-04-03 16:17:39 +00:00
|
|
|
RNA_def_property_dynamic_array_funcs(prop, "rna_Image_pixels_get_length");
|
|
|
|
|
RNA_def_property_float_funcs(prop, "rna_Image_pixels_get", "rna_Image_pixels_set", NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Packed and generated images support for Cycles
This commit adds support of packed and generated images
for Cycles when using SVM backend. Movies are still not
supported. This changes also doesn't touch OSL which is
much less trivial to adopt for any images which are not
saved to disk.
Implementation details:
- When adding images to Image Manager is now possible
to mark image as builtin. Builtin images will bypass
OIIO loader and will use special loading callbacks.
- Callbacks are set by Blender Session and they're
using C++ RNA interface to obtain needed data (pixels,
dimensions, is_float flag).
- Image Manager assumes file path is used as reference
to a builtin images, but in fact currently image
datablock name is used for reference. This makes it
easy to find an image in BlendData database.
- Added some extra properties to Image RNA:
* channels, which denotes actual number of channels
in ImBuf. This is needed to treat image's pixels
correct (before it wasn't possible because API
used internal number of channels for pixels which
is in fact doesn't correlate with image depth)
* is_float, which is truth if image is stored in
float buffer of ImBuf.
- Implemented string lookup for C++ RNA collections
for cases there's no manual lookup function.
OSL is not supported because it used own image loading
and filtering routines and there's seems to be no API
to feed pre-loaded pixels directly to the library.
Think we'll either need to add some API to support
such kind of feeding or consider OSL does not have
support of packed images at all.
Movies are not supported at this moment because of lack
of RNA API to load specified frame. It's not difficult
to solve, just need to consider what to best here:
* Either write some general python interface for ImBuf
and use it via C++ API, or
* Write a PY API function which will return pixels for
given frame, or
* Use bad-level BKE_* call
Anyway, small steps, further improvements later.
Reviewed by Brecht, thanks!
2013-01-12 10:59:13 +00:00
|
|
|
prop = RNA_def_property(srna, "channels", PROP_INT, PROP_UNSIGNED);
|
|
|
|
|
RNA_def_property_int_funcs(prop, "rna_Image_channels_get", NULL, NULL);
|
2013-01-13 14:52:31 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Channels", "Number of channels in pixels buffer");
|
Packed and generated images support for Cycles
This commit adds support of packed and generated images
for Cycles when using SVM backend. Movies are still not
supported. This changes also doesn't touch OSL which is
much less trivial to adopt for any images which are not
saved to disk.
Implementation details:
- When adding images to Image Manager is now possible
to mark image as builtin. Builtin images will bypass
OIIO loader and will use special loading callbacks.
- Callbacks are set by Blender Session and they're
using C++ RNA interface to obtain needed data (pixels,
dimensions, is_float flag).
- Image Manager assumes file path is used as reference
to a builtin images, but in fact currently image
datablock name is used for reference. This makes it
easy to find an image in BlendData database.
- Added some extra properties to Image RNA:
* channels, which denotes actual number of channels
in ImBuf. This is needed to treat image's pixels
correct (before it wasn't possible because API
used internal number of channels for pixels which
is in fact doesn't correlate with image depth)
* is_float, which is truth if image is stored in
float buffer of ImBuf.
- Implemented string lookup for C++ RNA collections
for cases there's no manual lookup function.
OSL is not supported because it used own image loading
and filtering routines and there's seems to be no API
to feed pre-loaded pixels directly to the library.
Think we'll either need to add some API to support
such kind of feeding or consider OSL does not have
support of packed images at all.
Movies are not supported at this moment because of lack
of RNA API to load specified frame. It's not difficult
to solve, just need to consider what to best here:
* Either write some general python interface for ImBuf
and use it via C++ API, or
* Write a PY API function which will return pixels for
given frame, or
* Use bad-level BKE_* call
Anyway, small steps, further improvements later.
Reviewed by Brecht, thanks!
2013-01-12 10:59:13 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Packed and generated images support for Cycles
This commit adds support of packed and generated images
for Cycles when using SVM backend. Movies are still not
supported. This changes also doesn't touch OSL which is
much less trivial to adopt for any images which are not
saved to disk.
Implementation details:
- When adding images to Image Manager is now possible
to mark image as builtin. Builtin images will bypass
OIIO loader and will use special loading callbacks.
- Callbacks are set by Blender Session and they're
using C++ RNA interface to obtain needed data (pixels,
dimensions, is_float flag).
- Image Manager assumes file path is used as reference
to a builtin images, but in fact currently image
datablock name is used for reference. This makes it
easy to find an image in BlendData database.
- Added some extra properties to Image RNA:
* channels, which denotes actual number of channels
in ImBuf. This is needed to treat image's pixels
correct (before it wasn't possible because API
used internal number of channels for pixels which
is in fact doesn't correlate with image depth)
* is_float, which is truth if image is stored in
float buffer of ImBuf.
- Implemented string lookup for C++ RNA collections
for cases there's no manual lookup function.
OSL is not supported because it used own image loading
and filtering routines and there's seems to be no API
to feed pre-loaded pixels directly to the library.
Think we'll either need to add some API to support
such kind of feeding or consider OSL does not have
support of packed images at all.
Movies are not supported at this moment because of lack
of RNA API to load specified frame. It's not difficult
to solve, just need to consider what to best here:
* Either write some general python interface for ImBuf
and use it via C++ API, or
* Write a PY API function which will return pixels for
given frame, or
* Use bad-level BKE_* call
Anyway, small steps, further improvements later.
Reviewed by Brecht, thanks!
2013-01-12 10:59:13 +00:00
|
|
|
prop = RNA_def_property(srna, "is_float", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Image_is_float_get", NULL);
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2021-01-04 12:00:00 +11:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Is Float", "True if this image is stored in floating-point buffer");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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
|
|
|
prop = RNA_def_property(srna, "colorspace_settings", PROP_POINTER, PROP_NONE);
|
|
|
|
|
RNA_def_property_pointer_sdna(prop, NULL, "colorspace_settings");
|
2012-12-24 15:51:27 +00:00
|
|
|
RNA_def_property_struct_type(prop, "ColorManagedInputColorspaceSettings");
|
2012-09-18 07:14:16 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Color Space Settings", "Input color space settings");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-31 13:52:13 +00:00
|
|
|
prop = RNA_def_property(srna, "alpha_mode", PROP_ENUM, PROP_NONE);
|
2019-06-14 23:16:04 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2012-12-31 13:52:13 +00:00
|
|
|
RNA_def_property_enum_items(prop, alpha_mode_items);
|
2019-05-26 12:37:51 +02:00
|
|
|
RNA_def_property_ui_text(prop,
|
|
|
|
|
"Alpha Mode",
|
|
|
|
|
"Representation of alpha in the image file, to convert to and from "
|
|
|
|
|
"when saving and loading the image");
|
2012-12-31 15:45:31 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_colormanage_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-02-25 15:05:53 +01:00
|
|
|
prop = RNA_def_property(srna, "use_half_precision", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
|
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMA_HIGH_BITDEPTH);
|
|
|
|
|
RNA_def_property_ui_text(prop,
|
|
|
|
|
"Half Float Precision",
|
2020-12-07 14:51:06 -08:00
|
|
|
"Use 16 bits per channel to lower the memory usage during rendering");
|
2020-02-25 15:05:53 +01:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_gpu_texture_update");
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* multiview */
|
|
|
|
|
prop = RNA_def_property(srna, "views_format", PROP_ENUM, PROP_NONE);
|
2019-06-14 23:16:04 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2015-04-06 10:40:12 -03:00
|
|
|
RNA_def_property_enum_sdna(prop, NULL, "views_format");
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(prop, rna_enum_views_format_items);
|
2015-04-06 10:40:12 -03:00
|
|
|
RNA_def_property_ui_text(prop, "Views Format", "Mode to load image views");
|
|
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_views_format_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
prop = RNA_def_property(srna, "stereo_3d_format", PROP_POINTER, PROP_NONE);
|
|
|
|
|
RNA_def_property_pointer_sdna(prop, NULL, "stereo3d_format");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
|
|
|
|
RNA_def_property_struct_type(prop, "Stereo3dFormat");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Stereo 3D Format", "Settings for stereo 3d");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-23 12:55:26 +00:00
|
|
|
RNA_api_image(srna);
|
2008-11-30 18:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RNA_def_image(BlenderRNA *brna)
|
|
|
|
|
{
|
2014-10-09 11:15:47 +02:00
|
|
|
rna_def_render_slot(brna);
|
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
|
|
|
rna_def_udim_tile(brna);
|
2008-11-30 18:39:49 +00:00
|
|
|
rna_def_image(brna);
|
|
|
|
|
rna_def_imageuser(brna);
|
2015-04-06 10:40:12 -03:00
|
|
|
rna_def_image_packed_files(brna);
|
2008-11-30 18:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|