2011-10-10 09:38:02 +00:00
|
|
|
/*
|
2002-10-12 11:37:38 +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
|
2006-12-20 17:57:56 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* 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.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup bke
|
2011-02-27 20:40:57 +00:00
|
|
|
*/
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <math.h>
|
2020-03-19 09:33:03 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2012-06-23 23:22:19 +00:00
|
|
|
#ifndef WIN32
|
2013-12-12 13:10:03 +06:00
|
|
|
# include <unistd.h>
|
2002-10-12 11:37:38 +00:00
|
|
|
#else
|
2013-12-12 13:10:03 +06:00
|
|
|
# include <io.h>
|
2002-10-12 11:37:38 +00:00
|
|
|
#endif
|
|
|
|
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
#include <time.h>
|
|
|
|
|
2019-02-01 12:44:19 +11:00
|
|
|
#include "CLG_log.h"
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
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
|
|
|
#include "IMB_colormanagement.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "IMB_imbuf.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "IMB_imbuf_types.h"
|
2018-04-05 16:27:15 +02:00
|
|
|
#include "IMB_metadata.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "IMB_moviecache.h"
|
2006-12-21 01:16:25 +00:00
|
|
|
|
|
|
|
#ifdef WITH_OPENEXR
|
2013-12-12 13:10:03 +06:00
|
|
|
# include "intern/openexr/openexr_multi.h"
|
2006-12-21 01:16:25 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-10-23 17:52:20 +00:00
|
|
|
#include "DNA_brush_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_camera_types.h"
|
|
|
|
#include "DNA_defaults.h"
|
|
|
|
#include "DNA_light_types.h"
|
2011-10-23 17:52:20 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
#include "DNA_meshdata_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_packedFile_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_sequence_types.h"
|
2019-09-07 23:17:40 +10:00
|
|
|
#include "DNA_world_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2014-10-02 19:04:38 +06:00
|
|
|
#include "BLI_math_vector.h"
|
2017-05-30 15:24:38 +02:00
|
|
|
#include "BLI_mempool.h"
|
2018-12-07 17:36:40 +01:00
|
|
|
#include "BLI_system.h"
|
2006-12-20 17:57:56 +00:00
|
|
|
#include "BLI_threads.h"
|
2019-04-17 06:17:24 +02:00
|
|
|
#include "BLI_timecode.h" /* for stamp timecode format */
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2020-03-06 17:11:55 +01:00
|
|
|
#include "BLT_translation.h"
|
|
|
|
|
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
|
|
|
#include "BKE_colortools.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_global.h"
|
2005-12-21 22:21:43 +00:00
|
|
|
#include "BKE_icons.h"
|
2020-03-06 17:11:55 +01:00
|
|
|
#include "BKE_idtype.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_image.h"
|
2020-02-10 12:58:59 +01:00
|
|
|
#include "BKE_lib_id.h"
|
2006-12-20 17:57:56 +00:00
|
|
|
#include "BKE_main.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_node.h"
|
2006-12-20 17:57:56 +00:00
|
|
|
#include "BKE_packedFile.h"
|
2015-05-22 23:28:41 +02:00
|
|
|
#include "BKE_report.h"
|
Biiig commit! Thanks to 2-3 weeks of cvs freeze...
Render:
- New; support for dual CPU render (SDL thread)
Currently only works with alternating scanlines, but gives excellent
performance. For both normal render as unified implemented.
Note the "mutex" locks on z-transp buffer render and imbuf loads.
- This has been made possible by major cleanups in render code, especially
getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct
OSA or using Materials or Texture data to write to.
- Made normal render fully 4x32 floats too, and removed all old optimizes
with chars or shorts.
- Made normal render and unified render use same code for sky and halo
render, giving equal (and better) results for halo render. Old render
now also uses PostProcess options (brightness, mul, gamma)
- Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer
after render. Using PostProcess menu you will note an immediate re-
display of image too (32 bits RGBA)
- Added "Hue" and "Saturation" sliders to PostProcess options
- Render module is still not having a "nice" API, but amount of dependencies
went down a lot. Next todo: remove abusive "previewrender" code.
The last main global in Render (struct Render) now can be re-used for fully
controlling a render, to allow multiple "instances" of render to open.
- Renderwindow now displays a smal bar on top with the stats, and keeps the
stats after render too. Including "spare" page support.
Not only easier visible that way, but also to remove the awkward code that
was drawing stats in the Info header (extreme slow on some ATIs too)
- Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping
defines.
- I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
|
|
|
#include "BKE_scene.h"
|
2011-02-17 22:34:41 +00:00
|
|
|
#include "BKE_sequencer.h" /* seq_foreground_frame_get() */
|
Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)
Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)
== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.
Opening files without UI and commandline rendering should work fine.
Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.
== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.
== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)
== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)
Reviewed By: campbellbarton, mont29
Tags: #user_interface, #bf_blender_2.8
Maniphest Tasks: T50521
Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
|
|
|
#include "BKE_workspace.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-08-18 19:26:53 +00:00
|
|
|
#include "BLF_api.h"
|
|
|
|
|
2005-07-27 07:43:48 +00:00
|
|
|
#include "PIL_time.h"
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
#include "RE_pipeline.h"
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
#include "GPU_draw.h"
|
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
|
|
|
#include "GPU_texture.h"
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
#include "BLI_sys_types.h" // for intptr_t support
|
2008-08-17 17:12:10 +00:00
|
|
|
|
2019-02-18 13:23:49 +01:00
|
|
|
#include "DEG_depsgraph.h"
|
|
|
|
#include "DEG_depsgraph_query.h"
|
|
|
|
|
2012-06-04 10:41:18 +00:00
|
|
|
/* for image user iteration */
|
|
|
|
#include "DNA_node_types.h"
|
|
|
|
#include "DNA_screen_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_space_types.h"
|
2012-06-04 10:41:18 +00:00
|
|
|
#include "DNA_view3d_types.h"
|
|
|
|
|
2019-02-01 12:44:19 +11:00
|
|
|
static CLG_LogRef LOG = {"bke.image"};
|
2019-11-19 07:37:16 -07:00
|
|
|
static ThreadMutex *image_mutex;
|
2012-11-15 15:59:58 +00:00
|
|
|
|
2020-03-06 17:11:55 +01:00
|
|
|
static void image_init(Image *ima, short source, short type);
|
|
|
|
static void image_free_packedfiles(Image *ima);
|
|
|
|
static void copy_image_packedfiles(ListBase *lb_dst, const ListBase *lb_src);
|
|
|
|
|
|
|
|
static void image_init_data(ID *id)
|
|
|
|
{
|
|
|
|
Image *image = (Image *)id;
|
|
|
|
|
|
|
|
if (image != NULL) {
|
|
|
|
image_init(image, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void image_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, const int flag)
|
|
|
|
{
|
|
|
|
Image *image_dst = (Image *)id_dst;
|
|
|
|
const Image *image_src = (const Image *)id_src;
|
|
|
|
|
|
|
|
BKE_color_managed_colorspace_settings_copy(&image_dst->colorspace_settings,
|
|
|
|
&image_src->colorspace_settings);
|
|
|
|
|
|
|
|
copy_image_packedfiles(&image_dst->packedfiles, &image_src->packedfiles);
|
|
|
|
|
|
|
|
image_dst->stereo3d_format = MEM_dupallocN(image_src->stereo3d_format);
|
|
|
|
BLI_duplicatelist(&image_dst->views, &image_src->views);
|
|
|
|
|
|
|
|
/* Cleanup stuff that cannot be copied. */
|
|
|
|
image_dst->cache = NULL;
|
|
|
|
image_dst->rr = NULL;
|
|
|
|
|
|
|
|
BLI_duplicatelist(&image_dst->renderslots, &image_src->renderslots);
|
|
|
|
LISTBASE_FOREACH (RenderSlot *, slot, &image_dst->renderslots) {
|
|
|
|
slot->render = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_listbase_clear(&image_dst->anims);
|
|
|
|
|
|
|
|
BLI_duplicatelist(&image_dst->tiles, &image_src->tiles);
|
|
|
|
|
2020-03-12 17:21:58 +01:00
|
|
|
for (int eye = 0; eye < 2; eye++) {
|
|
|
|
for (int i = 0; i < TEXTARGET_COUNT; i++) {
|
|
|
|
image_dst->gputexture[i][eye] = NULL;
|
|
|
|
}
|
2020-03-06 17:11:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
|
|
|
|
BKE_previewimg_id_copy(&image_dst->id, &image_src->id);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
image_dst->preview = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void image_free_data(ID *id)
|
|
|
|
{
|
|
|
|
Image *image = (Image *)id;
|
|
|
|
|
|
|
|
/* Also frees animdata. */
|
|
|
|
BKE_image_free_buffers(image);
|
|
|
|
|
|
|
|
image_free_packedfiles(image);
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (RenderSlot *, slot, &image->renderslots) {
|
|
|
|
if (slot->render) {
|
|
|
|
RE_FreeRenderResult(slot->render);
|
|
|
|
slot->render = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BLI_freelistN(&image->renderslots);
|
|
|
|
|
|
|
|
BKE_image_free_views(image);
|
|
|
|
MEM_SAFE_FREE(image->stereo3d_format);
|
|
|
|
|
|
|
|
BKE_icon_id_delete(&image->id);
|
|
|
|
BKE_previewimg_free(&image->preview);
|
|
|
|
|
|
|
|
BLI_freelistN(&image->tiles);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDTypeInfo IDType_ID_IM = {
|
|
|
|
.id_code = ID_IM,
|
|
|
|
.id_filter = FILTER_ID_IM,
|
|
|
|
.main_listbase_index = INDEX_ID_IM,
|
|
|
|
.struct_size = sizeof(Image),
|
|
|
|
.name = "Image",
|
|
|
|
.name_plural = "images",
|
|
|
|
.translation_context = BLT_I18NCONTEXT_ID_IMAGE,
|
|
|
|
.flags = 0,
|
|
|
|
|
|
|
|
.init_data = image_init_data,
|
|
|
|
.copy_data = image_copy_data,
|
|
|
|
.free_data = image_free_data,
|
|
|
|
.make_local = NULL,
|
|
|
|
};
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* prototypes */
|
2015-10-24 01:01:10 +11:00
|
|
|
static int image_num_files(struct Image *ima);
|
2015-05-08 07:25:39 +10:00
|
|
|
static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock);
|
2015-04-06 10:40:12 -03:00
|
|
|
static void image_update_views_format(Image *ima, ImageUser *iuser);
|
|
|
|
static void image_add_view(Image *ima, const char *viewname, const char *filepath);
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* max int, to indicate we don't store sequences in ibuf */
|
2019-04-17 06:17:24 +02:00
|
|
|
#define IMA_NO_INDEX 0x7FEFEFEF
|
2006-12-20 17:57:56 +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
|
|
|
/* quick lookup: supports 1 million entries, thousand passes */
|
|
|
|
#define IMA_MAKE_INDEX(entry, index) (((entry) << 10) + (index))
|
|
|
|
#define IMA_INDEX_ENTRY(index) ((index) >> 10)
|
2018-01-10 19:57:02 +11:00
|
|
|
#if 0
|
2019-04-17 06:17:24 +02:00
|
|
|
# define IMA_INDEX_PASS(index) (index & ~1023)
|
2018-01-10 19:57:02 +11:00
|
|
|
#endif
|
2006-12-20 17:57:56 +00:00
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
/* ******** IMAGE CACHE ************* */
|
|
|
|
|
|
|
|
typedef struct ImageCacheKey {
|
2019-04-17 06:17:24 +02:00
|
|
|
int index;
|
2013-12-13 16:22:08 +06:00
|
|
|
} ImageCacheKey;
|
|
|
|
|
|
|
|
static unsigned int imagecache_hashhash(const void *key_v)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const ImageCacheKey *key = key_v;
|
|
|
|
return key->index;
|
2013-12-13 16:22:08 +06:00
|
|
|
}
|
|
|
|
|
2014-09-25 06:15:52 +10:00
|
|
|
static bool imagecache_hashcmp(const void *a_v, const void *b_v)
|
2013-12-13 16:22:08 +06:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const ImageCacheKey *a = a_v;
|
|
|
|
const ImageCacheKey *b = b_v;
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return (a->index != b->index);
|
2013-12-13 16:22:08 +06:00
|
|
|
}
|
|
|
|
|
2014-04-02 16:50:06 +06:00
|
|
|
static void imagecache_keydata(void *userkey, int *framenr, int *proxy, int *render_flags)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImageCacheKey *key = userkey;
|
2014-04-02 16:50:06 +06: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
|
|
|
*framenr = IMA_INDEX_ENTRY(key->index);
|
2019-04-17 06:17:24 +02:00
|
|
|
*proxy = IMB_PROXY_NONE;
|
|
|
|
*render_flags = 0;
|
2014-04-02 16:50:06 +06:00
|
|
|
}
|
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
static void imagecache_put(Image *image, int index, ImBuf *ibuf)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImageCacheKey key;
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (image->cache == NULL) {
|
|
|
|
// char cache_name[64];
|
|
|
|
// SNPRINTF(cache_name, "Image Datablock %s", image->id.name);
|
2014-01-13 18:42:40 +06:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
image->cache = IMB_moviecache_create(
|
|
|
|
"Image Datablock Cache", sizeof(ImageCacheKey), imagecache_hashhash, imagecache_hashcmp);
|
|
|
|
IMB_moviecache_set_getdata_callback(image->cache, imagecache_keydata);
|
|
|
|
}
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
key.index = index;
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
IMB_moviecache_put(image->cache, &key, ibuf);
|
2013-12-13 16:22:08 +06: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 imagecache_remove(Image *image, int index)
|
|
|
|
{
|
|
|
|
if (image->cache == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageCacheKey key;
|
|
|
|
key.index = index;
|
|
|
|
IMB_moviecache_remove(image->cache, &key);
|
|
|
|
}
|
|
|
|
|
2013-12-18 15:35:31 +11:00
|
|
|
static struct ImBuf *imagecache_get(Image *image, int index)
|
2013-12-13 16:22:08 +06:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (image->cache) {
|
|
|
|
ImageCacheKey key;
|
|
|
|
key.index = index;
|
|
|
|
return IMB_moviecache_get(image->cache, &key);
|
|
|
|
}
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2013-12-13 16:22:08 +06:00
|
|
|
}
|
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
void BKE_images_init(void)
|
|
|
|
{
|
2019-11-19 07:37:16 -07:00
|
|
|
image_mutex = BLI_mutex_alloc();
|
2012-11-15 15:59:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_images_exit(void)
|
|
|
|
{
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_free(image_mutex);
|
2012-11-15 15:59:58 +00:00
|
|
|
}
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* ***************** ALLOC & FREE, DATA MANAGING *************** */
|
|
|
|
|
2014-10-17 12:37:40 +02:00
|
|
|
static void image_free_cached_frames(Image *image)
|
2006-06-05 11:07:15 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (image->cache) {
|
|
|
|
IMB_moviecache_free(image->cache);
|
|
|
|
image->cache = NULL;
|
|
|
|
}
|
2013-10-28 12:16:17 +00:00
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static void image_free_packedfiles(Image *ima)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
while (ima->packedfiles.last) {
|
|
|
|
ImagePackedFile *imapf = ima->packedfiles.last;
|
|
|
|
if (imapf->packedfile) {
|
2019-07-07 23:57:35 +10:00
|
|
|
BKE_packedfile_free(imapf->packedfile);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
BLI_remlink(&ima->packedfiles, imapf);
|
|
|
|
MEM_freeN(imapf);
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_free_packedfiles(Image *ima)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
image_free_packedfiles(ima);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_free_views(Image *image)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_freelistN(&image->views);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void image_free_anims(Image *ima)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
while (ima->anims.last) {
|
|
|
|
ImageAnim *ia = ima->anims.last;
|
|
|
|
if (ia->anim) {
|
|
|
|
IMB_free_anim(ia->anim);
|
|
|
|
ia->anim = NULL;
|
|
|
|
}
|
|
|
|
BLI_remlink(&ima->anims, ia);
|
|
|
|
MEM_freeN(ia);
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
2014-05-22 11:58:07 +10:00
|
|
|
/**
|
|
|
|
* Simply free the image data from memory,
|
|
|
|
* on display the image can load again (except for render buffers).
|
|
|
|
*/
|
2017-08-22 15:50:05 +02:00
|
|
|
void BKE_image_free_buffers_ex(Image *ima, bool do_lock)
|
2013-10-28 12:16:17 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (do_lock) {
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_lock(image_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
image_free_cached_frames(ima);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
image_free_anims(ima);
|
2010-03-27 15:35:34 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ima->rr) {
|
|
|
|
RE_FreeRenderResult(ima->rr);
|
|
|
|
ima->rr = NULL;
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (!G.background) {
|
2019-06-15 09:24:38 +10:00
|
|
|
/* Background mode doesn't use OpenGL,
|
2019-04-17 06:17:24 +02:00
|
|
|
* so we can avoid freeing GPU images and save some
|
|
|
|
* time by skipping mutex lock.
|
|
|
|
*/
|
|
|
|
GPU_free_image(ima);
|
|
|
|
}
|
2012-06-23 23:22:19 +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
|
|
|
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
|
|
|
|
tile->ok = IMA_OK;
|
|
|
|
}
|
2017-08-22 15:50:05 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (do_lock) {
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_unlock(image_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2017-08-22 15:50:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_free_buffers(Image *ima)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_image_free_buffers_ex(ima, false);
|
2006-06-05 11:07:15 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
/** Free (or release) any data used by this image (does not free the image itself). */
|
2012-05-05 14:03:12 +00:00
|
|
|
void BKE_image_free(Image *ima)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2020-03-06 17:11:55 +01:00
|
|
|
image_free_data(&ima->id);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* only image block itself */
|
2016-04-29 18:05:49 +02:00
|
|
|
static void image_init(Image *ima, short source, short type)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(ima, id));
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-09-12 04:34:55 +10:00
|
|
|
MEMCPY_STRUCT_AFTER(ima, DNA_struct_default_get(Image), id);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ima->source = source;
|
|
|
|
ima->type = type;
|
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
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (source == IMA_SRC_VIEWER) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ima->flag |= IMA_VIEW_AS_RENDER;
|
2019-04-22 09:39:35 +10: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
|
|
|
|
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
|
|
|
ImageTile *tile = MEM_callocN(sizeof(ImageTile), "Image Tiles");
|
|
|
|
tile->ok = IMA_OK;
|
|
|
|
tile->tile_number = 1001;
|
|
|
|
BLI_addtail(&ima->tiles, tile);
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (type == IMA_TYPE_R_RESULT) {
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
|
|
BKE_image_add_renderslot(ima, NULL);
|
|
|
|
}
|
|
|
|
}
|
2018-06-14 22:46:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_color_managed_colorspace_settings_init(&ima->colorspace_settings);
|
|
|
|
ima->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Image Stereo Format");
|
2016-04-29 18:05:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static Image *image_alloc(Main *bmain, const char *name, short source, short type)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Image *ima;
|
2016-04-29 18:05:49 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ima = BKE_libblock_alloc(bmain, ID_IM, name, 0);
|
|
|
|
if (ima) {
|
|
|
|
image_init(ima, source, type);
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return ima;
|
2006-12-20 17:57:56 +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
|
|
|
/* Get the ibuf from an image cache by it's index and entry.
|
2013-12-13 16:22:08 +06:00
|
|
|
* Local use here only.
|
|
|
|
*
|
|
|
|
* Returns referenced image buffer if it exists, callee is to
|
|
|
|
* call IMB_freeImBuf to de-reference the image buffer after
|
|
|
|
* it's done handling it.
|
|
|
|
*/
|
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 ImBuf *image_get_cached_ibuf_for_index_entry(Image *ima, int index, int entry)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (index != IMA_NO_INDEX) {
|
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
|
|
|
index = IMA_MAKE_INDEX(entry, index);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-11-15 15:59:58 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return imagecache_get(ima, index);
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* no ima->ibuf anymore, but listbase */
|
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 image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int entry)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (index != IMA_NO_INDEX) {
|
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
|
|
|
index = IMA_MAKE_INDEX(entry, index);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
imagecache_put(ima, index, ibuf);
|
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +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 image_remove_ibuf(Image *ima, int index, int entry)
|
|
|
|
{
|
|
|
|
if (index != IMA_NO_INDEX) {
|
|
|
|
index = IMA_MAKE_INDEX(entry, index);
|
|
|
|
}
|
|
|
|
imagecache_remove(ima, index);
|
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static void copy_image_packedfiles(ListBase *lb_dst, const ListBase *lb_src)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const ImagePackedFile *imapf_src;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_listbase_clear(lb_dst);
|
|
|
|
for (imapf_src = lb_src->first; imapf_src; imapf_src = imapf_src->next) {
|
|
|
|
ImagePackedFile *imapf_dst = MEM_mallocN(sizeof(ImagePackedFile), "Image Packed Files (copy)");
|
|
|
|
STRNCPY(imapf_dst->filepath, imapf_src->filepath);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (imapf_src->packedfile) {
|
2019-07-07 23:57:35 +10:00
|
|
|
imapf_dst->packedfile = BKE_packedfile_duplicate(imapf_src->packedfile);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_addtail(lb_dst, imapf_dst);
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
/* empty image block, of similar type and filename */
|
|
|
|
Image *BKE_image_copy(Main *bmain, const Image *ima)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Image *ima_copy;
|
|
|
|
BKE_id_copy(bmain, &ima->id, (ID **)&ima_copy);
|
|
|
|
return ima_copy;
|
2009-01-27 19:32:44 +00:00
|
|
|
}
|
|
|
|
|
2018-06-11 15:40:37 +02:00
|
|
|
void BKE_image_merge(Main *bmain, Image *dest, Image *source)
|
2009-01-27 19:32:44 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* sanity check */
|
|
|
|
if (dest && source && dest != source) {
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_lock(image_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (source->cache != NULL) {
|
|
|
|
struct MovieCacheIter *iter;
|
|
|
|
iter = IMB_moviecacheIter_new(source->cache);
|
|
|
|
while (!IMB_moviecacheIter_done(iter)) {
|
|
|
|
ImBuf *ibuf = IMB_moviecacheIter_getImBuf(iter);
|
|
|
|
ImageCacheKey *key = IMB_moviecacheIter_getUserKey(iter);
|
|
|
|
imagecache_put(dest, key->index, ibuf);
|
|
|
|
IMB_moviecacheIter_step(iter);
|
|
|
|
}
|
|
|
|
IMB_moviecacheIter_free(iter);
|
|
|
|
}
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_unlock(image_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
BKE_id_free(bmain, source);
|
|
|
|
}
|
2009-01-27 19:32:44 +00:00
|
|
|
}
|
|
|
|
|
2012-05-17 15:26:11 +00:00
|
|
|
/* note, we could be clever and scale all imbuf's but since some are mipmaps its not so simple */
|
2014-02-03 18:55:59 +11:00
|
|
|
bool BKE_image_scale(Image *image, int width, int height)
|
2012-05-17 15:26:11 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImBuf *ibuf;
|
|
|
|
void *lock;
|
2012-05-17 15:26:11 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);
|
2012-05-17 15:26:11 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf) {
|
|
|
|
IMB_scaleImBuf(ibuf, width, height);
|
2018-03-04 22:45:22 +01:00
|
|
|
BKE_image_mark_dirty(image, ibuf);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-05-17 15:26:11 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_image_release_ibuf(image, ibuf, lock);
|
2012-06-29 10:52:37 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return (ibuf != NULL);
|
2012-05-17 15:26:11 +00:00
|
|
|
}
|
|
|
|
|
2018-06-11 22:30:59 +02:00
|
|
|
bool BKE_image_has_opengl_texture(Image *ima)
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
{
|
2020-03-12 17:21:58 +01:00
|
|
|
for (int eye = 0; eye < 2; eye++) {
|
|
|
|
for (int i = 0; i < TEXTARGET_COUNT; i++) {
|
|
|
|
if (ima->gputexture[i][eye] != NULL) {
|
|
|
|
return true;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03: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
|
|
|
ImageTile *BKE_image_get_tile(Image *ima, int tile_number)
|
|
|
|
{
|
|
|
|
if (ima == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Verify valid tile range. */
|
|
|
|
if ((tile_number != 0) && (tile_number < 1001 || tile_number > IMA_UDIM_MAX)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Tile number 0 is a special case and refers to the first tile, typically
|
|
|
|
* coming from non-UDIM-aware code. */
|
|
|
|
if (tile_number == 0 || tile_number == 1001) {
|
|
|
|
return ima->tiles.first;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ima->source != IMA_SRC_TILED) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
|
|
|
|
if (tile->tile_number == tile_number) {
|
|
|
|
return tile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageTile *BKE_image_get_tile_from_iuser(Image *ima, ImageUser *iuser)
|
|
|
|
{
|
|
|
|
return BKE_image_get_tile(ima, (iuser && iuser->tile) ? iuser->tile : 1001);
|
|
|
|
}
|
|
|
|
|
|
|
|
int BKE_image_get_tile_from_pos(struct Image *ima,
|
|
|
|
const float uv[2],
|
2020-03-25 17:58:58 +11:00
|
|
|
float r_uv[2],
|
|
|
|
float r_ofs[2])
|
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
|
|
|
{
|
|
|
|
float local_ofs[2];
|
2020-03-25 17:58:58 +11:00
|
|
|
if (r_ofs == NULL) {
|
|
|
|
r_ofs = local_ofs;
|
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
|
|
|
}
|
|
|
|
|
2020-03-25 17:58:58 +11:00
|
|
|
copy_v2_v2(r_uv, uv);
|
|
|
|
zero_v2(r_ofs);
|
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
|
|
|
|
|
|
|
if ((ima->source != IMA_SRC_TILED) || uv[0] < 0.0f || uv[1] < 0.0f || uv[0] >= 10.0f) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ix = (int)uv[0];
|
|
|
|
int iy = (int)uv[1];
|
|
|
|
int tile_number = 1001 + 10 * iy + ix;
|
|
|
|
|
|
|
|
if (BKE_image_get_tile(ima, tile_number) == NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
2020-03-25 17:58:58 +11:00
|
|
|
r_ofs[0] = ix;
|
|
|
|
r_ofs[1] = iy;
|
|
|
|
sub_v2_v2(r_uv, r_ofs);
|
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
|
|
|
|
|
|
|
return tile_number;
|
|
|
|
}
|
|
|
|
|
2012-12-31 13:52:13 +00:00
|
|
|
static void image_init_color_management(Image *ima)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImBuf *ibuf;
|
|
|
|
char name[FILE_MAX];
|
2012-12-31 13:52:13 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_image_user_file_path(NULL, ima, name);
|
2012-12-31 13:52:13 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* will set input color space to image format default's */
|
|
|
|
ibuf = IMB_loadiffname(name, IB_test | IB_alphamode_detect, ima->colorspace_settings.name);
|
2012-12-31 13:52:13 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ibuf->flags & IB_alphamode_premul) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ima->alpha_mode = IMA_ALPHA_PREMUL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-05-18 20:52:20 +02:00
|
|
|
else if (ibuf->flags & IB_alphamode_channel_packed) {
|
|
|
|
ima->alpha_mode = IMA_ALPHA_CHANNEL_PACKED;
|
|
|
|
}
|
|
|
|
else if (ibuf->flags & IB_alphamode_ignore) {
|
|
|
|
ima->alpha_mode = IMA_ALPHA_IGNORE;
|
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
ima->alpha_mode = IMA_ALPHA_STRAIGHT;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-12-31 13:52:13 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
}
|
2012-12-31 13:52:13 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 03:09:01 +11:00
|
|
|
char BKE_image_alpha_mode_from_extension_ex(const char *filepath)
|
2013-02-19 08:37:08 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (BLI_path_extension_check_n(filepath, ".exr", ".cin", ".dpx", ".hdr", NULL)) {
|
|
|
|
return IMA_ALPHA_PREMUL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return IMA_ALPHA_STRAIGHT;
|
|
|
|
}
|
2013-02-19 08:37:08 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 03:09:01 +11:00
|
|
|
void BKE_image_alpha_mode_from_extension(Image *image)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
image->alpha_mode = BKE_image_alpha_mode_from_extension_ex(image->name);
|
2014-01-31 03:09:01 +11:00
|
|
|
}
|
|
|
|
|
2013-02-05 12:46:15 +00:00
|
|
|
Image *BKE_image_load(Main *bmain, const char *filepath)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Image *ima;
|
|
|
|
int file;
|
|
|
|
char str[FILE_MAX];
|
2012-05-05 14:52:04 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
STRNCPY(str, filepath);
|
|
|
|
BLI_path_abs(str, BKE_main_blendfile_path(bmain));
|
2012-05-05 14:52:04 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* exists? */
|
|
|
|
file = BLI_open(str, O_BINARY | O_RDONLY, 0);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (file == -1) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
close(file);
|
2012-05-05 14:52:04 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ima = image_alloc(bmain, BLI_path_basename(filepath), IMA_SRC_FILE, IMA_TYPE_IMAGE);
|
|
|
|
STRNCPY(ima->name, filepath);
|
2012-05-05 14:52:04 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (BLI_path_extension_check_array(filepath, imb_ext_movie)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ima->source = IMA_SRC_MOVIE;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-05-05 14:52:04 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
image_init_color_management(ima);
|
2012-12-31 13:52:13 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return ima;
|
2012-05-05 14:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* checks if image was already loaded, then returns same image */
|
|
|
|
/* otherwise creates new. */
|
|
|
|
/* does not load ibuf itself */
|
|
|
|
/* pass on optional frame for #name images */
|
2018-06-11 15:40:37 +02:00
|
|
|
Image *BKE_image_load_exists_ex(Main *bmain, const char *filepath, bool *r_exists)
|
2012-05-05 14:52:04 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Image *ima;
|
|
|
|
char str[FILE_MAX], strtest[FILE_MAX];
|
|
|
|
|
|
|
|
STRNCPY(str, filepath);
|
2019-10-04 07:03:53 +10:00
|
|
|
BLI_path_abs(str, bmain->name);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* first search an identical filepath */
|
|
|
|
for (ima = bmain->images.first; ima; ima = ima->id.next) {
|
|
|
|
if (ima->source != IMA_SRC_VIEWER && ima->source != IMA_SRC_GENERATED) {
|
|
|
|
STRNCPY(strtest, ima->name);
|
|
|
|
BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &ima->id));
|
|
|
|
|
|
|
|
if (BLI_path_cmp(strtest, str) == 0) {
|
|
|
|
if ((BKE_image_has_anim(ima) == false) || (ima->id.us == 0)) {
|
|
|
|
id_us_plus(&ima->id); /* officially should not, it doesn't link here! */
|
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
|
|
|
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
|
|
|
|
if (tile->ok == 0) {
|
|
|
|
tile->ok = IMA_OK;
|
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
if (r_exists) {
|
2019-04-17 06:17:24 +02:00
|
|
|
*r_exists = true;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
return ima;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (r_exists) {
|
2019-04-17 06:17:24 +02:00
|
|
|
*r_exists = false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
return BKE_image_load(bmain, filepath);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2018-06-11 15:40:37 +02:00
|
|
|
Image *BKE_image_load_exists(Main *bmain, const char *filepath)
|
2014-11-23 22:00:26 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return BKE_image_load_exists_ex(bmain, filepath, NULL);
|
2014-11-23 22:00:26 +01:00
|
|
|
}
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
static ImBuf *add_ibuf_size(unsigned int width,
|
|
|
|
unsigned int height,
|
|
|
|
const char *name,
|
|
|
|
int depth,
|
|
|
|
int floatbuf,
|
|
|
|
short gen_type,
|
|
|
|
const float color[4],
|
|
|
|
ColorManagedColorspaceSettings *colorspace_settings)
|
2005-09-16 20:17:09 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImBuf *ibuf;
|
|
|
|
unsigned char *rect = NULL;
|
|
|
|
float *rect_float = NULL;
|
2019-07-05 14:30:31 +02:00
|
|
|
float fill_color[4];
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (floatbuf) {
|
|
|
|
ibuf = IMB_allocImBuf(width, height, depth, IB_rectfloat);
|
2012-09-23 14:41:03 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (colorspace_settings->name[0] == '\0') {
|
|
|
|
const char *colorspace = IMB_colormanagement_role_colorspace_name_get(
|
|
|
|
COLOR_ROLE_DEFAULT_FLOAT);
|
2012-09-23 14:41:03 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
STRNCPY(colorspace_settings->name, colorspace);
|
|
|
|
}
|
2012-09-25 08:42:24 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf != NULL) {
|
|
|
|
rect_float = ibuf->rect_float;
|
|
|
|
IMB_colormanagement_check_is_data(ibuf, colorspace_settings->name);
|
|
|
|
}
|
2019-07-05 14:30:31 +02:00
|
|
|
|
|
|
|
if (IMB_colormanagement_space_name_is_data(colorspace_settings->name)) {
|
|
|
|
copy_v4_v4(fill_color, color);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* The input color here should ideally be linear already, but for now
|
|
|
|
* we just convert and postpone breaking the API for later. */
|
|
|
|
srgb_to_linearrgb_v4(fill_color, color);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ibuf = IMB_allocImBuf(width, height, depth, IB_rect);
|
2012-09-21 20:44:41 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (colorspace_settings->name[0] == '\0') {
|
|
|
|
const char *colorspace = IMB_colormanagement_role_colorspace_name_get(
|
|
|
|
COLOR_ROLE_DEFAULT_BYTE);
|
2012-09-23 14:41:03 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
STRNCPY(colorspace_settings->name, colorspace);
|
|
|
|
}
|
2012-09-23 14:41:03 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf != NULL) {
|
|
|
|
rect = (unsigned char *)ibuf->rect;
|
|
|
|
IMB_colormanagement_assign_rect_colorspace(ibuf, colorspace_settings->name);
|
|
|
|
}
|
2019-07-05 14:30:31 +02:00
|
|
|
|
|
|
|
copy_v4_v4(fill_color, color);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2013-12-16 16:42:48 +06:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (!ibuf) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
STRNCPY(ibuf->name, name);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
switch (gen_type) {
|
|
|
|
case IMA_GENTYPE_GRID:
|
|
|
|
BKE_image_buf_fill_checker(rect, rect_float, width, height);
|
|
|
|
break;
|
|
|
|
case IMA_GENTYPE_GRID_COLOR:
|
|
|
|
BKE_image_buf_fill_checker_color(rect, rect_float, width, height);
|
|
|
|
break;
|
|
|
|
default:
|
2019-07-05 14:30:31 +02:00
|
|
|
BKE_image_buf_fill_color(rect, rect_float, width, height, fill_color);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
}
|
2008-01-06 16:04:48 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return ibuf;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2005-09-16 20:17:09 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* adds new image block, creates ImBuf and initializes color */
|
2019-04-17 06:17:24 +02:00
|
|
|
Image *BKE_image_add_generated(Main *bmain,
|
|
|
|
unsigned int width,
|
|
|
|
unsigned int height,
|
|
|
|
const char *name,
|
|
|
|
int depth,
|
|
|
|
int floatbuf,
|
|
|
|
short gen_type,
|
|
|
|
const float color[4],
|
2019-06-26 15:04:44 +02:00
|
|
|
const bool stereo3d,
|
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
|
|
|
const bool is_data,
|
|
|
|
const bool tiled)
|
2019-04-17 06:17:24 +02:00
|
|
|
{
|
|
|
|
/* on save, type is changed to FILE in editsima.c */
|
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 *ima;
|
|
|
|
if (tiled) {
|
|
|
|
ima = image_alloc(bmain, name, IMA_SRC_TILED, IMA_TYPE_IMAGE);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ima = image_alloc(bmain, name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST);
|
|
|
|
}
|
2019-06-26 15:04:44 +02:00
|
|
|
if (ima == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-26 15:04:44 +02:00
|
|
|
int view_id;
|
|
|
|
const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
|
|
|
|
|
|
|
|
/* STRNCPY(ima->name, name); */ /* don't do this, this writes in ain invalid filepath! */
|
|
|
|
ima->gen_x = width;
|
|
|
|
ima->gen_y = height;
|
|
|
|
ima->gen_type = gen_type;
|
|
|
|
ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0);
|
|
|
|
ima->gen_depth = depth;
|
|
|
|
copy_v4_v4(ima->gen_color, color);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-26 15:04:44 +02:00
|
|
|
if (is_data) {
|
|
|
|
STRNCPY(ima->colorspace_settings.name,
|
|
|
|
IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DATA));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (view_id = 0; view_id < 2; view_id++) {
|
|
|
|
ImBuf *ibuf;
|
|
|
|
ibuf = add_ibuf_size(
|
|
|
|
width, height, ima->name, depth, floatbuf, gen_type, color, &ima->colorspace_settings);
|
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
|
|
|
int index = tiled ? 0 : IMA_NO_INDEX;
|
|
|
|
int entry = tiled ? 1001 : 0;
|
|
|
|
image_assign_ibuf(ima, ibuf, stereo3d ? view_id : index, entry);
|
2019-06-26 15:04:44 +02:00
|
|
|
|
|
|
|
/* image_assign_ibuf puts buffer to the cache, which increments user counter. */
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
if (!stereo3d) {
|
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2019-06-26 15:04:44 +02:00
|
|
|
image_add_view(ima, names[view_id], "");
|
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
|
|
|
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
|
|
|
tile->ok = IMA_OK_LOADED;
|
2019-06-26 15:04:44 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return ima;
|
2010-03-08 20:08:04 +00:00
|
|
|
}
|
|
|
|
|
2015-02-09 12:02:59 +01:00
|
|
|
/* Create an image image from ibuf. The refcount of ibuf is increased,
|
|
|
|
* caller should take care to drop its reference by calling
|
|
|
|
* IMB_freeImBuf if needed. */
|
2018-06-11 15:40:37 +02:00
|
|
|
Image *BKE_image_add_from_imbuf(Main *bmain, ImBuf *ibuf, const char *name)
|
2010-03-08 20:08:04 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* on save, type is changed to FILE in editsima.c */
|
|
|
|
Image *ima;
|
2010-03-08 21:33:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (name == NULL) {
|
|
|
|
name = BLI_path_basename(ibuf->name);
|
|
|
|
}
|
2015-05-04 12:25:33 +10:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ima = image_alloc(bmain, name, IMA_SRC_FILE, IMA_TYPE_IMAGE);
|
2010-03-08 20:08:04 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ima) {
|
|
|
|
STRNCPY(ima->name, ibuf->name);
|
|
|
|
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
|
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
|
|
|
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
|
|
|
tile->ok = IMA_OK_LOADED;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2010-03-08 20:08:04 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return ima;
|
2005-09-16 20:17:09 +00:00
|
|
|
}
|
|
|
|
|
2016-02-20 14:52:36 +01:00
|
|
|
/* Pack image buffer to memory as PNG or EXR. */
|
2018-03-03 16:55:08 +01:00
|
|
|
static bool image_memorypack_imbuf(Image *ima, ImBuf *ibuf, const char *filepath)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2016-02-20 14:52:36 +01:00
|
|
|
ibuf->ftype = (ibuf->rect_float) ? IMB_FTYPE_OPENEXR : IMB_FTYPE_PNG;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2018-03-03 16:55:08 +01:00
|
|
|
IMB_saveiff(ibuf, filepath, IB_rect | IB_mem);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2018-03-03 16:55:08 +01:00
|
|
|
if (ibuf->encodedbuffer == NULL) {
|
|
|
|
CLOG_STR_ERROR(&LOG, "memory save for pack error");
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
image_free_packedfiles(ima);
|
|
|
|
return false;
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2018-03-03 16:55:08 +01:00
|
|
|
ImagePackedFile *imapf;
|
|
|
|
PackedFile *pf = MEM_callocN(sizeof(*pf), "PackedFile");
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2018-03-03 16:55:08 +01:00
|
|
|
pf->data = ibuf->encodedbuffer;
|
|
|
|
pf->size = ibuf->encodedsize;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2018-03-03 16:55:08 +01:00
|
|
|
imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image PackedFile");
|
|
|
|
STRNCPY(imapf->filepath, filepath);
|
|
|
|
imapf->packedfile = pf;
|
|
|
|
BLI_addtail(&ima->packedfiles, imapf);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2018-03-03 16:55:08 +01:00
|
|
|
ibuf->encodedbuffer = NULL;
|
|
|
|
ibuf->encodedsize = 0;
|
|
|
|
ibuf->userflags &= ~IB_BITMAPDIRTY;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2018-03-03 16:55:08 +01:00
|
|
|
return true;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
2018-03-03 16:55:08 +01:00
|
|
|
/* Pack image to memory. */
|
|
|
|
bool BKE_image_memorypack(Image *ima)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2018-03-03 16:55:08 +01:00
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
image_free_packedfiles(ima);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (BKE_image_is_multiview(ima)) {
|
2018-03-03 16:55:08 +01:00
|
|
|
/* Store each view as a separate packed files with R_IMF_VIEWS_INDIVIDUAL. */
|
|
|
|
ImageView *iv;
|
|
|
|
int i;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2018-03-03 16:55:08 +01:00
|
|
|
for (i = 0, iv = ima->views.first; iv; iv = iv->next, i++) {
|
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
|
|
|
ImBuf *ibuf = image_get_cached_ibuf_for_index_entry(ima, i, 0);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2018-03-03 16:55:08 +01:00
|
|
|
if (!ibuf) {
|
|
|
|
ok = false;
|
|
|
|
break;
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2018-03-03 16:55:08 +01:00
|
|
|
/* if the image was a R_IMF_VIEWS_STEREO_3D we force _L, _R suffices */
|
|
|
|
if (ima->views_format == R_IMF_VIEWS_STEREO_3D) {
|
|
|
|
const char *suffix[2] = {STEREO_LEFT_SUFFIX, STEREO_RIGHT_SUFFIX};
|
|
|
|
BLI_path_suffix(iv->filepath, FILE_MAX, suffix[i], "");
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2018-03-03 16:55:08 +01:00
|
|
|
ok = ok && image_memorypack_imbuf(ima, ibuf, iv->filepath);
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2018-03-03 16:55:08 +01:00
|
|
|
ima->views_format = R_IMF_VIEWS_INDIVIDUAL;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
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
|
|
|
ImBuf *ibuf = image_get_cached_ibuf_for_index_entry(ima, IMA_NO_INDEX, 0);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2018-03-03 16:55:08 +01:00
|
|
|
if (ibuf) {
|
|
|
|
ok = ok && image_memorypack_imbuf(ima, ibuf, ibuf->name);
|
|
|
|
IMB_freeImBuf(ibuf);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-03-03 16:55:08 +01:00
|
|
|
else {
|
|
|
|
ok = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ok && ima->source == IMA_SRC_GENERATED) {
|
|
|
|
ima->source = IMA_SRC_FILE;
|
|
|
|
ima->type = IMA_TYPE_IMAGE;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2018-03-03 16:55:08 +01:00
|
|
|
return ok;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
void BKE_image_packfiles(ReportList *reports, Image *ima, const char *basepath)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const int totfiles = image_num_files(ima);
|
|
|
|
|
|
|
|
if (totfiles == 1) {
|
|
|
|
ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image packed file");
|
|
|
|
BLI_addtail(&ima->packedfiles, imapf);
|
2019-07-07 23:57:35 +10:00
|
|
|
imapf->packedfile = BKE_packedfile_new(reports, ima->name, basepath);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (imapf->packedfile) {
|
|
|
|
STRNCPY(imapf->filepath, ima->name);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_freelinkN(&ima->packedfiles, imapf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ImageView *iv;
|
|
|
|
for (iv = ima->views.first; iv; iv = iv->next) {
|
|
|
|
ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image packed file");
|
|
|
|
BLI_addtail(&ima->packedfiles, imapf);
|
|
|
|
|
2019-07-07 23:57:35 +10:00
|
|
|
imapf->packedfile = BKE_packedfile_new(reports, iv->filepath, basepath);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (imapf->packedfile) {
|
|
|
|
STRNCPY(imapf->filepath, iv->filepath);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_freelinkN(&ima->packedfiles, imapf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_packfiles_from_mem(ReportList *reports,
|
|
|
|
Image *ima,
|
|
|
|
char *data,
|
|
|
|
const size_t data_len)
|
|
|
|
{
|
|
|
|
const int totfiles = image_num_files(ima);
|
|
|
|
|
|
|
|
if (totfiles != 1) {
|
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot pack multiview images from raw data currently...");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), __func__);
|
|
|
|
BLI_addtail(&ima->packedfiles, imapf);
|
2019-07-07 23:57:35 +10:00
|
|
|
imapf->packedfile = BKE_packedfile_new_from_memory(data, data_len);
|
2019-04-17 06:17:24 +02:00
|
|
|
STRNCPY(imapf->filepath, ima->name);
|
|
|
|
}
|
2015-05-22 23:28:41 +02:00
|
|
|
}
|
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
void BKE_image_tag_time(Image *ima)
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ima->lastused = PIL_check_seconds_timer_i();
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
}
|
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
static uintptr_t image_mem_size(Image *image)
|
2008-02-01 12:14:15 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
uintptr_t size = 0;
|
|
|
|
|
|
|
|
/* viewers have memory depending on other rules, has no valid rect pointer */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (image->source == IMA_SRC_VIEWER) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_lock(image_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (image->cache != NULL) {
|
|
|
|
struct MovieCacheIter *iter = IMB_moviecacheIter_new(image->cache);
|
|
|
|
|
|
|
|
while (!IMB_moviecacheIter_done(iter)) {
|
|
|
|
ImBuf *ibuf = IMB_moviecacheIter_getImBuf(iter);
|
|
|
|
ImBuf *ibufm;
|
|
|
|
int level;
|
|
|
|
|
|
|
|
if (ibuf->rect) {
|
|
|
|
size += MEM_allocN_len(ibuf->rect);
|
|
|
|
}
|
|
|
|
if (ibuf->rect_float) {
|
|
|
|
size += MEM_allocN_len(ibuf->rect_float);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (level = 0; level < IMB_MIPMAP_LEVELS; level++) {
|
|
|
|
ibufm = ibuf->mipmap[level];
|
|
|
|
if (ibufm) {
|
|
|
|
if (ibufm->rect) {
|
|
|
|
size += MEM_allocN_len(ibufm->rect);
|
|
|
|
}
|
|
|
|
if (ibufm->rect_float) {
|
|
|
|
size += MEM_allocN_len(ibufm->rect_float);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IMB_moviecacheIter_step(iter);
|
|
|
|
}
|
|
|
|
IMB_moviecacheIter_free(iter);
|
|
|
|
}
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_unlock(image_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
return size;
|
2008-02-01 12:14:15 +00:00
|
|
|
}
|
|
|
|
|
2018-06-11 15:40:37 +02:00
|
|
|
void BKE_image_print_memlist(Main *bmain)
|
2008-02-01 12:14:15 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Image *ima;
|
|
|
|
uintptr_t size, totsize = 0;
|
2008-02-01 12:14:15 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
for (ima = bmain->images.first; ima; ima = ima->id.next) {
|
2019-04-17 06:17:24 +02:00
|
|
|
totsize += image_mem_size(ima);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2008-02-01 12:14:15 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
printf("\ntotal image memory len: %.3f MB\n", (double)totsize / (double)(1024 * 1024));
|
2008-02-01 12:14:15 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
for (ima = bmain->images.first; ima; ima = ima->id.next) {
|
|
|
|
size = image_mem_size(ima);
|
2008-02-01 12:14:15 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (size) {
|
2019-04-17 06:17:24 +02:00
|
|
|
printf("%s len: %.3f MB\n", ima->id.name + 2, (double)size / (double)(1024 * 1024));
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2008-02-01 12:14:15 +00:00
|
|
|
}
|
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
static bool imagecache_check_dirty(ImBuf *ibuf, void *UNUSED(userkey), void *UNUSED(userdata))
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return (ibuf->userflags & IB_BITMAPDIRTY) == 0;
|
2013-12-13 16:22:08 +06:00
|
|
|
}
|
|
|
|
|
2018-06-11 15:40:37 +02:00
|
|
|
void BKE_image_free_all_textures(Main *bmain)
|
2006-02-11 23:17:41 +00:00
|
|
|
{
|
2013-12-13 16:22:08 +06:00
|
|
|
#undef CHECK_FREED_SIZE
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
Tex *tex;
|
|
|
|
Image *ima;
|
2013-12-13 16:22:08 +06:00
|
|
|
#ifdef CHECK_FREED_SIZE
|
2019-04-17 06:17:24 +02:00
|
|
|
uintptr_t tot_freed_size = 0;
|
2013-12-13 16:22:08 +06:00
|
|
|
#endif
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
for (ima = bmain->images.first; ima; ima = ima->id.next) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ima->id.tag &= ~LIB_TAG_DOIT;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
for (tex = bmain->textures.first; tex; tex = tex->id.next) {
|
|
|
|
if (tex->ima) {
|
2019-04-17 06:17:24 +02:00
|
|
|
tex->ima->id.tag |= LIB_TAG_DOIT;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
for (ima = bmain->images.first; ima; ima = ima->id.next) {
|
|
|
|
if (ima->cache && (ima->id.tag & LIB_TAG_DOIT)) {
|
2013-12-13 16:22:08 +06:00
|
|
|
#ifdef CHECK_FREED_SIZE
|
2019-04-17 06:17:24 +02:00
|
|
|
uintptr_t old_size = image_mem_size(ima);
|
2013-12-13 16:22:08 +06:00
|
|
|
#endif
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
IMB_moviecache_cleanup(ima->cache, imagecache_check_dirty, NULL);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
#ifdef CHECK_FREED_SIZE
|
2019-04-17 06:17:24 +02:00
|
|
|
tot_freed_size += old_size - image_mem_size(ima);
|
2012-03-03 20:19:11 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
2013-12-13 16:22:08 +06:00
|
|
|
#ifdef CHECK_FREED_SIZE
|
2019-04-17 06:17:24 +02:00
|
|
|
printf("%s: freed total %lu MB\n", __func__, tot_freed_size / (1024 * 1024));
|
2013-12-13 16:22:08 +06:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool imagecache_check_free_anim(ImBuf *ibuf, void *UNUSED(userkey), void *userdata)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
int except_frame = *(int *)userdata;
|
|
|
|
return (ibuf->userflags & IB_BITMAPDIRTY) == 0 && (ibuf->index != IMA_NO_INDEX) &&
|
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
|
|
|
(except_frame != IMA_INDEX_ENTRY(ibuf->index));
|
2006-02-11 23:17:41 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* except_frame is weak, only works for seqs without offset... */
|
|
|
|
void BKE_image_free_anim_ibufs(Image *ima, int except_frame)
|
|
|
|
{
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_lock(image_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ima->cache != NULL) {
|
|
|
|
IMB_moviecache_cleanup(ima->cache, imagecache_check_free_anim, &except_frame);
|
|
|
|
}
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_unlock(image_mutex);
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
2018-06-11 15:40:37 +02:00
|
|
|
void BKE_image_all_free_anim_ibufs(Main *bmain, int cfra)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Image *ima;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
for (ima = bmain->images.first; ima; ima = ima->id.next) {
|
|
|
|
if (BKE_image_is_animated(ima)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_image_free_anim_ibufs(ima, cfra);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* *********** READ AND WRITE ************** */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
int BKE_image_imtype_to_ftype(const char imtype, ImbFormatOptions *r_options)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
memset(r_options, 0, sizeof(*r_options));
|
|
|
|
|
|
|
|
if (imtype == R_IMF_IMTYPE_TARGA) {
|
|
|
|
return IMB_FTYPE_TGA;
|
|
|
|
}
|
|
|
|
else if (imtype == R_IMF_IMTYPE_RAWTGA) {
|
|
|
|
r_options->flag = RAWTGA;
|
|
|
|
return IMB_FTYPE_TGA;
|
|
|
|
}
|
|
|
|
else if (imtype == R_IMF_IMTYPE_IRIS) {
|
|
|
|
return IMB_FTYPE_IMAGIC;
|
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_HDR
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_RADHDR) {
|
|
|
|
return IMB_FTYPE_RADHDR;
|
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_PNG) {
|
|
|
|
r_options->quality = 15;
|
|
|
|
return IMB_FTYPE_PNG;
|
|
|
|
}
|
2007-06-25 19:50:25 +00:00
|
|
|
#ifdef WITH_DDS
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_DDS) {
|
|
|
|
return IMB_FTYPE_DDS;
|
|
|
|
}
|
2007-06-25 19:50:25 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_BMP) {
|
|
|
|
return IMB_FTYPE_BMP;
|
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_TIFF
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_TIFF) {
|
|
|
|
return IMB_FTYPE_TIF;
|
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_OPENEXR || imtype == R_IMF_IMTYPE_MULTILAYER) {
|
|
|
|
return IMB_FTYPE_OPENEXR;
|
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_CINEON
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_CINEON) {
|
|
|
|
return IMB_FTYPE_CINEON;
|
|
|
|
}
|
|
|
|
else if (imtype == R_IMF_IMTYPE_DPX) {
|
|
|
|
return IMB_FTYPE_DPX;
|
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2009-01-26 08:34:40 +00:00
|
|
|
#ifdef WITH_OPENJPEG
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_JP2) {
|
|
|
|
r_options->flag |= JP2_JP2;
|
|
|
|
r_options->quality = 90;
|
|
|
|
return IMB_FTYPE_JP2;
|
|
|
|
}
|
2009-01-26 08:34:40 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else {
|
|
|
|
r_options->quality = 90;
|
|
|
|
return IMB_FTYPE_JPG;
|
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
char BKE_image_ftype_to_imtype(const int ftype, const ImbFormatOptions *options)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ftype == 0) {
|
|
|
|
return R_IMF_IMTYPE_TARGA;
|
|
|
|
}
|
|
|
|
else if (ftype == IMB_FTYPE_IMAGIC) {
|
|
|
|
return R_IMF_IMTYPE_IRIS;
|
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_HDR
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (ftype == IMB_FTYPE_RADHDR) {
|
|
|
|
return R_IMF_IMTYPE_RADHDR;
|
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (ftype == IMB_FTYPE_PNG) {
|
|
|
|
return R_IMF_IMTYPE_PNG;
|
|
|
|
}
|
2007-06-25 19:50:25 +00:00
|
|
|
#ifdef WITH_DDS
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (ftype == IMB_FTYPE_DDS) {
|
|
|
|
return R_IMF_IMTYPE_DDS;
|
|
|
|
}
|
2007-06-25 19:50:25 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (ftype == IMB_FTYPE_BMP) {
|
|
|
|
return R_IMF_IMTYPE_BMP;
|
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_TIFF
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (ftype == IMB_FTYPE_TIF) {
|
|
|
|
return R_IMF_IMTYPE_TIFF;
|
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (ftype == IMB_FTYPE_OPENEXR) {
|
|
|
|
return R_IMF_IMTYPE_OPENEXR;
|
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_CINEON
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (ftype == IMB_FTYPE_CINEON) {
|
|
|
|
return R_IMF_IMTYPE_CINEON;
|
|
|
|
}
|
|
|
|
else if (ftype == IMB_FTYPE_DPX) {
|
|
|
|
return R_IMF_IMTYPE_DPX;
|
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (ftype == IMB_FTYPE_TGA) {
|
|
|
|
if (options && (options->flag & RAWTGA)) {
|
|
|
|
return R_IMF_IMTYPE_RAWTGA;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return R_IMF_IMTYPE_TARGA;
|
|
|
|
}
|
|
|
|
}
|
2009-01-26 08:34:40 +00:00
|
|
|
#ifdef WITH_OPENJPEG
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (ftype == IMB_FTYPE_JP2) {
|
|
|
|
return R_IMF_IMTYPE_JP2;
|
|
|
|
}
|
2009-01-26 08:34:40 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else {
|
|
|
|
return R_IMF_IMTYPE_JPEG90;
|
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
2013-03-09 05:35:49 +00:00
|
|
|
bool BKE_imtype_is_movie(const char imtype)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
switch (imtype) {
|
|
|
|
case R_IMF_IMTYPE_AVIRAW:
|
|
|
|
case R_IMF_IMTYPE_AVIJPEG:
|
|
|
|
case R_IMF_IMTYPE_FFMPEG:
|
|
|
|
case R_IMF_IMTYPE_H264:
|
|
|
|
case R_IMF_IMTYPE_THEORA:
|
|
|
|
case R_IMF_IMTYPE_XVID:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2011-11-22 00:06:54 +00:00
|
|
|
int BKE_imtype_supports_zbuf(const char imtype)
|
2011-11-21 20:19:58 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
switch (imtype) {
|
|
|
|
case R_IMF_IMTYPE_IRIZ:
|
|
|
|
case R_IMF_IMTYPE_OPENEXR: /* but not R_IMF_IMTYPE_MULTILAYER */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2011-11-21 20:19:58 +00:00
|
|
|
}
|
|
|
|
|
2011-11-22 00:06:54 +00:00
|
|
|
int BKE_imtype_supports_compress(const char imtype)
|
2011-11-21 20:19:58 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
switch (imtype) {
|
|
|
|
case R_IMF_IMTYPE_PNG:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2011-11-21 20:19:58 +00:00
|
|
|
}
|
|
|
|
|
2011-11-22 00:06:54 +00:00
|
|
|
int BKE_imtype_supports_quality(const char imtype)
|
2011-11-21 20:19:58 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
switch (imtype) {
|
|
|
|
case R_IMF_IMTYPE_JPEG90:
|
|
|
|
case R_IMF_IMTYPE_JP2:
|
|
|
|
case R_IMF_IMTYPE_AVIJPEG:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2011-11-21 20:19:58 +00:00
|
|
|
}
|
|
|
|
|
2012-09-24 11:56:07 +00:00
|
|
|
int BKE_imtype_requires_linear_float(const char imtype)
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
switch (imtype) {
|
|
|
|
case R_IMF_IMTYPE_CINEON:
|
|
|
|
case R_IMF_IMTYPE_DPX:
|
|
|
|
case R_IMF_IMTYPE_RADHDR:
|
|
|
|
case R_IMF_IMTYPE_OPENEXR:
|
|
|
|
case R_IMF_IMTYPE_MULTILAYER:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return 0;
|
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
|
|
|
}
|
|
|
|
|
2014-03-31 14:20:55 +09:00
|
|
|
char BKE_imtype_valid_channels(const char imtype, bool write_file)
|
2011-11-25 03:47:34 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
char chan_flag = IMA_CHAN_FLAG_RGB; /* assume all support rgb */
|
|
|
|
|
|
|
|
/* alpha */
|
|
|
|
switch (imtype) {
|
|
|
|
case R_IMF_IMTYPE_BMP:
|
2019-04-22 09:39:35 +10:00
|
|
|
if (write_file) {
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
ATTR_FALLTHROUGH;
|
|
|
|
case R_IMF_IMTYPE_TARGA:
|
|
|
|
case R_IMF_IMTYPE_RAWTGA:
|
|
|
|
case R_IMF_IMTYPE_IRIS:
|
|
|
|
case R_IMF_IMTYPE_PNG:
|
|
|
|
case R_IMF_IMTYPE_TIFF:
|
|
|
|
case R_IMF_IMTYPE_OPENEXR:
|
|
|
|
case R_IMF_IMTYPE_MULTILAYER:
|
|
|
|
case R_IMF_IMTYPE_DDS:
|
|
|
|
case R_IMF_IMTYPE_JP2:
|
|
|
|
case R_IMF_IMTYPE_DPX:
|
|
|
|
chan_flag |= IMA_CHAN_FLAG_ALPHA;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* bw */
|
|
|
|
switch (imtype) {
|
2020-01-29 12:37:14 +11:00
|
|
|
case R_IMF_IMTYPE_BMP:
|
2019-04-17 06:17:24 +02:00
|
|
|
case R_IMF_IMTYPE_PNG:
|
|
|
|
case R_IMF_IMTYPE_JPEG90:
|
|
|
|
case R_IMF_IMTYPE_TARGA:
|
|
|
|
case R_IMF_IMTYPE_RAWTGA:
|
|
|
|
case R_IMF_IMTYPE_TIFF:
|
|
|
|
case R_IMF_IMTYPE_IRIS:
|
|
|
|
chan_flag |= IMA_CHAN_FLAG_BW;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return chan_flag;
|
2011-11-25 03:47:34 +00:00
|
|
|
}
|
|
|
|
|
2011-11-22 00:06:54 +00:00
|
|
|
char BKE_imtype_valid_depths(const char imtype)
|
2011-11-21 20:19:58 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
switch (imtype) {
|
|
|
|
case R_IMF_IMTYPE_RADHDR:
|
|
|
|
return R_IMF_CHAN_DEPTH_32;
|
|
|
|
case R_IMF_IMTYPE_TIFF:
|
|
|
|
return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_16;
|
|
|
|
case R_IMF_IMTYPE_OPENEXR:
|
|
|
|
return R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_32;
|
|
|
|
case R_IMF_IMTYPE_MULTILAYER:
|
|
|
|
return R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_32;
|
|
|
|
/* eeh, cineon does some strange 10bits per channel */
|
|
|
|
case R_IMF_IMTYPE_DPX:
|
|
|
|
return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_10 | R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16;
|
|
|
|
case R_IMF_IMTYPE_CINEON:
|
|
|
|
return R_IMF_CHAN_DEPTH_10;
|
|
|
|
case R_IMF_IMTYPE_JP2:
|
|
|
|
return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16;
|
|
|
|
case R_IMF_IMTYPE_PNG:
|
|
|
|
return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_16;
|
|
|
|
/* most formats are 8bit only */
|
|
|
|
default:
|
|
|
|
return R_IMF_CHAN_DEPTH_8;
|
|
|
|
}
|
2011-11-21 20:19:58 +00:00
|
|
|
}
|
|
|
|
|
2011-11-24 05:18:26 +00:00
|
|
|
/* string is from command line --render-format arg, keep in sync with
|
2016-03-04 06:35:17 +11:00
|
|
|
* creator_args.c help info */
|
2011-11-24 05:18:26 +00:00
|
|
|
char BKE_imtype_from_arg(const char *imtype_arg)
|
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (STREQ(imtype_arg, "TGA")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_TARGA;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (STREQ(imtype_arg, "IRIS")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_IRIS;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2011-11-24 05:18:26 +00:00
|
|
|
#ifdef WITH_DDS
|
2019-04-22 09:39:35 +10:00
|
|
|
else if (STREQ(imtype_arg, "DDS")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_DDS;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2011-11-24 05:18:26 +00:00
|
|
|
#endif
|
2019-04-22 09:39:35 +10:00
|
|
|
else if (STREQ(imtype_arg, "JPEG")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_JPEG90;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (STREQ(imtype_arg, "IRIZ")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_IRIZ;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (STREQ(imtype_arg, "RAWTGA")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_RAWTGA;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (STREQ(imtype_arg, "AVIRAW")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_AVIRAW;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (STREQ(imtype_arg, "AVIJPEG")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_AVIJPEG;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (STREQ(imtype_arg, "PNG")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_PNG;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (STREQ(imtype_arg, "BMP")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_BMP;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2011-11-24 05:18:26 +00:00
|
|
|
#ifdef WITH_HDR
|
2019-04-22 09:39:35 +10:00
|
|
|
else if (STREQ(imtype_arg, "HDR")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_RADHDR;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2011-11-24 05:18:26 +00:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_TIFF
|
2019-04-22 09:39:35 +10:00
|
|
|
else if (STREQ(imtype_arg, "TIFF")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_TIFF;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2011-11-24 05:18:26 +00:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_OPENEXR
|
2019-04-22 09:39:35 +10:00
|
|
|
else if (STREQ(imtype_arg, "OPEN_EXR")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_OPENEXR;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (STREQ(imtype_arg, "OPEN_EXR_MULTILAYER")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_MULTILAYER;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (STREQ(imtype_arg, "EXR")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_OPENEXR;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (STREQ(imtype_arg, "MULTILAYER")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_MULTILAYER;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2011-11-24 05:18:26 +00:00
|
|
|
#endif
|
2019-04-22 09:39:35 +10:00
|
|
|
else if (STREQ(imtype_arg, "FFMPEG")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_FFMPEG;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2011-11-24 05:18:26 +00:00
|
|
|
#ifdef WITH_CINEON
|
2019-04-22 09:39:35 +10:00
|
|
|
else if (STREQ(imtype_arg, "CINEON")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_CINEON;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (STREQ(imtype_arg, "DPX")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_DPX;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2011-11-24 05:18:26 +00:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_OPENJPEG
|
2019-04-22 09:39:35 +10:00
|
|
|
else if (STREQ(imtype_arg, "JP2")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_JP2;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2011-11-24 05:18:26 +00:00
|
|
|
#endif
|
2019-04-22 09:39:35 +10:00
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
return R_IMF_IMTYPE_INVALID;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool do_add_image_extension(char *string,
|
|
|
|
const char imtype,
|
|
|
|
const ImageFormatData *im_format)
|
|
|
|
{
|
|
|
|
const char *extension = NULL;
|
|
|
|
const char *extension_test;
|
|
|
|
(void)im_format; /* may be unused, depends on build options */
|
|
|
|
|
|
|
|
if (imtype == R_IMF_IMTYPE_IRIS) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!BLI_path_extension_check(string, extension_test = ".rgb")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
extension = extension_test;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else if (imtype == R_IMF_IMTYPE_IRIZ) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!BLI_path_extension_check(string, extension_test = ".rgb")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
extension = extension_test;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_HDR
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_RADHDR) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!BLI_path_extension_check(string, extension_test = ".hdr")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
extension = extension_test;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (ELEM(imtype,
|
|
|
|
R_IMF_IMTYPE_PNG,
|
|
|
|
R_IMF_IMTYPE_FFMPEG,
|
|
|
|
R_IMF_IMTYPE_H264,
|
|
|
|
R_IMF_IMTYPE_THEORA,
|
|
|
|
R_IMF_IMTYPE_XVID)) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!BLI_path_extension_check(string, extension_test = ".png")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
extension = extension_test;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2007-06-25 19:50:25 +00:00
|
|
|
#ifdef WITH_DDS
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_DDS) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!BLI_path_extension_check(string, extension_test = ".dds")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
extension = extension_test;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2007-06-25 19:50:25 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (ELEM(imtype, R_IMF_IMTYPE_TARGA, R_IMF_IMTYPE_RAWTGA)) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!BLI_path_extension_check(string, extension_test = ".tga")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
extension = extension_test;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else if (imtype == R_IMF_IMTYPE_BMP) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!BLI_path_extension_check(string, extension_test = ".bmp")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
extension = extension_test;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2010-05-21 03:25:38 +00:00
|
|
|
#ifdef WITH_TIFF
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_TIFF) {
|
|
|
|
if (!BLI_path_extension_check_n(string, extension_test = ".tif", ".tiff", NULL)) {
|
|
|
|
extension = extension_test;
|
|
|
|
}
|
|
|
|
}
|
2010-05-21 03:25:38 +00:00
|
|
|
#endif
|
2013-10-11 16:38:04 +00:00
|
|
|
#ifdef WITH_OPENIMAGEIO
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_PSD) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!BLI_path_extension_check(string, extension_test = ".psd")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
extension = extension_test;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2013-10-08 21:17:24 +00:00
|
|
|
#endif
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 00:40:35 +00:00
|
|
|
#ifdef WITH_OPENEXR
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_OPENEXR || imtype == R_IMF_IMTYPE_MULTILAYER) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!BLI_path_extension_check(string, extension_test = ".exr")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
extension = extension_test;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 00:40:35 +00:00
|
|
|
#endif
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_CINEON
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_CINEON) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!BLI_path_extension_check(string, extension_test = ".cin")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
extension = extension_test;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else if (imtype == R_IMF_IMTYPE_DPX) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!BLI_path_extension_check(string, extension_test = ".dpx")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
extension = extension_test;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2009-01-26 08:34:40 +00:00
|
|
|
#ifdef WITH_OPENJPEG
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_JP2) {
|
|
|
|
if (im_format) {
|
|
|
|
if (im_format->jp2_codec == R_IMF_JP2_CODEC_JP2) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!BLI_path_extension_check(string, extension_test = ".jp2")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
extension = extension_test;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else if (im_format->jp2_codec == R_IMF_JP2_CODEC_J2K) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!BLI_path_extension_check(string, extension_test = ".j2c")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
extension = extension_test;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_assert(!"Unsupported jp2 codec was specified in im_format->jp2_codec");
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!BLI_path_extension_check(string, extension_test = ".jp2")) {
|
2019-04-17 06:17:24 +02:00
|
|
|
extension = extension_test;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
2009-01-26 08:34:40 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else { // R_IMF_IMTYPE_AVIRAW, R_IMF_IMTYPE_AVIJPEG, R_IMF_IMTYPE_JPEG90 etc
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!(BLI_path_extension_check_n(string, extension_test = ".jpg", ".jpeg", NULL))) {
|
2019-04-17 06:17:24 +02:00
|
|
|
extension = extension_test;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (extension) {
|
|
|
|
/* prefer this in many cases to avoid .png.tga, but in certain cases it breaks */
|
|
|
|
/* remove any other known image extension */
|
|
|
|
if (BLI_path_extension_check_array(string, imb_ext_image)) {
|
|
|
|
return BLI_path_extension_replace(string, FILE_MAX, extension);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return BLI_path_extension_ensure(string, FILE_MAX, extension);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
int BKE_image_path_ensure_ext_from_imformat(char *string, const ImageFormatData *im_format)
|
2012-12-23 13:57:09 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return do_add_image_extension(string, im_format->imtype, im_format);
|
2012-12-23 13:57:09 +00:00
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
int BKE_image_path_ensure_ext_from_imtype(char *string, const char imtype)
|
2012-12-23 13:57:09 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return do_add_image_extension(string, imtype, NULL);
|
2012-12-23 13:57:09 +00:00
|
|
|
}
|
|
|
|
|
2012-04-24 02:01:23 +00:00
|
|
|
void BKE_imformat_defaults(ImageFormatData *im_format)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
memset(im_format, 0, sizeof(*im_format));
|
|
|
|
im_format->planes = R_IMF_PLANES_RGBA;
|
|
|
|
im_format->imtype = R_IMF_IMTYPE_PNG;
|
|
|
|
im_format->depth = R_IMF_CHAN_DEPTH_8;
|
|
|
|
im_format->quality = 90;
|
|
|
|
im_format->compress = 15;
|
2012-09-18 10:11:46 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_color_managed_display_settings_init(&im_format->display_settings);
|
|
|
|
BKE_color_managed_view_settings_init_default(&im_format->view_settings,
|
|
|
|
&im_format->display_settings);
|
2012-04-24 02:01:23 +00:00
|
|
|
}
|
|
|
|
|
2012-06-22 15:40:49 +00:00
|
|
|
void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *imbuf)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
int ftype = imbuf->ftype;
|
|
|
|
int custom_flags = imbuf->foptions.flag;
|
|
|
|
char quality = imbuf->foptions.quality;
|
2012-08-17 23:29:39 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_imformat_defaults(im_format);
|
2012-06-22 15:40:49 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* file type */
|
2012-06-22 15:40:49 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ftype == IMB_FTYPE_IMAGIC) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_IRIS;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-23 08:36:57 +10:00
|
|
|
#ifdef WITH_HDR
|
2019-04-22 09:39:35 +10:00
|
|
|
else if (ftype == IMB_FTYPE_RADHDR) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_RADHDR;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-23 08:36:57 +10:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (ftype == IMB_FTYPE_PNG) {
|
|
|
|
im_format->imtype = R_IMF_IMTYPE_PNG;
|
2012-06-22 15:40:49 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (custom_flags & PNG_16BIT) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->depth = R_IMF_CHAN_DEPTH_16;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2015-07-13 13:58:17 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->compress = quality;
|
|
|
|
}
|
2012-12-30 13:01:47 +00:00
|
|
|
|
2012-06-22 15:40:49 +00:00
|
|
|
#ifdef WITH_DDS
|
2019-04-22 09:39:35 +10:00
|
|
|
else if (ftype == IMB_FTYPE_DDS) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_DDS;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-23 08:36:57 +10:00
|
|
|
#endif
|
2019-04-22 09:39:35 +10:00
|
|
|
else if (ftype == IMB_FTYPE_BMP) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_BMP;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-23 08:36:57 +10:00
|
|
|
#ifdef WITH_TIFF
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (ftype == IMB_FTYPE_TIF) {
|
|
|
|
im_format->imtype = R_IMF_IMTYPE_TIFF;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (custom_flags & TIF_16BIT) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->depth = R_IMF_CHAN_DEPTH_16;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
if (custom_flags & TIF_COMPRESS_NONE) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->tiff_codec = R_IMF_TIFF_CODEC_NONE;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
if (custom_flags & TIF_COMPRESS_DEFLATE) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->tiff_codec = R_IMF_TIFF_CODEC_DEFLATE;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
if (custom_flags & TIF_COMPRESS_LZW) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->tiff_codec = R_IMF_TIFF_CODEC_LZW;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
if (custom_flags & TIF_COMPRESS_PACKBITS) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->tiff_codec = R_IMF_TIFF_CODEC_PACKBITS;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-06-22 15:40:49 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WITH_OPENEXR
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (ftype == IMB_FTYPE_OPENEXR) {
|
|
|
|
im_format->imtype = R_IMF_IMTYPE_OPENEXR;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (custom_flags & OPENEXR_HALF) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->depth = R_IMF_CHAN_DEPTH_16;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
if (custom_flags & OPENEXR_COMPRESS) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->exr_codec = R_IMF_EXR_CODEC_ZIP; // Can't determine compression
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
if (imbuf->zbuf_float) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->flag |= R_IMF_FLAG_ZBUF;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-06-22 15:40:49 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WITH_CINEON
|
2019-04-22 09:39:35 +10:00
|
|
|
else if (ftype == IMB_FTYPE_CINEON) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_CINEON;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (ftype == IMB_FTYPE_DPX) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_DPX;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-23 08:36:57 +10:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (ftype == IMB_FTYPE_TGA) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (custom_flags & RAWTGA) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_RAWTGA;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->imtype = R_IMF_IMTYPE_TARGA;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-06-22 15:40:49 +00:00
|
|
|
#ifdef WITH_OPENJPEG
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (ftype == IMB_FTYPE_JP2) {
|
|
|
|
im_format->imtype = R_IMF_IMTYPE_JP2;
|
|
|
|
im_format->quality = quality;
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (custom_flags & JP2_16BIT) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->depth = R_IMF_CHAN_DEPTH_16;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (custom_flags & JP2_12BIT) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->depth = R_IMF_CHAN_DEPTH_12;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (custom_flags & JP2_YCC) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->jp2_flag |= R_IMF_JP2_FLAG_YCC;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
if (custom_flags & JP2_CINE) {
|
|
|
|
im_format->jp2_flag |= R_IMF_JP2_FLAG_CINE_PRESET;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (custom_flags & JP2_CINE_48FPS) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->jp2_flag |= R_IMF_JP2_FLAG_CINE_48;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (custom_flags & JP2_JP2) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->jp2_codec = R_IMF_JP2_CODEC_JP2;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (custom_flags & JP2_J2K) {
|
2019-04-17 06:17:24 +02:00
|
|
|
im_format->jp2_codec = R_IMF_JP2_CODEC_J2K;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_assert(!"Unsupported jp2 codec was specified in file type");
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-06-22 15:40:49 +00:00
|
|
|
#endif
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
else {
|
|
|
|
im_format->imtype = R_IMF_IMTYPE_JPEG90;
|
|
|
|
im_format->quality = quality;
|
|
|
|
}
|
2012-06-22 15:40:49 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* planes */
|
|
|
|
im_format->planes = imbuf->planes;
|
2012-06-22 15:40:49 +00:00
|
|
|
}
|
|
|
|
|
2012-12-11 15:14:35 +00:00
|
|
|
#define STAMP_NAME_SIZE ((MAX_ID_NAME - 2) + 16)
|
|
|
|
/* could allow access externally - 512 is for long names,
|
|
|
|
* STAMP_NAME_SIZE is for id names, allowing them some room for description */
|
2017-02-06 17:03:59 +01:00
|
|
|
typedef struct StampDataCustomField {
|
2019-04-17 06:17:24 +02:00
|
|
|
struct StampDataCustomField *next, *prev;
|
|
|
|
/* TODO(sergey): Think of better size here, maybe dynamically allocated even. */
|
|
|
|
char key[512];
|
|
|
|
char *value;
|
|
|
|
/* TODO(sergey): Support non-string values. */
|
2017-02-06 17:03:59 +01:00
|
|
|
} StampDataCustomField;
|
|
|
|
|
2007-10-28 22:27:07 +00:00
|
|
|
typedef struct StampData {
|
2019-04-17 06:17:24 +02:00
|
|
|
char file[512];
|
|
|
|
char note[512];
|
|
|
|
char date[512];
|
|
|
|
char marker[512];
|
|
|
|
char time[512];
|
|
|
|
char frame[512];
|
|
|
|
char frame_range[512];
|
|
|
|
char camera[STAMP_NAME_SIZE];
|
|
|
|
char cameralens[STAMP_NAME_SIZE];
|
|
|
|
char scene[STAMP_NAME_SIZE];
|
|
|
|
char strip[STAMP_NAME_SIZE];
|
|
|
|
char rendertime[STAMP_NAME_SIZE];
|
|
|
|
char memory[STAMP_NAME_SIZE];
|
|
|
|
char hostname[512];
|
|
|
|
|
|
|
|
/* Custom fields are used to put extra meta information header from render
|
|
|
|
* engine to the result image.
|
|
|
|
*
|
|
|
|
* NOTE: This fields are not stamped onto the image. At least for now.
|
|
|
|
*/
|
|
|
|
ListBase custom_fields;
|
2007-10-28 22:27:07 +00:00
|
|
|
} StampData;
|
2012-12-11 15:14:35 +00:00
|
|
|
#undef STAMP_NAME_SIZE
|
2007-10-28 22:27:07 +00:00
|
|
|
|
2018-04-05 16:31:59 +02:00
|
|
|
/**
|
|
|
|
* \param do_prefix: Include a label like "File ", "Date ", etc. in the stamp data strings.
|
|
|
|
* \param use_dynamic: Also include data that can change on a per-frame basis.
|
|
|
|
*/
|
2019-04-17 06:17:24 +02:00
|
|
|
static void stampdata(
|
2020-03-13 17:27:11 +11:00
|
|
|
const Scene *scene, Object *camera, StampData *stamp_data, int do_prefix, bool use_dynamic)
|
2019-04-17 06:17:24 +02:00
|
|
|
{
|
|
|
|
char text[256];
|
|
|
|
struct tm *tl;
|
|
|
|
time_t t;
|
|
|
|
|
|
|
|
if (scene->r.stamp & R_STAMP_FILENAME) {
|
|
|
|
SNPRINTF(stamp_data->file,
|
|
|
|
do_prefix ? "File %s" : "%s",
|
|
|
|
G.relbase_valid ? BKE_main_blendfile_path_from_global() : "<untitled>");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->file[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scene->r.stamp & R_STAMP_NOTE) {
|
|
|
|
/* Never do prefix for Note */
|
|
|
|
SNPRINTF(stamp_data->note, "%s", scene->r.stamp_udata);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->note[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scene->r.stamp & R_STAMP_DATE) {
|
|
|
|
t = time(NULL);
|
|
|
|
tl = localtime(&t);
|
|
|
|
SNPRINTF(text,
|
|
|
|
"%04d/%02d/%02d %02d:%02d:%02d",
|
|
|
|
tl->tm_year + 1900,
|
|
|
|
tl->tm_mon + 1,
|
|
|
|
tl->tm_mday,
|
|
|
|
tl->tm_hour,
|
|
|
|
tl->tm_min,
|
|
|
|
tl->tm_sec);
|
|
|
|
SNPRINTF(stamp_data->date, do_prefix ? "Date %s" : "%s", text);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->date[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_dynamic && scene->r.stamp & R_STAMP_MARKER) {
|
|
|
|
const char *name = BKE_scene_find_last_marker_name(scene, CFRA);
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (name) {
|
2019-04-17 06:17:24 +02:00
|
|
|
STRNCPY(text, name);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
STRNCPY(text, "<none>");
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
SNPRINTF(stamp_data->marker, do_prefix ? "Marker %s" : "%s", text);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->marker[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_dynamic && scene->r.stamp & R_STAMP_TIME) {
|
|
|
|
const short timecode_style = USER_TIMECODE_SMPTE_FULL;
|
|
|
|
BLI_timecode_string_from_time(
|
|
|
|
text, sizeof(text), 0, FRA2TIME(scene->r.cfra), FPS, timecode_style);
|
|
|
|
SNPRINTF(stamp_data->time, do_prefix ? "Timecode %s" : "%s", text);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->time[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_dynamic && scene->r.stamp & R_STAMP_FRAME) {
|
|
|
|
char fmtstr[32];
|
|
|
|
int digits = 1;
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (scene->r.efra > 9) {
|
2019-04-17 06:17:24 +02:00
|
|
|
digits = integer_digits_i(scene->r.efra);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
SNPRINTF(fmtstr, do_prefix ? "Frame %%0%di" : "%%0%di", digits);
|
|
|
|
SNPRINTF(stamp_data->frame, fmtstr, scene->r.cfra);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->frame[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scene->r.stamp & R_STAMP_FRAME_RANGE) {
|
|
|
|
SNPRINTF(stamp_data->frame_range,
|
|
|
|
do_prefix ? "Frame Range %d:%d" : "%d:%d",
|
|
|
|
scene->r.sfra,
|
|
|
|
scene->r.efra);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->frame_range[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_dynamic && scene->r.stamp & R_STAMP_CAMERA) {
|
|
|
|
SNPRINTF(stamp_data->camera,
|
|
|
|
do_prefix ? "Camera %s" : "%s",
|
|
|
|
camera ? camera->id.name + 2 : "<none>");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->camera[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_dynamic && scene->r.stamp & R_STAMP_CAMERALENS) {
|
|
|
|
if (camera && camera->type == OB_CAMERA) {
|
|
|
|
SNPRINTF(text, "%.2f", ((Camera *)camera->data)->lens);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
STRNCPY(text, "<none>");
|
|
|
|
}
|
|
|
|
|
|
|
|
SNPRINTF(stamp_data->cameralens, do_prefix ? "Lens %s" : "%s", text);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->cameralens[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scene->r.stamp & R_STAMP_SCENE) {
|
|
|
|
SNPRINTF(stamp_data->scene, do_prefix ? "Scene %s" : "%s", scene->id.name + 2);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->scene[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_dynamic && scene->r.stamp & R_STAMP_SEQSTRIP) {
|
2020-03-13 17:27:11 +11:00
|
|
|
const Sequence *seq = BKE_sequencer_foreground_frame_get(scene, scene->r.cfra);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (seq) {
|
2019-04-17 06:17:24 +02:00
|
|
|
STRNCPY(text, seq->name + 2);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
STRNCPY(text, "<none>");
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
SNPRINTF(stamp_data->strip, do_prefix ? "Strip %s" : "%s", text);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->strip[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
Render *re = RE_GetSceneRender(scene);
|
|
|
|
RenderStats *stats = re ? RE_GetStats(re) : NULL;
|
|
|
|
|
|
|
|
if (use_dynamic && stats && (scene->r.stamp & R_STAMP_RENDERTIME)) {
|
|
|
|
BLI_timecode_string_from_time_simple(text, sizeof(text), stats->lastframetime);
|
|
|
|
|
|
|
|
SNPRINTF(stamp_data->rendertime, do_prefix ? "RenderTime %s" : "%s", text);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->rendertime[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_dynamic && stats && (scene->r.stamp & R_STAMP_MEMORY)) {
|
|
|
|
SNPRINTF(stamp_data->memory, do_prefix ? "Peak Memory %.2fM" : "%.2fM", stats->mem_peak);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->memory[0] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (scene->r.stamp & R_STAMP_FRAME_RANGE) {
|
|
|
|
SNPRINTF(stamp_data->frame_range,
|
|
|
|
do_prefix ? "Frame Range %d:%d" : "%d:%d",
|
|
|
|
scene->r.sfra,
|
|
|
|
scene->r.efra);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->frame_range[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scene->r.stamp & R_STAMP_HOSTNAME) {
|
|
|
|
char hostname[500]; /* sizeof(stamp_data->hostname) minus some bytes for a label. */
|
|
|
|
BLI_hostname_get(hostname, sizeof(hostname));
|
|
|
|
SNPRINTF(stamp_data->hostname, do_prefix ? "Hostname %s" : "%s", hostname);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->hostname[0] = '\0';
|
|
|
|
}
|
2007-10-28 22:27:07 +00:00
|
|
|
}
|
|
|
|
|
2016-02-01 18:09:15 +01:00
|
|
|
static void stampdata_from_template(StampData *stamp_data,
|
|
|
|
const Scene *scene,
|
2019-09-26 12:05:40 +02:00
|
|
|
const StampData *stamp_data_template,
|
|
|
|
bool do_prefix)
|
2016-02-01 16:09:21 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (scene->r.stamp & R_STAMP_FILENAME) {
|
2019-09-26 12:05:40 +02:00
|
|
|
SNPRINTF(stamp_data->file, do_prefix ? "File %s" : "%s", stamp_data_template->file);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->file[0] = '\0';
|
|
|
|
}
|
|
|
|
if (scene->r.stamp & R_STAMP_NOTE) {
|
|
|
|
SNPRINTF(stamp_data->note, "%s", stamp_data_template->note);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->note[0] = '\0';
|
|
|
|
}
|
|
|
|
if (scene->r.stamp & R_STAMP_DATE) {
|
2019-09-26 12:05:40 +02:00
|
|
|
SNPRINTF(stamp_data->date, do_prefix ? "Date %s" : "%s", stamp_data_template->date);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->date[0] = '\0';
|
|
|
|
}
|
|
|
|
if (scene->r.stamp & R_STAMP_MARKER) {
|
2019-09-26 12:05:40 +02:00
|
|
|
SNPRINTF(stamp_data->marker, do_prefix ? "Marker %s" : "%s", stamp_data_template->marker);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->marker[0] = '\0';
|
|
|
|
}
|
|
|
|
if (scene->r.stamp & R_STAMP_TIME) {
|
2019-09-26 12:05:40 +02:00
|
|
|
SNPRINTF(stamp_data->time, do_prefix ? "Timecode %s" : "%s", stamp_data_template->time);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->time[0] = '\0';
|
|
|
|
}
|
|
|
|
if (scene->r.stamp & R_STAMP_FRAME) {
|
2019-09-26 12:05:40 +02:00
|
|
|
SNPRINTF(stamp_data->frame, do_prefix ? "Frame %s" : "%s", stamp_data_template->frame);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->frame[0] = '\0';
|
|
|
|
}
|
|
|
|
if (scene->r.stamp & R_STAMP_CAMERA) {
|
2019-09-26 12:05:40 +02:00
|
|
|
SNPRINTF(stamp_data->camera, do_prefix ? "Camera %s" : "%s", stamp_data_template->camera);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->camera[0] = '\0';
|
|
|
|
}
|
|
|
|
if (scene->r.stamp & R_STAMP_CAMERALENS) {
|
2019-09-26 12:05:40 +02:00
|
|
|
SNPRINTF(
|
|
|
|
stamp_data->cameralens, do_prefix ? "Lens %s" : "%s", stamp_data_template->cameralens);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->cameralens[0] = '\0';
|
|
|
|
}
|
|
|
|
if (scene->r.stamp & R_STAMP_SCENE) {
|
2019-09-26 12:05:40 +02:00
|
|
|
SNPRINTF(stamp_data->scene, do_prefix ? "Scene %s" : "%s", stamp_data_template->scene);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->scene[0] = '\0';
|
|
|
|
}
|
|
|
|
if (scene->r.stamp & R_STAMP_SEQSTRIP) {
|
2019-09-26 12:05:40 +02:00
|
|
|
SNPRINTF(stamp_data->strip, do_prefix ? "Strip %s" : "%s", stamp_data_template->strip);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->strip[0] = '\0';
|
|
|
|
}
|
|
|
|
if (scene->r.stamp & R_STAMP_RENDERTIME) {
|
2019-09-26 12:05:40 +02:00
|
|
|
SNPRINTF(stamp_data->rendertime,
|
|
|
|
do_prefix ? "RenderTime %s" : "%s",
|
|
|
|
stamp_data_template->rendertime);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->rendertime[0] = '\0';
|
|
|
|
}
|
|
|
|
if (scene->r.stamp & R_STAMP_MEMORY) {
|
2019-09-26 12:05:40 +02:00
|
|
|
SNPRINTF(stamp_data->memory, do_prefix ? "Peak Memory %s" : "%s", stamp_data_template->memory);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->memory[0] = '\0';
|
|
|
|
}
|
|
|
|
if (scene->r.stamp & R_STAMP_HOSTNAME) {
|
2019-09-26 12:05:40 +02:00
|
|
|
SNPRINTF(
|
|
|
|
stamp_data->hostname, do_prefix ? "Hostname %s" : "%s", stamp_data_template->hostname);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data->hostname[0] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_stamp_buf(Scene *scene,
|
|
|
|
Object *camera,
|
|
|
|
const StampData *stamp_data_template,
|
|
|
|
unsigned char *rect,
|
|
|
|
float *rectf,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
int channels)
|
|
|
|
{
|
|
|
|
struct StampData stamp_data;
|
|
|
|
float w, h, pad;
|
|
|
|
int x, y, y_ofs;
|
|
|
|
float h_fixed;
|
|
|
|
const int mono = blf_mono_font_render; // XXX
|
|
|
|
struct ColorManagedDisplay *display;
|
|
|
|
const char *display_device;
|
|
|
|
|
|
|
|
/* vars for calculating wordwrap */
|
|
|
|
struct {
|
|
|
|
struct ResultBLF info;
|
|
|
|
rctf rect;
|
|
|
|
} wrap;
|
|
|
|
|
|
|
|
/* this could be an argument if we want to operate on non linear float imbuf's
|
|
|
|
* for now though this is only used for renders which use scene settings */
|
2012-08-12 22:50:21 +00:00
|
|
|
|
2013-12-02 20:33:45 +11:00
|
|
|
#define TEXT_SIZE_CHECK(str, w, h) \
|
2019-04-17 06:17:24 +02:00
|
|
|
((str[0]) && ((void)(h = h_fixed), (w = BLF_width(mono, str, sizeof(str)))))
|
2013-12-02 20:33:45 +11:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* must enable BLF_WORD_WRAP before using */
|
2015-09-18 20:37:53 +10:00
|
|
|
#define TEXT_SIZE_CHECK_WORD_WRAP(str, w, h) \
|
2019-04-17 06:17:24 +02:00
|
|
|
((str[0]) && (BLF_boundbox_ex(mono, str, sizeof(str), &wrap.rect, &wrap.info), \
|
|
|
|
(void)(h = h_fixed * wrap.info.lines), \
|
|
|
|
(w = BLI_rctf_size_x(&wrap.rect))))
|
2015-09-18 20:37:53 +10:00
|
|
|
|
2011-05-04 15:09:48 +00:00
|
|
|
#define BUFF_MARGIN_X 2
|
|
|
|
#define BUFF_MARGIN_Y 1
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!rect && !rectf) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
display_device = scene->display_settings.display_device;
|
|
|
|
display = IMB_colormanagement_display_get_named(display_device);
|
|
|
|
|
2019-09-26 12:05:40 +02:00
|
|
|
bool do_prefix = (scene->r.stamp & R_STAMP_HIDE_LABELS) == 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
if (stamp_data_template == NULL) {
|
2019-09-26 12:05:40 +02:00
|
|
|
stampdata(scene, camera, &stamp_data, do_prefix, true);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
2019-09-26 12:05:40 +02:00
|
|
|
stampdata_from_template(&stamp_data, scene, stamp_data_template, do_prefix);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO, do_versions */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (scene->r.stamp_font_id < 8) {
|
2019-04-17 06:17:24 +02:00
|
|
|
scene->r.stamp_font_id = 12;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* set before return */
|
|
|
|
BLF_size(mono, scene->r.stamp_font_id, 72);
|
|
|
|
BLF_wordwrap(mono, width - (BUFF_MARGIN_X * 2));
|
|
|
|
|
|
|
|
BLF_buffer(mono, rectf, rect, width, height, channels, display);
|
|
|
|
BLF_buffer_col(mono, scene->r.fg_stamp);
|
|
|
|
pad = BLF_width_max(mono);
|
|
|
|
|
|
|
|
/* use 'h_fixed' rather than 'h', aligns better */
|
|
|
|
h_fixed = BLF_height_max(mono);
|
|
|
|
y_ofs = -BLF_descender(mono);
|
|
|
|
|
|
|
|
x = 0;
|
|
|
|
y = height;
|
|
|
|
|
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.file, w, h)) {
|
|
|
|
/* Top left corner */
|
|
|
|
y -= h;
|
|
|
|
|
|
|
|
/* also a little of space to the background. */
|
|
|
|
buf_rectfill_area(rect,
|
|
|
|
rectf,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
scene->r.bg_stamp,
|
|
|
|
display,
|
|
|
|
x - BUFF_MARGIN_X,
|
|
|
|
y - BUFF_MARGIN_Y,
|
|
|
|
w + BUFF_MARGIN_X,
|
|
|
|
y + h + BUFF_MARGIN_Y);
|
|
|
|
|
|
|
|
/* and draw the text. */
|
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
|
|
|
BLF_draw_buffer(mono, stamp_data.file, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
|
|
|
|
/* the extra pixel for background. */
|
|
|
|
y -= BUFF_MARGIN_Y * 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Top left corner, below File */
|
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.date, w, h)) {
|
|
|
|
y -= h;
|
|
|
|
|
|
|
|
/* and space for background. */
|
|
|
|
buf_rectfill_area(rect,
|
|
|
|
rectf,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
scene->r.bg_stamp,
|
|
|
|
display,
|
|
|
|
0,
|
|
|
|
y - BUFF_MARGIN_Y,
|
|
|
|
w + BUFF_MARGIN_X,
|
|
|
|
y + h + BUFF_MARGIN_Y);
|
|
|
|
|
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
|
|
|
BLF_draw_buffer(mono, stamp_data.date, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
|
|
|
|
/* the extra pixel for background. */
|
|
|
|
y -= BUFF_MARGIN_Y * 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Top left corner, below File, Date */
|
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.rendertime, w, h)) {
|
|
|
|
y -= h;
|
|
|
|
|
|
|
|
/* and space for background. */
|
|
|
|
buf_rectfill_area(rect,
|
|
|
|
rectf,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
scene->r.bg_stamp,
|
|
|
|
display,
|
|
|
|
0,
|
|
|
|
y - BUFF_MARGIN_Y,
|
|
|
|
w + BUFF_MARGIN_X,
|
|
|
|
y + h + BUFF_MARGIN_Y);
|
|
|
|
|
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
|
|
|
BLF_draw_buffer(mono, stamp_data.rendertime, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
|
|
|
|
/* the extra pixel for background. */
|
|
|
|
y -= BUFF_MARGIN_Y * 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Top left corner, below File, Date, Rendertime */
|
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.memory, w, h)) {
|
|
|
|
y -= h;
|
|
|
|
|
|
|
|
/* and space for background. */
|
|
|
|
buf_rectfill_area(rect,
|
|
|
|
rectf,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
scene->r.bg_stamp,
|
|
|
|
display,
|
|
|
|
0,
|
|
|
|
y - BUFF_MARGIN_Y,
|
|
|
|
w + BUFF_MARGIN_X,
|
|
|
|
y + h + BUFF_MARGIN_Y);
|
|
|
|
|
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
|
|
|
BLF_draw_buffer(mono, stamp_data.memory, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
|
|
|
|
/* the extra pixel for background. */
|
|
|
|
y -= BUFF_MARGIN_Y * 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Top left corner, below File, Date, Rendertime, Memory */
|
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.hostname, w, h)) {
|
|
|
|
y -= h;
|
|
|
|
|
|
|
|
/* and space for background. */
|
|
|
|
buf_rectfill_area(rect,
|
|
|
|
rectf,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
scene->r.bg_stamp,
|
|
|
|
display,
|
|
|
|
0,
|
|
|
|
y - BUFF_MARGIN_Y,
|
|
|
|
w + BUFF_MARGIN_X,
|
|
|
|
y + h + BUFF_MARGIN_Y);
|
|
|
|
|
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
|
|
|
BLF_draw_buffer(mono, stamp_data.hostname, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
|
|
|
|
/* the extra pixel for background. */
|
|
|
|
y -= BUFF_MARGIN_Y * 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Top left corner, below File, Date, Memory, Rendertime, Hostname */
|
|
|
|
BLF_enable(mono, BLF_WORD_WRAP);
|
|
|
|
if (TEXT_SIZE_CHECK_WORD_WRAP(stamp_data.note, w, h)) {
|
|
|
|
y -= h;
|
|
|
|
|
|
|
|
/* and space for background. */
|
|
|
|
buf_rectfill_area(rect,
|
|
|
|
rectf,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
scene->r.bg_stamp,
|
|
|
|
display,
|
|
|
|
0,
|
|
|
|
y - BUFF_MARGIN_Y,
|
|
|
|
w + BUFF_MARGIN_X,
|
|
|
|
y + h + BUFF_MARGIN_Y);
|
|
|
|
|
|
|
|
BLF_position(mono, x, y + y_ofs + (h - h_fixed), 0.0);
|
|
|
|
BLF_draw_buffer(mono, stamp_data.note, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
}
|
|
|
|
BLF_disable(mono, BLF_WORD_WRAP);
|
|
|
|
|
|
|
|
x = 0;
|
|
|
|
y = 0;
|
|
|
|
|
|
|
|
/* Bottom left corner, leaving space for timing */
|
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.marker, w, h)) {
|
|
|
|
|
|
|
|
/* extra space for background. */
|
|
|
|
buf_rectfill_area(rect,
|
|
|
|
rectf,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
scene->r.bg_stamp,
|
|
|
|
display,
|
|
|
|
x - BUFF_MARGIN_X,
|
|
|
|
y - BUFF_MARGIN_Y,
|
|
|
|
w + BUFF_MARGIN_X,
|
|
|
|
y + h + BUFF_MARGIN_Y);
|
|
|
|
|
|
|
|
/* and pad the text. */
|
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
|
|
|
BLF_draw_buffer(mono, stamp_data.marker, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
|
|
|
|
/* space width. */
|
|
|
|
x += w + pad;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Left bottom corner */
|
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.time, w, h)) {
|
|
|
|
|
|
|
|
/* extra space for background */
|
|
|
|
buf_rectfill_area(rect,
|
|
|
|
rectf,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
scene->r.bg_stamp,
|
|
|
|
display,
|
|
|
|
x - BUFF_MARGIN_X,
|
|
|
|
y,
|
|
|
|
x + w + BUFF_MARGIN_X,
|
|
|
|
y + h + BUFF_MARGIN_Y);
|
|
|
|
|
|
|
|
/* and pad the text. */
|
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
|
|
|
BLF_draw_buffer(mono, stamp_data.time, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
|
|
|
|
/* space width. */
|
|
|
|
x += w + pad;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.frame, w, h)) {
|
|
|
|
|
|
|
|
/* extra space for background. */
|
|
|
|
buf_rectfill_area(rect,
|
|
|
|
rectf,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
scene->r.bg_stamp,
|
|
|
|
display,
|
|
|
|
x - BUFF_MARGIN_X,
|
|
|
|
y - BUFF_MARGIN_Y,
|
|
|
|
x + w + BUFF_MARGIN_X,
|
|
|
|
y + h + BUFF_MARGIN_Y);
|
|
|
|
|
|
|
|
/* and pad the text. */
|
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
|
|
|
BLF_draw_buffer(mono, stamp_data.frame, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
|
|
|
|
/* space width. */
|
|
|
|
x += w + pad;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.camera, w, h)) {
|
|
|
|
|
|
|
|
/* extra space for background. */
|
|
|
|
buf_rectfill_area(rect,
|
|
|
|
rectf,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
scene->r.bg_stamp,
|
|
|
|
display,
|
|
|
|
x - BUFF_MARGIN_X,
|
|
|
|
y - BUFF_MARGIN_Y,
|
|
|
|
x + w + BUFF_MARGIN_X,
|
|
|
|
y + h + BUFF_MARGIN_Y);
|
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
|
|
|
BLF_draw_buffer(mono, stamp_data.camera, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
|
|
|
|
/* space width. */
|
|
|
|
x += w + pad;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.cameralens, w, h)) {
|
|
|
|
|
|
|
|
/* extra space for background. */
|
|
|
|
buf_rectfill_area(rect,
|
|
|
|
rectf,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
scene->r.bg_stamp,
|
|
|
|
display,
|
|
|
|
x - BUFF_MARGIN_X,
|
|
|
|
y - BUFF_MARGIN_Y,
|
|
|
|
x + w + BUFF_MARGIN_X,
|
|
|
|
y + h + BUFF_MARGIN_Y);
|
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
|
|
|
BLF_draw_buffer(mono, stamp_data.cameralens, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.scene, w, h)) {
|
|
|
|
|
|
|
|
/* Bottom right corner, with an extra space because blenfont is too strict! */
|
|
|
|
x = width - w - 2;
|
|
|
|
|
|
|
|
/* extra space for background. */
|
|
|
|
buf_rectfill_area(rect,
|
|
|
|
rectf,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
scene->r.bg_stamp,
|
|
|
|
display,
|
|
|
|
x - BUFF_MARGIN_X,
|
|
|
|
y - BUFF_MARGIN_Y,
|
|
|
|
x + w + BUFF_MARGIN_X,
|
|
|
|
y + h + BUFF_MARGIN_Y);
|
|
|
|
|
|
|
|
/* and pad the text. */
|
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
|
|
|
BLF_draw_buffer(mono, stamp_data.scene, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TEXT_SIZE_CHECK(stamp_data.strip, w, h)) {
|
|
|
|
|
|
|
|
/* Top right corner, with an extra space because blenfont is too strict! */
|
|
|
|
x = width - w - pad;
|
|
|
|
y = height - h;
|
|
|
|
|
|
|
|
/* extra space for background. */
|
|
|
|
buf_rectfill_area(rect,
|
|
|
|
rectf,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
scene->r.bg_stamp,
|
|
|
|
display,
|
|
|
|
x - BUFF_MARGIN_X,
|
|
|
|
y - BUFF_MARGIN_Y,
|
|
|
|
x + w + BUFF_MARGIN_X,
|
|
|
|
y + h + BUFF_MARGIN_Y);
|
|
|
|
|
|
|
|
BLF_position(mono, x, y + y_ofs, 0.0);
|
|
|
|
BLF_draw_buffer(mono, stamp_data.strip, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup the buffer. */
|
|
|
|
BLF_buffer(mono, NULL, NULL, 0, 0, 0, NULL);
|
|
|
|
BLF_wordwrap(mono, 0);
|
2011-05-04 15:09:48 +00:00
|
|
|
|
2013-12-02 20:33:45 +11:00
|
|
|
#undef TEXT_SIZE_CHECK
|
2015-09-18 20:37:53 +10:00
|
|
|
#undef TEXT_SIZE_CHECK_WORD_WRAP
|
2011-05-04 15:09:48 +00:00
|
|
|
#undef BUFF_MARGIN_X
|
|
|
|
#undef BUFF_MARGIN_Y
|
2007-10-20 16:17:27 +00:00
|
|
|
}
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
void BKE_render_result_stamp_info(Scene *scene,
|
|
|
|
Object *camera,
|
|
|
|
struct RenderResult *rr,
|
|
|
|
bool allocate_only)
|
2007-10-28 22:27:07 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct StampData *stamp_data;
|
2015-04-21 18:33:33 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!(scene && (scene->r.stamp & R_STAMP_ALL)) && !allocate_only) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2015-04-21 18:33:33 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (!rr->stamp_data) {
|
|
|
|
stamp_data = MEM_callocN(sizeof(StampData), "RenderResult.stamp_data");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stamp_data = rr->stamp_data;
|
|
|
|
}
|
2007-10-28 22:27:07 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!allocate_only) {
|
2019-04-17 06:17:24 +02:00
|
|
|
stampdata(scene, camera, stamp_data, 0, true);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (!rr->stamp_data) {
|
|
|
|
rr->stamp_data = stamp_data;
|
|
|
|
}
|
2015-04-21 18:33:33 +02:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2020-03-13 17:27:11 +11:00
|
|
|
struct StampData *BKE_stamp_info_from_scene_static(const Scene *scene)
|
2018-04-05 16:31:59 +02:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct StampData *stamp_data;
|
2018-04-05 16:31:59 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!(scene && (scene->r.stamp & R_STAMP_ALL))) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-04-05 16:31:59 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Memory is allocated here (instead of by the caller) so that the caller
|
|
|
|
* doesn't have to know the size of the StampData struct. */
|
|
|
|
stamp_data = MEM_callocN(sizeof(StampData), __func__);
|
|
|
|
stampdata(scene, NULL, stamp_data, 0, false);
|
2018-04-05 16:31:59 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return stamp_data;
|
2018-04-05 16:31:59 +02:00
|
|
|
}
|
|
|
|
|
2019-02-06 11:49:41 +01:00
|
|
|
static const char *stamp_metadata_fields[] = {
|
2019-04-17 06:17:24 +02:00
|
|
|
"File",
|
|
|
|
"Note",
|
|
|
|
"Date",
|
|
|
|
"Marker",
|
|
|
|
"Time",
|
|
|
|
"Frame",
|
|
|
|
"FrameRange",
|
|
|
|
"Camera",
|
|
|
|
"Lens",
|
|
|
|
"Scene",
|
|
|
|
"Strip",
|
|
|
|
"RenderTime",
|
|
|
|
"Memory",
|
|
|
|
"Hostname",
|
|
|
|
NULL,
|
2019-02-06 11:49:41 +01:00
|
|
|
};
|
|
|
|
|
2019-02-07 10:08:01 +01:00
|
|
|
/* Check whether the given metadata field name translates to a known field of
|
|
|
|
* a stamp. */
|
|
|
|
bool BKE_stamp_is_known_field(const char *field_name)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
int i = 0;
|
|
|
|
while (stamp_metadata_fields[i] != NULL) {
|
|
|
|
if (STREQ(field_name, stamp_metadata_fields[i])) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
return false;
|
2019-02-07 10:08:01 +01:00
|
|
|
}
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
void BKE_stamp_info_callback(void *data,
|
|
|
|
struct StampData *stamp_data,
|
|
|
|
StampCallback callback,
|
|
|
|
bool noskip)
|
2015-04-21 18:33:33 +02:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if ((callback == NULL) || (stamp_data == NULL)) {
|
|
|
|
return;
|
|
|
|
}
|
2015-06-12 14:34:20 +02:00
|
|
|
|
|
|
|
#define CALL(member, value_str) \
|
2019-04-17 06:17:24 +02:00
|
|
|
if (noskip || stamp_data->member[0]) { \
|
|
|
|
callback(data, value_str, stamp_data->member, sizeof(stamp_data->member)); \
|
|
|
|
} \
|
|
|
|
((void)0)
|
|
|
|
|
|
|
|
/* TODO(sergey): Use stamp_metadata_fields somehow, or make it more generic
|
|
|
|
* meta information to avoid duplication. */
|
|
|
|
CALL(file, "File");
|
|
|
|
CALL(note, "Note");
|
|
|
|
CALL(date, "Date");
|
|
|
|
CALL(marker, "Marker");
|
|
|
|
CALL(time, "Time");
|
|
|
|
CALL(frame, "Frame");
|
|
|
|
CALL(frame_range, "FrameRange");
|
|
|
|
CALL(camera, "Camera");
|
|
|
|
CALL(cameralens, "Lens");
|
|
|
|
CALL(scene, "Scene");
|
|
|
|
CALL(strip, "Strip");
|
|
|
|
CALL(rendertime, "RenderTime");
|
|
|
|
CALL(memory, "Memory");
|
|
|
|
CALL(hostname, "Hostname");
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (StampDataCustomField *, custom_field, &stamp_data->custom_fields) {
|
|
|
|
if (noskip || custom_field->value[0]) {
|
|
|
|
callback(data, custom_field->key, custom_field->value, strlen(custom_field->value) + 1);
|
|
|
|
}
|
|
|
|
}
|
2017-02-06 17:03:59 +01:00
|
|
|
|
2015-06-12 14:34:20 +02:00
|
|
|
#undef CALL
|
2007-10-28 22:27:07 +00:00
|
|
|
}
|
|
|
|
|
2017-02-06 17:03:59 +01:00
|
|
|
void BKE_render_result_stamp_data(RenderResult *rr, const char *key, const char *value)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
StampData *stamp_data;
|
|
|
|
if (rr->stamp_data == NULL) {
|
|
|
|
rr->stamp_data = MEM_callocN(sizeof(StampData), "RenderResult.stamp_data");
|
|
|
|
}
|
|
|
|
stamp_data = rr->stamp_data;
|
|
|
|
StampDataCustomField *field = MEM_mallocN(sizeof(StampDataCustomField),
|
|
|
|
"StampData Custom Field");
|
|
|
|
STRNCPY(field->key, key);
|
|
|
|
field->value = BLI_strdup(value);
|
|
|
|
BLI_addtail(&stamp_data->custom_fields, field);
|
2017-02-06 17:03:59 +01:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:51:36 +01:00
|
|
|
StampData *BKE_stamp_data_copy(const StampData *stamp_data)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (stamp_data == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-02-25 19:51:36 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
StampData *stamp_datan = MEM_dupallocN(stamp_data);
|
|
|
|
BLI_duplicatelist(&stamp_datan->custom_fields, &stamp_data->custom_fields);
|
2019-02-25 19:51:36 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
LISTBASE_FOREACH (StampDataCustomField *, custom_fieldn, &stamp_datan->custom_fields) {
|
|
|
|
custom_fieldn->value = MEM_dupallocN(custom_fieldn->value);
|
|
|
|
}
|
2019-02-25 19:51:36 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return stamp_datan;
|
2019-02-25 19:51:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_stamp_data_free(StampData *stamp_data)
|
2017-02-06 16:54:41 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (stamp_data == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
LISTBASE_FOREACH (StampDataCustomField *, custom_field, &stamp_data->custom_fields) {
|
|
|
|
MEM_freeN(custom_field->value);
|
|
|
|
}
|
|
|
|
BLI_freelistN(&stamp_data->custom_fields);
|
|
|
|
MEM_freeN(stamp_data);
|
2017-02-06 16:54:41 +01:00
|
|
|
}
|
|
|
|
|
2015-06-12 14:34:20 +02:00
|
|
|
/* wrap for callback only */
|
2018-04-05 16:27:15 +02:00
|
|
|
static void metadata_set_field(void *data, const char *propname, char *propvalue, int UNUSED(len))
|
2015-05-26 12:02:14 +02:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* We know it is an ImBuf* because that's what we pass to BKE_stamp_info_callback. */
|
|
|
|
struct ImBuf *imbuf = data;
|
|
|
|
IMB_metadata_set_field(imbuf->metadata, propname, propvalue);
|
2015-06-12 14:34:20 +02:00
|
|
|
}
|
|
|
|
|
2015-07-01 15:23:09 +02:00
|
|
|
static void metadata_get_field(void *data, const char *propname, char *propvalue, int len)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* We know it is an ImBuf* because that's what we pass to BKE_stamp_info_callback. */
|
|
|
|
struct ImBuf *imbuf = data;
|
|
|
|
IMB_metadata_get_field(imbuf->metadata, propname, propvalue, len);
|
2015-07-01 15:23:09 +02:00
|
|
|
}
|
|
|
|
|
2015-06-12 14:34:20 +02:00
|
|
|
void BKE_imbuf_stamp_info(RenderResult *rr, struct ImBuf *ibuf)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct StampData *stamp_data = rr->stamp_data;
|
|
|
|
IMB_metadata_ensure(&ibuf->metadata);
|
|
|
|
BKE_stamp_info_callback(ibuf, stamp_data, metadata_set_field, false);
|
2015-05-26 12:02:14 +02:00
|
|
|
}
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
static void metadata_copy_custom_fields(const char *field, const char *value, void *rr_v)
|
2019-02-06 11:49:41 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (BKE_stamp_is_known_field(field)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
RenderResult *rr = (RenderResult *)rr_v;
|
|
|
|
BKE_render_result_stamp_data(rr, field, value);
|
2019-02-06 11:49:41 +01:00
|
|
|
}
|
|
|
|
|
2015-07-01 15:23:09 +02:00
|
|
|
void BKE_stamp_info_from_imbuf(RenderResult *rr, struct ImBuf *ibuf)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (rr->stamp_data == NULL) {
|
|
|
|
rr->stamp_data = MEM_callocN(sizeof(StampData), "RenderResult.stamp_data");
|
|
|
|
}
|
|
|
|
struct StampData *stamp_data = rr->stamp_data;
|
|
|
|
IMB_metadata_ensure(&ibuf->metadata);
|
|
|
|
BKE_stamp_info_callback(ibuf, stamp_data, metadata_get_field, true);
|
|
|
|
/* Copy render engine specific settings. */
|
|
|
|
IMB_metadata_foreach(ibuf, metadata_copy_custom_fields, rr);
|
2015-07-01 15:23:09 +02:00
|
|
|
}
|
2015-05-26 12:02:14 +02:00
|
|
|
|
2014-01-22 02:48:11 +11:00
|
|
|
bool BKE_imbuf_alpha_test(ImBuf *ibuf)
|
2010-11-30 23:38:31 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
int tot;
|
|
|
|
if (ibuf->rect_float) {
|
|
|
|
const float *buf = ibuf->rect_float;
|
|
|
|
for (tot = ibuf->x * ibuf->y; tot--; buf += 4) {
|
|
|
|
if (buf[3] < 1.0f) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ibuf->rect) {
|
|
|
|
unsigned char *buf = (unsigned char *)ibuf->rect;
|
|
|
|
for (tot = ibuf->x * ibuf->y; tot--; buf += 4) {
|
|
|
|
if (buf[3] != 255) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2010-11-30 23:38:31 +00:00
|
|
|
}
|
|
|
|
|
2011-11-24 06:30:37 +00:00
|
|
|
/* note: imf->planes is ignored here, its assumed the image channels
|
|
|
|
* are already set */
|
2016-01-11 12:01:08 +11:00
|
|
|
void BKE_imbuf_write_prepare(ImBuf *ibuf, const ImageFormatData *imf)
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
char imtype = imf->imtype;
|
|
|
|
char compress = imf->compress;
|
|
|
|
char quality = imf->quality;
|
2011-11-21 20:19:58 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* initialize all from image format */
|
|
|
|
ibuf->foptions.flag = 0;
|
2016-01-14 18:51:48 +11:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (imtype == R_IMF_IMTYPE_IRIS) {
|
|
|
|
ibuf->ftype = IMB_FTYPE_IMAGIC;
|
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_HDR
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_RADHDR) {
|
|
|
|
ibuf->ftype = IMB_FTYPE_RADHDR;
|
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (ELEM(imtype,
|
|
|
|
R_IMF_IMTYPE_PNG,
|
|
|
|
R_IMF_IMTYPE_FFMPEG,
|
|
|
|
R_IMF_IMTYPE_H264,
|
|
|
|
R_IMF_IMTYPE_THEORA,
|
|
|
|
R_IMF_IMTYPE_XVID)) {
|
|
|
|
ibuf->ftype = IMB_FTYPE_PNG;
|
|
|
|
|
|
|
|
if (imtype == R_IMF_IMTYPE_PNG) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (imf->depth == R_IMF_CHAN_DEPTH_16) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->foptions.flag |= PNG_16BIT;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
ibuf->foptions.quality = compress;
|
|
|
|
}
|
|
|
|
}
|
2007-06-25 19:50:25 +00:00
|
|
|
#ifdef WITH_DDS
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_DDS) {
|
|
|
|
ibuf->ftype = IMB_FTYPE_DDS;
|
|
|
|
}
|
2007-06-25 19:50:25 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_BMP) {
|
|
|
|
ibuf->ftype = IMB_FTYPE_BMP;
|
|
|
|
}
|
2010-05-21 03:25:38 +00:00
|
|
|
#ifdef WITH_TIFF
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_TIFF) {
|
|
|
|
ibuf->ftype = IMB_FTYPE_TIF;
|
|
|
|
|
|
|
|
if (imf->depth == R_IMF_CHAN_DEPTH_16) {
|
|
|
|
ibuf->foptions.flag |= TIF_16BIT;
|
|
|
|
}
|
|
|
|
if (imf->tiff_codec == R_IMF_TIFF_CODEC_NONE) {
|
|
|
|
ibuf->foptions.flag |= TIF_COMPRESS_NONE;
|
|
|
|
}
|
|
|
|
else if (imf->tiff_codec == R_IMF_TIFF_CODEC_DEFLATE) {
|
|
|
|
ibuf->foptions.flag |= TIF_COMPRESS_DEFLATE;
|
|
|
|
}
|
|
|
|
else if (imf->tiff_codec == R_IMF_TIFF_CODEC_LZW) {
|
|
|
|
ibuf->foptions.flag |= TIF_COMPRESS_LZW;
|
|
|
|
}
|
|
|
|
else if (imf->tiff_codec == R_IMF_TIFF_CODEC_PACKBITS) {
|
|
|
|
ibuf->foptions.flag |= TIF_COMPRESS_PACKBITS;
|
|
|
|
}
|
|
|
|
}
|
2010-05-21 03:25:38 +00:00
|
|
|
#endif
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
#ifdef WITH_OPENEXR
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
|
|
|
|
ibuf->ftype = IMB_FTYPE_OPENEXR;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (imf->depth == R_IMF_CHAN_DEPTH_16) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->foptions.flag |= OPENEXR_HALF;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->foptions.flag |= (imf->exr_codec & OPENEXR_COMPRESS);
|
|
|
|
|
|
|
|
if (!(imf->flag & R_IMF_FLAG_ZBUF)) {
|
|
|
|
/* Signal for exr saving. */
|
|
|
|
IMB_freezbuffloatImBuf(ibuf);
|
|
|
|
}
|
|
|
|
}
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
#endif
|
2010-08-03 11:25:34 +00:00
|
|
|
#ifdef WITH_CINEON
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_CINEON) {
|
|
|
|
ibuf->ftype = IMB_FTYPE_CINEON;
|
|
|
|
if (imf->cineon_flag & R_IMF_CINEON_FLAG_LOG) {
|
|
|
|
ibuf->foptions.flag |= CINEON_LOG;
|
|
|
|
}
|
|
|
|
if (imf->depth == R_IMF_CHAN_DEPTH_16) {
|
|
|
|
ibuf->foptions.flag |= CINEON_16BIT;
|
|
|
|
}
|
|
|
|
else if (imf->depth == R_IMF_CHAN_DEPTH_12) {
|
|
|
|
ibuf->foptions.flag |= CINEON_12BIT;
|
|
|
|
}
|
|
|
|
else if (imf->depth == R_IMF_CHAN_DEPTH_10) {
|
|
|
|
ibuf->foptions.flag |= CINEON_10BIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (imtype == R_IMF_IMTYPE_DPX) {
|
|
|
|
ibuf->ftype = IMB_FTYPE_DPX;
|
|
|
|
if (imf->cineon_flag & R_IMF_CINEON_FLAG_LOG) {
|
|
|
|
ibuf->foptions.flag |= CINEON_LOG;
|
|
|
|
}
|
|
|
|
if (imf->depth == R_IMF_CHAN_DEPTH_16) {
|
|
|
|
ibuf->foptions.flag |= CINEON_16BIT;
|
|
|
|
}
|
|
|
|
else if (imf->depth == R_IMF_CHAN_DEPTH_12) {
|
|
|
|
ibuf->foptions.flag |= CINEON_12BIT;
|
|
|
|
}
|
|
|
|
else if (imf->depth == R_IMF_CHAN_DEPTH_10) {
|
|
|
|
ibuf->foptions.flag |= CINEON_10BIT;
|
|
|
|
}
|
|
|
|
}
|
2010-08-03 11:25:34 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_TARGA) {
|
|
|
|
ibuf->ftype = IMB_FTYPE_TGA;
|
|
|
|
}
|
|
|
|
else if (imtype == R_IMF_IMTYPE_RAWTGA) {
|
|
|
|
ibuf->ftype = IMB_FTYPE_TGA;
|
|
|
|
ibuf->foptions.flag = RAWTGA;
|
|
|
|
}
|
2009-01-26 08:34:40 +00:00
|
|
|
#ifdef WITH_OPENJPEG
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (imtype == R_IMF_IMTYPE_JP2) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (quality < 10) {
|
2019-04-17 06:17:24 +02:00
|
|
|
quality = 90;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->ftype = IMB_FTYPE_JP2;
|
|
|
|
ibuf->foptions.quality = quality;
|
|
|
|
|
|
|
|
if (imf->depth == R_IMF_CHAN_DEPTH_16) {
|
|
|
|
ibuf->foptions.flag |= JP2_16BIT;
|
|
|
|
}
|
|
|
|
else if (imf->depth == R_IMF_CHAN_DEPTH_12) {
|
|
|
|
ibuf->foptions.flag |= JP2_12BIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (imf->jp2_flag & R_IMF_JP2_FLAG_YCC) {
|
|
|
|
ibuf->foptions.flag |= JP2_YCC;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (imf->jp2_flag & R_IMF_JP2_FLAG_CINE_PRESET) {
|
|
|
|
ibuf->foptions.flag |= JP2_CINE;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (imf->jp2_flag & R_IMF_JP2_FLAG_CINE_48) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->foptions.flag |= JP2_CINE_48FPS;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (imf->jp2_codec == R_IMF_JP2_CODEC_JP2) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->foptions.flag |= JP2_JP2;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (imf->jp2_codec == R_IMF_JP2_CODEC_J2K) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->foptions.flag |= JP2_J2K;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_assert(!"Unsupported jp2 codec was specified in im_format->jp2_codec");
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-01-26 08:34:40 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else {
|
|
|
|
/* R_IMF_IMTYPE_JPEG90, etc. default we save jpegs */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (quality < 10) {
|
2019-04-17 06:17:24 +02:00
|
|
|
quality = 90;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->ftype = IMB_FTYPE_JPG;
|
|
|
|
ibuf->foptions.quality = quality;
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
2016-01-11 12:01:08 +11:00
|
|
|
int BKE_imbuf_write(ImBuf *ibuf, const char *name, const ImageFormatData *imf)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
int ok;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_imbuf_write_prepare(ibuf, imf);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_make_existing_file(name);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat);
|
|
|
|
if (ok == 0) {
|
|
|
|
perror(name);
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return (ok);
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
|
|
|
|
2014-06-15 12:15:28 +10:00
|
|
|
/* same as BKE_imbuf_write() but crappy workaround not to permanently modify
|
2011-11-24 06:30:37 +00:00
|
|
|
* _some_, values in the imbuf */
|
2019-04-17 06:17:24 +02:00
|
|
|
int BKE_imbuf_write_as(ImBuf *ibuf, const char *name, ImageFormatData *imf, const bool save_copy)
|
2011-11-24 06:30:37 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImBuf ibuf_back = *ibuf;
|
|
|
|
int ok;
|
2011-11-24 06:30:37 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* all data is rgba anyway,
|
|
|
|
* this just controls how to save for some formats */
|
|
|
|
ibuf->planes = imf->planes;
|
2011-11-24 06:30:37 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ok = BKE_imbuf_write(ibuf, name, imf);
|
2011-11-24 06:30:37 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (save_copy) {
|
|
|
|
/* note that we are not restoring _all_ settings */
|
|
|
|
ibuf->planes = ibuf_back.planes;
|
|
|
|
ibuf->ftype = ibuf_back.ftype;
|
|
|
|
ibuf->foptions = ibuf_back.foptions;
|
|
|
|
}
|
2011-11-24 06:30:37 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return ok;
|
2011-11-24 06:30:37 +00:00
|
|
|
}
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
int BKE_imbuf_write_stamp(Scene *scene,
|
|
|
|
struct RenderResult *rr,
|
|
|
|
ImBuf *ibuf,
|
|
|
|
const char *name,
|
|
|
|
const struct ImageFormatData *imf)
|
2011-04-30 05:26:09 +00:00
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (scene && scene->r.stamp & R_STAMP_ALL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_imbuf_stamp_info(rr, ibuf);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2011-04-30 05:26:09 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return BKE_imbuf_write(ibuf, name, imf);
|
2011-04-30 05:26:09 +00:00
|
|
|
}
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
static void do_makepicstring(char *string,
|
|
|
|
const char *base,
|
|
|
|
const char *relbase,
|
|
|
|
int frame,
|
|
|
|
const char imtype,
|
|
|
|
const ImageFormatData *im_format,
|
2019-08-16 04:54:10 +10:00
|
|
|
const bool use_ext,
|
|
|
|
const bool use_frames,
|
2019-04-17 06:17:24 +02:00
|
|
|
const char *suffix)
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (string == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */
|
|
|
|
BLI_path_abs(string, relbase);
|
2010-11-16 14:40:46 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (use_frames) {
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_path_frame(string, frame, 4);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (suffix) {
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_path_suffix(string, FILE_MAX, suffix, "");
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (use_ext) {
|
2019-04-17 06:17:24 +02:00
|
|
|
do_add_image_extension(string, imtype, im_format);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-12-23 13:57:09 +00:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
void BKE_image_path_from_imformat(char *string,
|
|
|
|
const char *base,
|
|
|
|
const char *relbase,
|
|
|
|
int frame,
|
|
|
|
const ImageFormatData *im_format,
|
|
|
|
const bool use_ext,
|
|
|
|
const bool use_frames,
|
|
|
|
const char *suffix)
|
2012-12-23 13:57:09 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
do_makepicstring(
|
|
|
|
string, base, relbase, frame, im_format->imtype, im_format, use_ext, use_frames, suffix);
|
2012-12-23 13:57:09 +00:00
|
|
|
}
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
void BKE_image_path_from_imtype(char *string,
|
|
|
|
const char *base,
|
|
|
|
const char *relbase,
|
|
|
|
int frame,
|
|
|
|
const char imtype,
|
|
|
|
const bool use_ext,
|
|
|
|
const bool use_frames,
|
|
|
|
const char *view)
|
2012-12-23 13:57:09 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
do_makepicstring(string, base, relbase, frame, imtype, NULL, use_ext, use_frames, view);
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
struct anim *openanim_noload(const char *name,
|
|
|
|
int flags,
|
|
|
|
int streamindex,
|
|
|
|
char colorspace[IMA_MAX_SPACE])
|
2015-02-04 18:48:47 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct anim *anim;
|
2015-02-04 18:48:47 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
anim = IMB_open_anim(name, flags, streamindex, colorspace);
|
|
|
|
return anim;
|
2015-02-04 18:48:47 +01:00
|
|
|
}
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* used by sequencer too */
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
struct anim *openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE])
|
2012-05-17 23:21:11 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct anim *anim;
|
|
|
|
struct ImBuf *ibuf;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
anim = IMB_open_anim(name, flags, streamindex, colorspace);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (anim == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
|
|
|
|
if (ibuf == NULL) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (BLI_exists(name)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
printf("not an anim: %s\n", name);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
printf("anim file doesn't exist: %s\n", name);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
IMB_free_anim(anim);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
IMB_freeImBuf(ibuf);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return (anim);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* ************************* New Image API *************** */
|
|
|
|
|
2012-06-23 23:22:19 +00:00
|
|
|
/* Notes about Image storage
|
2012-03-03 20:19:11 +00:00
|
|
|
* - packedfile
|
|
|
|
* -> written in .blend
|
|
|
|
* - filename
|
|
|
|
* -> written in .blend
|
|
|
|
* - movie
|
|
|
|
* -> comes from packedfile or filename
|
|
|
|
* - renderresult
|
|
|
|
* -> comes from packedfile or filename
|
|
|
|
* - listbase
|
|
|
|
* -> ibufs from exrhandle
|
|
|
|
* - flipbook array
|
|
|
|
* -> ibufs come from movie, temporary renderresult or sequence
|
|
|
|
* - ibuf
|
|
|
|
* -> comes from packedfile or filename or generated
|
|
|
|
*/
|
2004-01-26 12:37:34 +00:00
|
|
|
|
2010-01-14 10:59:42 +00:00
|
|
|
/* forces existence of 1 Image for renderout or nodes, returns Image */
|
2006-12-20 17:57:56 +00:00
|
|
|
/* name is only for default, when making new one */
|
2020-03-06 13:02:59 +11:00
|
|
|
Image *BKE_image_ensure_viewer(Main *bmain, int type, const char *name)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Image *ima;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
for (ima = bmain->images.first; ima; ima = ima->id.next) {
|
|
|
|
if (ima->source == IMA_SRC_VIEWER) {
|
|
|
|
if (ima->type == type) {
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ima == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ima = image_alloc(bmain, name, IMA_SRC_VIEWER, type);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* happens on reload, imagewindow cannot be image user when hidden*/
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ima->id.us == 0) {
|
2020-03-11 16:51:53 +01:00
|
|
|
id_us_ensure_real(&ima->id);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return ima;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static void image_viewer_create_views(const RenderData *rd, Image *ima)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if ((rd->scemode & R_MULTIVIEW) == 0) {
|
|
|
|
image_add_view(ima, "", "");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SceneRenderView *srv;
|
|
|
|
for (srv = rd->views.first; srv; srv = srv->next) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (BKE_scene_multiview_is_render_view_active(rd, srv) == false) {
|
2019-04-17 06:17:24 +02:00
|
|
|
continue;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
image_add_view(ima, srv->name, "");
|
|
|
|
}
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset the image cache and views when the Viewer Nodes views don't match the scene views */
|
2020-03-06 13:02:59 +11:00
|
|
|
void BKE_image_ensure_viewer_views(const RenderData *rd, Image *ima, ImageUser *iuser)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bool do_reset;
|
|
|
|
const bool is_multiview = (rd->scemode & R_MULTIVIEW) != 0;
|
|
|
|
|
|
|
|
BLI_thread_lock(LOCK_DRAW_IMAGE);
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!BKE_scene_multiview_is_stereo3d(rd)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
iuser->flag &= ~IMA_SHOW_STEREO;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* see if all scene render views are in the image view list */
|
|
|
|
do_reset = (BKE_scene_multiview_num_views_get(rd) != BLI_listbase_count(&ima->views));
|
|
|
|
|
|
|
|
/* multiview also needs to be sure all the views are synced */
|
|
|
|
if (is_multiview && !do_reset) {
|
|
|
|
SceneRenderView *srv;
|
|
|
|
ImageView *iv;
|
|
|
|
|
|
|
|
for (iv = ima->views.first; iv; iv = iv->next) {
|
|
|
|
srv = BLI_findstring(&rd->views, iv->name, offsetof(SceneRenderView, name));
|
|
|
|
if ((srv == NULL) || (BKE_scene_multiview_is_render_view_active(rd, srv) == false)) {
|
|
|
|
do_reset = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (do_reset) {
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_lock(image_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
image_free_cached_frames(ima);
|
|
|
|
BKE_image_free_views(ima);
|
|
|
|
|
|
|
|
/* add new views */
|
|
|
|
image_viewer_create_views(rd, ima);
|
|
|
|
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_unlock(image_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BLI_thread_unlock(LOCK_DRAW_IMAGE);
|
|
|
|
}
|
|
|
|
|
2019-06-26 19:34:35 +02:00
|
|
|
static void image_walk_ntree_all_users(
|
|
|
|
bNodeTree *ntree,
|
|
|
|
ID *id,
|
|
|
|
void *customdata,
|
|
|
|
void callback(Image *ima, ID *iuser_id, ImageUser *iuser, void *customdata))
|
2019-04-17 06:17:24 +02:00
|
|
|
{
|
|
|
|
switch (ntree->type) {
|
|
|
|
case NTREE_SHADER:
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if (node->id) {
|
|
|
|
if (node->type == SH_NODE_TEX_IMAGE) {
|
|
|
|
NodeTexImage *tex = node->storage;
|
|
|
|
Image *ima = (Image *)node->id;
|
2019-06-26 19:34:35 +02:00
|
|
|
callback(ima, id, &tex->iuser, customdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
if (node->type == SH_NODE_TEX_ENVIRONMENT) {
|
|
|
|
NodeTexImage *tex = node->storage;
|
|
|
|
Image *ima = (Image *)node->id;
|
2019-06-26 19:34:35 +02:00
|
|
|
callback(ima, id, &tex->iuser, customdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NTREE_TEXTURE:
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if (node->id && node->type == TEX_NODE_IMAGE) {
|
|
|
|
Image *ima = (Image *)node->id;
|
|
|
|
ImageUser *iuser = node->storage;
|
2019-06-26 19:34:35 +02:00
|
|
|
callback(ima, id, iuser, customdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NTREE_COMPOSIT:
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if (node->id && node->type == CMP_NODE_IMAGE) {
|
|
|
|
Image *ima = (Image *)node->id;
|
|
|
|
ImageUser *iuser = node->storage;
|
2019-06-26 19:34:35 +02:00
|
|
|
callback(ima, id, iuser, customdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-26 19:34:35 +02:00
|
|
|
static void image_walk_id_all_users(
|
|
|
|
ID *id,
|
|
|
|
bool skip_nested_nodes,
|
|
|
|
void *customdata,
|
|
|
|
void callback(Image *ima, ID *iuser_id, ImageUser *iuser, void *customdata))
|
2019-02-18 16:19:15 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
switch (GS(id->name)) {
|
|
|
|
case ID_OB: {
|
|
|
|
Object *ob = (Object *)id;
|
|
|
|
if (ob->empty_drawtype == OB_EMPTY_IMAGE && ob->data) {
|
2019-06-26 19:34:35 +02:00
|
|
|
callback(ob->data, &ob->id, ob->iuser, customdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ID_MA: {
|
|
|
|
Material *ma = (Material *)id;
|
|
|
|
if (ma->nodetree && ma->use_nodes && !skip_nested_nodes) {
|
2019-06-26 19:34:35 +02:00
|
|
|
image_walk_ntree_all_users(ma->nodetree, &ma->id, customdata, callback);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ID_LA: {
|
|
|
|
Light *light = (Light *)id;
|
|
|
|
if (light->nodetree && light->use_nodes && !skip_nested_nodes) {
|
2019-06-26 19:34:35 +02:00
|
|
|
image_walk_ntree_all_users(light->nodetree, &light->id, customdata, callback);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ID_WO: {
|
|
|
|
World *world = (World *)id;
|
|
|
|
if (world->nodetree && world->use_nodes && !skip_nested_nodes) {
|
2019-06-26 19:34:35 +02:00
|
|
|
image_walk_ntree_all_users(world->nodetree, &world->id, customdata, callback);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ID_TE: {
|
|
|
|
Tex *tex = (Tex *)id;
|
|
|
|
if (tex->type == TEX_IMAGE && tex->ima) {
|
2019-06-26 19:34:35 +02:00
|
|
|
callback(tex->ima, &tex->id, &tex->iuser, customdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
if (tex->nodetree && tex->use_nodes && !skip_nested_nodes) {
|
2019-06-26 19:34:35 +02:00
|
|
|
image_walk_ntree_all_users(tex->nodetree, &tex->id, customdata, callback);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ID_NT: {
|
|
|
|
bNodeTree *ntree = (bNodeTree *)id;
|
2019-06-26 19:34:35 +02:00
|
|
|
image_walk_ntree_all_users(ntree, &ntree->id, customdata, callback);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ID_CA: {
|
|
|
|
Camera *cam = (Camera *)id;
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (CameraBGImage *, bgpic, &cam->bg_images) {
|
2019-06-26 19:34:35 +02:00
|
|
|
callback(bgpic->ima, NULL, &bgpic->iuser, customdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ID_WM: {
|
|
|
|
wmWindowManager *wm = (wmWindowManager *)id;
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
2019-04-17 06:17:24 +02:00
|
|
|
const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
|
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
2020-04-03 13:25:03 +02:00
|
|
|
if (area->spacetype == SPACE_IMAGE) {
|
|
|
|
SpaceImage *sima = area->spacedata.first;
|
2019-06-26 19:34:35 +02:00
|
|
|
callback(sima->image, NULL, &sima->iuser, customdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ID_SCE: {
|
|
|
|
Scene *scene = (Scene *)id;
|
|
|
|
if (scene->nodetree && scene->use_nodes && !skip_nested_nodes) {
|
2019-06-26 19:34:35 +02:00
|
|
|
image_walk_ntree_all_users(scene->nodetree, &scene->id, customdata, callback);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-26 19:34:35 +02:00
|
|
|
void BKE_image_walk_all_users(
|
|
|
|
const Main *mainp,
|
|
|
|
void *customdata,
|
|
|
|
void callback(Image *ima, ID *iuser_id, ImageUser *iuser, void *customdata))
|
2019-02-18 16:19:15 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
for (Scene *scene = mainp->scenes.first; scene; scene = scene->id.next) {
|
|
|
|
image_walk_id_all_users(&scene->id, false, customdata, callback);
|
|
|
|
}
|
2019-02-18 16:19:15 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
for (Object *ob = mainp->objects.first; ob; ob = ob->id.next) {
|
|
|
|
image_walk_id_all_users(&ob->id, false, customdata, callback);
|
|
|
|
}
|
2019-02-18 16:19:15 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
for (bNodeTree *ntree = mainp->nodetrees.first; ntree; ntree = ntree->id.next) {
|
|
|
|
image_walk_id_all_users(&ntree->id, false, customdata, callback);
|
|
|
|
}
|
2019-02-18 16:19:15 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
for (Material *ma = mainp->materials.first; ma; ma = ma->id.next) {
|
|
|
|
image_walk_id_all_users(&ma->id, false, customdata, callback);
|
|
|
|
}
|
2019-03-14 12:40:15 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
for (Light *light = mainp->materials.first; light; light = light->id.next) {
|
|
|
|
image_walk_id_all_users(&light->id, false, customdata, callback);
|
|
|
|
}
|
2019-03-14 12:40:15 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
for (World *world = mainp->materials.first; world; world = world->id.next) {
|
|
|
|
image_walk_id_all_users(&world->id, false, customdata, callback);
|
|
|
|
}
|
2019-02-18 16:19:15 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
for (Tex *tex = mainp->textures.first; tex; tex = tex->id.next) {
|
|
|
|
image_walk_id_all_users(&tex->id, false, customdata, callback);
|
|
|
|
}
|
2019-02-18 16:19:15 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
for (Camera *cam = mainp->cameras.first; cam; cam = cam->id.next) {
|
|
|
|
image_walk_id_all_users(&cam->id, false, customdata, callback);
|
|
|
|
}
|
2019-02-18 16:19:15 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
for (wmWindowManager *wm = mainp->wm.first; wm; wm = wm->id.next) { /* only 1 wm */
|
|
|
|
image_walk_id_all_users(&wm->id, false, customdata, callback);
|
|
|
|
}
|
2012-06-04 10:41:18 +00:00
|
|
|
}
|
|
|
|
|
2019-06-26 19:34:35 +02:00
|
|
|
static void image_tag_frame_recalc(Image *ima, ID *iuser_id, ImageUser *iuser, void *customdata)
|
2012-06-04 10:41:18 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Image *changed_image = customdata;
|
2012-06-04 10:41:18 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ima == changed_image && BKE_image_is_animated(ima)) {
|
|
|
|
iuser->flag |= IMA_NEED_FRAME_RECALC;
|
|
|
|
iuser->ok = 1;
|
2019-06-26 19:34:35 +02:00
|
|
|
|
|
|
|
if (iuser_id) {
|
|
|
|
/* Must copy image user changes to CoW datablock. */
|
|
|
|
DEG_id_tag_update(iuser_id, ID_RECALC_COPY_ON_WRITE);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-02-18 15:22:02 +01:00
|
|
|
}
|
|
|
|
|
2019-06-26 19:34:35 +02:00
|
|
|
static void image_tag_reload(Image *ima, ID *iuser_id, ImageUser *iuser, void *customdata)
|
2019-02-18 15:22:02 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Image *changed_image = customdata;
|
2019-02-18 15:22:02 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ima == changed_image) {
|
|
|
|
iuser->ok = 1;
|
|
|
|
if (iuser->scene) {
|
|
|
|
image_update_views_format(ima, iuser);
|
|
|
|
}
|
2019-06-26 19:34:35 +02:00
|
|
|
if (iuser_id) {
|
|
|
|
/* Must copy image user changes to CoW datablock. */
|
|
|
|
DEG_id_tag_update(iuser_id, ID_RECALC_COPY_ON_WRITE);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-06-04 10:41:18 +00:00
|
|
|
}
|
|
|
|
|
2016-02-20 22:36:02 +01:00
|
|
|
void BKE_imageuser_default(ImageUser *iuser)
|
|
|
|
{
|
|
|
|
memset(iuser, 0, sizeof(ImageUser));
|
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
|
|
|
iuser->ok = 1;
|
2016-02-20 22:36:02 +01:00
|
|
|
iuser->frames = 100;
|
|
|
|
iuser->sfra = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_init_imageuser(Image *ima, ImageUser *iuser)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
RenderResult *rr = ima->rr;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
iuser->multi_index = 0;
|
|
|
|
iuser->layer = iuser->pass = iuser->view = 0;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (rr) {
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_image_multilayer_index(rr, iuser);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03: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 image_free_tile(Image *ima, ImageTile *tile)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < TEXTARGET_COUNT; i++) {
|
Fix T73133: UDIM texture count in Eevee is limited by OpenGL
Based on @fclem's suggestion in D6421, this commit implements support for
storing all tiles of a UDIM texture in a single 2D array texture on the GPU.
Previously, Eevee was binding one OpenGL texture per tile, quickly running
into hardware limits with nontrivial UDIM texture sets.
Workbench meanwhile had no UDIM support at all, as reusing the per-tile
approach would require splitting the mesh by tile as well as texture.
With this commit, both Workbench as well as Eevee now support huge numbers
of tiles, with the eventual limits being GPU memory and ultimately
GL_MAX_ARRAY_TEXTURE_LAYERS, which tends to be in the 1000s on modern GPUs.
Initially my plan was to have one array texture per unique size, but managing
the different textures and keeping everything consistent ended up being way
too complex.
Therefore, we now use a simpler version that allocates a texture that
is large enough to fit the largest tile and then packs all tiles into as many
layers as necessary.
As a result, each UDIM texture only binds two textures (one for the actual
images, one for metadata) regardless of how many tiles are used.
Note that this rolls back per-tile GPUTextures, meaning that we again have
per-Image GPUTextures like we did before the original UDIM commit,
but now with four instead of two types.
Reviewed By: fclem
Differential Revision: https://developer.blender.org/D6456
2020-01-14 00:33:21 +01:00
|
|
|
/* Only two textures depends on all tiles, so if this is a secondary tile we can keep the other
|
|
|
|
* two. */
|
|
|
|
if (tile != ima->tiles.first &&
|
|
|
|
!(ELEM(i, TEXTARGET_TEXTURE_2D_ARRAY, TEXTARGET_TEXTURE_TILE_MAPPING))) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-03-12 17:21:58 +01:00
|
|
|
for (int eye = 0; eye < 2; eye++) {
|
|
|
|
if (ima->gputexture[i][eye] != NULL) {
|
|
|
|
GPU_texture_free(ima->gputexture[i][eye]);
|
|
|
|
ima->gputexture[i][eye] = NULL;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BKE_image_is_multiview(ima)) {
|
|
|
|
const int totviews = BLI_listbase_count(&ima->views);
|
|
|
|
for (int i = 0; i < totviews; i++) {
|
|
|
|
image_remove_ibuf(ima, i, tile->tile_number);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
image_remove_ibuf(ima, 0, tile->tile_number);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-11 15:40:37 +02:00
|
|
|
void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ima == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_lock(image_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
switch (signal) {
|
|
|
|
case IMA_SIGNAL_FREE:
|
|
|
|
BKE_image_free_buffers(ima);
|
|
|
|
|
|
|
|
if (iuser) {
|
|
|
|
iuser->ok = 1;
|
|
|
|
if (iuser->scene) {
|
|
|
|
image_update_views_format(ima, iuser);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IMA_SIGNAL_SRC_CHANGE:
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ima->type == IMA_TYPE_UV_TEST) {
|
|
|
|
if (ima->source != IMA_SRC_GENERATED) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ima->type = IMA_TYPE_IMAGE;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
if (ima->source == IMA_SRC_GENERATED) {
|
|
|
|
if (ima->gen_x == 0 || ima->gen_y == 0) {
|
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
|
|
|
ImBuf *ibuf = image_get_cached_ibuf_for_index_entry(ima, IMA_NO_INDEX, 0);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf) {
|
|
|
|
ima->gen_x = ibuf->x;
|
|
|
|
ima->gen_y = ibuf->y;
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Changing source type to generated will likely change file format
|
|
|
|
* used by generated image buffer. Saving different file format to
|
|
|
|
* the old name might confuse other applications.
|
|
|
|
*
|
|
|
|
* Here we ensure original image path wouldn't be used when saving
|
|
|
|
* generated image.
|
|
|
|
*/
|
|
|
|
ima->name[0] = '\0';
|
|
|
|
}
|
|
|
|
|
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
|
|
|
if (ima->source != IMA_SRC_TILED) {
|
|
|
|
/* Free all but the first tile. */
|
|
|
|
ImageTile *base_tile = BKE_image_get_tile(ima, 0);
|
2020-02-17 12:33:12 +11:00
|
|
|
BLI_assert(base_tile == ima->tiles.first);
|
|
|
|
for (ImageTile *tile = base_tile->next, *tile_next; tile; tile = tile_next) {
|
|
|
|
tile_next = tile->next;
|
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_free_tile(ima, tile);
|
|
|
|
MEM_freeN(tile);
|
|
|
|
}
|
|
|
|
base_tile->next = NULL;
|
|
|
|
ima->tiles.last = base_tile;
|
|
|
|
}
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* image buffers for non-sequence multilayer will share buffers with RenderResult,
|
|
|
|
* however sequence multilayer will own buffers. Such logic makes switching from
|
|
|
|
* single multilayer file to sequence completely unstable
|
|
|
|
* since changes in nodes seems this workaround isn't needed anymore, all sockets
|
|
|
|
* are nicely detecting anyway, but freeing buffers always here makes multilayer
|
|
|
|
* sequences behave stable
|
|
|
|
*/
|
|
|
|
BKE_image_free_buffers(ima);
|
|
|
|
|
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
|
|
|
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
|
|
|
|
tile->ok = 1;
|
|
|
|
}
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (iuser) {
|
2019-06-26 19:34:35 +02:00
|
|
|
image_tag_frame_recalc(ima, NULL, iuser, ima);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
BKE_image_walk_all_users(bmain, ima, image_tag_frame_recalc);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IMA_SIGNAL_RELOAD:
|
|
|
|
/* try to repack file */
|
|
|
|
if (BKE_image_has_packedfile(ima)) {
|
|
|
|
const int totfiles = image_num_files(ima);
|
|
|
|
|
|
|
|
if (totfiles != BLI_listbase_count_at_most(&ima->packedfiles, totfiles + 1)) {
|
|
|
|
/* in case there are new available files to be loaded */
|
|
|
|
image_free_packedfiles(ima);
|
|
|
|
BKE_image_packfiles(NULL, ima, ID_BLEND_PATH(bmain, &ima->id));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ImagePackedFile *imapf;
|
|
|
|
for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
|
|
|
|
PackedFile *pf;
|
2019-07-07 23:57:35 +10:00
|
|
|
pf = BKE_packedfile_new(NULL, imapf->filepath, ID_BLEND_PATH(bmain, &ima->id));
|
2019-04-17 06:17:24 +02:00
|
|
|
if (pf) {
|
2019-07-07 23:57:35 +10:00
|
|
|
BKE_packedfile_free(imapf->packedfile);
|
2019-04-17 06:17:24 +02:00
|
|
|
imapf->packedfile = pf;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("ERROR: Image \"%s\" not available. Keeping packed image\n", imapf->filepath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (BKE_image_has_packedfile(ima)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_image_free_buffers(ima);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_image_free_buffers(ima);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
if (iuser) {
|
2019-06-26 19:34:35 +02:00
|
|
|
image_tag_reload(ima, NULL, iuser, ima);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
BKE_image_walk_all_users(bmain, ima, image_tag_reload);
|
|
|
|
break;
|
|
|
|
case IMA_SIGNAL_USER_NEW_IMAGE:
|
|
|
|
if (iuser) {
|
|
|
|
iuser->ok = 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
|
|
|
if (ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_SEQUENCE, IMA_SRC_TILED)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ima->type == IMA_TYPE_MULTILAYER) {
|
2016-02-20 22:36:02 +01:00
|
|
|
BKE_image_init_imageuser(ima, iuser);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IMA_SIGNAL_COLORMANAGE:
|
|
|
|
BKE_image_free_buffers(ima);
|
|
|
|
|
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
|
|
|
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
|
|
|
|
tile->ok = 1;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (iuser) {
|
2019-04-17 06:17:24 +02:00
|
|
|
iuser->ok = 1;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_unlock(image_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* don't use notifiers because they are not 100% sure to succeeded
|
|
|
|
* this also makes sure all scenes are accounted for. */
|
|
|
|
{
|
|
|
|
Scene *scene;
|
|
|
|
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
|
|
|
|
if (scene->nodetree) {
|
|
|
|
nodeUpdateID(scene->nodetree, &ima->id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2015-09-09 19:41:46 +05:00
|
|
|
/* return renderpass for a given pass index and active view */
|
|
|
|
/* fallback to available if there are missing passes for active view */
|
2019-04-17 06:17:24 +02:00
|
|
|
static RenderPass *image_render_pass_get(RenderLayer *rl,
|
|
|
|
const int pass,
|
|
|
|
const int view,
|
|
|
|
int *r_passindex)
|
|
|
|
{
|
|
|
|
RenderPass *rpass_ret = NULL;
|
|
|
|
RenderPass *rpass;
|
|
|
|
|
|
|
|
int rp_index = 0;
|
|
|
|
const char *rp_name = "";
|
|
|
|
|
|
|
|
for (rpass = rl->passes.first; rpass; rpass = rpass->next, rp_index++) {
|
|
|
|
if (rp_index == pass) {
|
|
|
|
rpass_ret = rpass;
|
|
|
|
if (view == 0) {
|
|
|
|
/* no multiview or left eye */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rp_name = rpass->name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* multiview */
|
|
|
|
else if (rp_name[0] && STREQ(rpass->name, rp_name) && (rpass->view_id == view)) {
|
|
|
|
rpass_ret = rpass;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fallback to the first pass in the layer */
|
|
|
|
if (rpass_ret == NULL) {
|
|
|
|
rp_index = 0;
|
|
|
|
rpass_ret = rl->passes.first;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (r_passindex) {
|
|
|
|
*r_passindex = (rpass == rpass_ret ? rp_index : pass);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rpass_ret;
|
2015-09-09 19:41:46 +05: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
|
|
|
void BKE_image_get_tile_label(Image *ima, ImageTile *tile, char *label, int len_label)
|
|
|
|
{
|
|
|
|
label[0] = '\0';
|
|
|
|
if (ima == NULL || tile == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tile->label[0]) {
|
|
|
|
BLI_strncpy(label, tile->label, len_label);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_snprintf(label, len_label, "%d", tile->tile_number);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageTile *BKE_image_add_tile(struct Image *ima, int tile_number, const char *label)
|
|
|
|
{
|
|
|
|
if (ima->source != IMA_SRC_TILED) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tile_number < 1001 || tile_number > IMA_UDIM_MAX) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Search the first tile that has a higher number.
|
|
|
|
* We then insert before that to keep the list sorted. */
|
|
|
|
ImageTile *next_tile;
|
|
|
|
for (next_tile = ima->tiles.first; next_tile; next_tile = next_tile->next) {
|
|
|
|
if (next_tile->tile_number == tile_number) {
|
|
|
|
/* Tile already exists. */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (next_tile->tile_number > tile_number) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageTile *tile = MEM_callocN(sizeof(ImageTile), "image new tile");
|
|
|
|
tile->ok = 1;
|
|
|
|
tile->tile_number = tile_number;
|
|
|
|
|
|
|
|
if (next_tile) {
|
|
|
|
BLI_insertlinkbefore(&ima->tiles, next_tile, tile);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_addtail(&ima->tiles, tile);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (label) {
|
|
|
|
BLI_strncpy(tile->label, label, sizeof(tile->label));
|
|
|
|
}
|
|
|
|
|
2020-03-12 17:21:58 +01:00
|
|
|
for (int eye = 0; eye < 2; eye++) {
|
|
|
|
/* Reallocate GPU tile array. */
|
|
|
|
if (ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY][eye] != NULL) {
|
|
|
|
GPU_texture_free(ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY][eye]);
|
|
|
|
ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY][eye] = NULL;
|
|
|
|
}
|
|
|
|
if (ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING][eye] != NULL) {
|
|
|
|
GPU_texture_free(ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING][eye]);
|
|
|
|
ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING][eye] = NULL;
|
|
|
|
}
|
Fix T73133: UDIM texture count in Eevee is limited by OpenGL
Based on @fclem's suggestion in D6421, this commit implements support for
storing all tiles of a UDIM texture in a single 2D array texture on the GPU.
Previously, Eevee was binding one OpenGL texture per tile, quickly running
into hardware limits with nontrivial UDIM texture sets.
Workbench meanwhile had no UDIM support at all, as reusing the per-tile
approach would require splitting the mesh by tile as well as texture.
With this commit, both Workbench as well as Eevee now support huge numbers
of tiles, with the eventual limits being GPU memory and ultimately
GL_MAX_ARRAY_TEXTURE_LAYERS, which tends to be in the 1000s on modern GPUs.
Initially my plan was to have one array texture per unique size, but managing
the different textures and keeping everything consistent ended up being way
too complex.
Therefore, we now use a simpler version that allocates a texture that
is large enough to fit the largest tile and then packs all tiles into as many
layers as necessary.
As a result, each UDIM texture only binds two textures (one for the actual
images, one for metadata) regardless of how many tiles are used.
Note that this rolls back per-tile GPUTextures, meaning that we again have
per-Image GPUTextures like we did before the original UDIM commit,
but now with four instead of two types.
Reviewed By: fclem
Differential Revision: https://developer.blender.org/D6456
2020-01-14 00:33:21 +01: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
|
|
|
return tile;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BKE_image_remove_tile(struct Image *ima, ImageTile *tile)
|
|
|
|
{
|
|
|
|
if (ima == NULL || tile == NULL || ima->source != IMA_SRC_TILED) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tile == ima->tiles.first) {
|
|
|
|
/* Can't remove first tile. */
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
image_free_tile(ima, tile);
|
|
|
|
BLI_remlink(&ima->tiles, tile);
|
|
|
|
MEM_freeN(tile);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BKE_image_fill_tile(struct Image *ima,
|
|
|
|
ImageTile *tile,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
const float color[4],
|
|
|
|
int gen_type,
|
|
|
|
int planes,
|
|
|
|
bool is_float)
|
|
|
|
{
|
|
|
|
if (ima == NULL || tile == NULL || ima->source != IMA_SRC_TILED) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
image_free_tile(ima, tile);
|
|
|
|
|
|
|
|
ImBuf *tile_ibuf = add_ibuf_size(
|
|
|
|
width, height, ima->name, planes, is_float, gen_type, color, &ima->colorspace_settings);
|
|
|
|
|
|
|
|
if (tile_ibuf != NULL) {
|
|
|
|
image_assign_ibuf(ima, tile_ibuf, 0, tile->tile_number);
|
|
|
|
BKE_image_release_ibuf(ima, tile_ibuf, NULL);
|
|
|
|
tile->ok = 1;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* if layer or pass changes, we need an index for the imbufs list */
|
2018-09-24 17:27:41 +02:00
|
|
|
/* note it is called for rendered results, but it doesn't use the index! */
|
2006-12-20 17:57:56 +00:00
|
|
|
/* and because rendered results use fake layer/passes, don't correct for wrong indices here */
|
|
|
|
RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
RenderLayer *rl;
|
|
|
|
RenderPass *rpass = NULL;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (rr == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (iuser) {
|
|
|
|
short index = 0, rv_index, rl_index = 0;
|
|
|
|
bool is_stereo = (iuser->flag & IMA_SHOW_STEREO) && RE_RenderResult_is_stereo(rr);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
rv_index = is_stereo ? iuser->multiview_eye : iuser->view;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (RE_HasCombinedLayer(rr)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
rl_index += 1;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
for (rl = rr->layers.first; rl; rl = rl->next, rl_index++) {
|
|
|
|
if (iuser->layer == rl_index) {
|
|
|
|
int rp_index;
|
|
|
|
rpass = image_render_pass_get(rl, iuser->pass, rv_index, &rp_index);
|
|
|
|
iuser->multi_index = index + rp_index;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
index += BLI_listbase_count(&rl->passes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return rpass;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
void BKE_image_multiview_index(Image *ima, ImageUser *iuser)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (iuser) {
|
|
|
|
bool is_stereo = BKE_image_is_stereo(ima) && (iuser->flag & IMA_SHOW_STEREO);
|
|
|
|
if (is_stereo) {
|
|
|
|
iuser->multi_index = iuser->multiview_eye;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if ((iuser->view < 0) ||
|
|
|
|
(iuser->view >= BLI_listbase_count_at_most(&ima->views, iuser->view + 1))) {
|
|
|
|
iuser->multi_index = iuser->view = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
iuser->multi_index = iuser->view;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* if layer or pass changes, we need an index for the imbufs list */
|
2018-09-24 17:27:41 +02:00
|
|
|
/* note it is called for rendered results, but it doesn't use the index! */
|
2015-04-06 10:40:12 -03:00
|
|
|
/* and because rendered results use fake layer/passes, don't correct for wrong indices here */
|
|
|
|
bool BKE_image_is_multilayer(Image *ima)
|
|
|
|
{
|
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
|
|
|
if (ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_SEQUENCE, IMA_SRC_TILED)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ima->type == IMA_TYPE_MULTILAYER) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ima->source == IMA_SRC_VIEWER) {
|
|
|
|
if (ima->type == IMA_TYPE_R_RESULT) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
2015-10-11 01:14:02 +02:00
|
|
|
bool BKE_image_is_multiview(Image *ima)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImageView *view = ima->views.first;
|
|
|
|
return (view && (view->next || view->name[0]));
|
2015-10-11 01:14:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BKE_image_is_stereo(Image *ima)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return BKE_image_is_multiview(ima) &&
|
|
|
|
(BLI_findstring(&ima->views, STEREO_LEFT_NAME, offsetof(ImageView, name)) &&
|
|
|
|
BLI_findstring(&ima->views, STEREO_RIGHT_NAME, offsetof(ImageView, name)));
|
2015-10-11 01:14:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void image_init_multilayer_multiview(Image *ima, RenderResult *rr)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* update image views from render views, but only if they actually changed,
|
|
|
|
* to avoid invalid memory access during render. ideally these should always
|
|
|
|
* be acquired with a mutex along with the render result, but there are still
|
|
|
|
* some places with just an image pointer that need to access views */
|
|
|
|
if (rr && BLI_listbase_count(&ima->views) == BLI_listbase_count(&rr->views)) {
|
|
|
|
ImageView *iv = ima->views.first;
|
|
|
|
RenderView *rv = rr->views.first;
|
|
|
|
bool modified = false;
|
|
|
|
for (; rv; rv = rv->next, iv = iv->next) {
|
|
|
|
modified |= !STREQ(rv->name, iv->name);
|
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!modified) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BKE_image_free_views(ima);
|
|
|
|
|
|
|
|
if (rr) {
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (RenderView *, rv, &rr->views) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ImageView *iv = MEM_callocN(sizeof(ImageView), "Viewer Image View");
|
|
|
|
STRNCPY(iv->name, rv->name);
|
|
|
|
BLI_addtail(&ima->views, iv);
|
|
|
|
}
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
2010-03-27 15:35:34 +00:00
|
|
|
RenderResult *BKE_image_acquire_renderresult(Scene *scene, Image *ima)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
RenderResult *rr = NULL;
|
|
|
|
if (ima->rr) {
|
|
|
|
rr = ima->rr;
|
|
|
|
}
|
|
|
|
else if (ima->type == IMA_TYPE_R_RESULT) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ima->render_slot == ima->last_render_slot) {
|
2019-04-17 06:17:24 +02:00
|
|
|
rr = RE_AcquireResultRead(RE_GetSceneRender(scene));
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
rr = BKE_image_get_renderslot(ima, ima->render_slot)->render;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* set proper views */
|
|
|
|
image_init_multilayer_multiview(ima, rr);
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return rr;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
2010-03-27 15:35:34 +00:00
|
|
|
void BKE_image_release_renderresult(Scene *scene, Image *ima)
|
2009-09-30 18:18:32 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ima->rr) {
|
|
|
|
/* pass */
|
|
|
|
}
|
|
|
|
else if (ima->type == IMA_TYPE_R_RESULT) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ima->render_slot == ima->last_render_slot) {
|
2019-04-17 06:17:24 +02:00
|
|
|
RE_ReleaseResult(RE_GetSceneRender(scene));
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2010-03-27 15:35:34 +00:00
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
bool BKE_image_is_openexr(struct Image *ima)
|
|
|
|
{
|
|
|
|
#ifdef WITH_OPENEXR
|
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
|
|
|
if (ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_SEQUENCE, IMA_SRC_TILED)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return BLI_path_extension_check(ima->name, ".exr");
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
#else
|
2019-04-17 06:17:24 +02:00
|
|
|
UNUSED_VARS(ima);
|
2015-04-06 10:40:12 -03:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
2015-11-30 00:51:30 +01:00
|
|
|
void BKE_image_backup_render(Scene *scene, Image *ima, bool free_current_slot)
|
2010-03-27 15:35:34 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* called right before rendering, ima->renderslots contains render
|
|
|
|
* result pointers for everything but the current render */
|
|
|
|
Render *re = RE_GetSceneRender(scene);
|
|
|
|
|
|
|
|
/* Ensure we always have a valid render slot. */
|
|
|
|
if (!ima->renderslots.first) {
|
|
|
|
BKE_image_add_renderslot(ima, NULL);
|
|
|
|
ima->render_slot = 0;
|
|
|
|
ima->last_render_slot = 0;
|
|
|
|
}
|
|
|
|
else if (ima->render_slot >= BLI_listbase_count(&ima->renderslots)) {
|
|
|
|
ima->render_slot = 0;
|
|
|
|
ima->last_render_slot = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
RenderSlot *last_slot = BKE_image_get_renderslot(ima, ima->last_render_slot);
|
|
|
|
RenderSlot *cur_slot = BKE_image_get_renderslot(ima, ima->render_slot);
|
|
|
|
|
|
|
|
if (last_slot && ima->render_slot != ima->last_render_slot) {
|
|
|
|
last_slot->render = NULL;
|
|
|
|
RE_SwapResult(re, &last_slot->render);
|
|
|
|
|
|
|
|
if (cur_slot->render) {
|
|
|
|
if (free_current_slot) {
|
|
|
|
BKE_image_clear_renderslot(ima, NULL, ima->render_slot);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
RE_SwapResult(re, &cur_slot->render);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ima->last_render_slot = ima->render_slot;
|
2009-09-30 18:18:32 +00:00
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/**************************** multiview load openexr *********************************/
|
|
|
|
|
|
|
|
static void image_add_view(Image *ima, const char *viewname, const char *filepath)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImageView *iv;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
iv = MEM_mallocN(sizeof(ImageView), "Viewer Image View");
|
|
|
|
STRNCPY(iv->name, viewname);
|
|
|
|
STRNCPY(iv->filepath, filepath);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* For stereo drawing we need to ensure:
|
|
|
|
* STEREO_LEFT_NAME == STEREO_LEFT_ID and
|
|
|
|
* STEREO_RIGHT_NAME == STEREO_RIGHT_ID */
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (STREQ(viewname, STEREO_LEFT_NAME)) {
|
|
|
|
BLI_addhead(&ima->views, iv);
|
|
|
|
}
|
|
|
|
else if (STREQ(viewname, STEREO_RIGHT_NAME)) {
|
|
|
|
ImageView *left_iv = BLI_findstring(&ima->views, STEREO_LEFT_NAME, offsetof(ImageView, name));
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (left_iv == NULL) {
|
|
|
|
BLI_addhead(&ima->views, iv);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_insertlinkafter(&ima->views, left_iv, iv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_addtail(&ima->views, iv);
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* after imbuf load, openexr type can return with a exrhandle open */
|
|
|
|
/* in that case we have to build a render-result */
|
|
|
|
#ifdef WITH_OPENEXR
|
2006-12-20 17:57:56 +00:00
|
|
|
static void image_create_multilayer(Image *ima, ImBuf *ibuf, int framenr)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const char *colorspace = ima->colorspace_settings.name;
|
|
|
|
bool predivide = (ima->alpha_mode == IMA_ALPHA_PREMUL);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* only load rr once for multiview */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!ima->rr) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ima->rr = RE_MultilayerConvert(ibuf->userdata, colorspace, predivide, ibuf->x, ibuf->y);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2006-12-24 16:03:31 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
IMB_exr_close(ibuf->userdata);
|
2006-12-24 16:03:31 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->userdata = NULL;
|
|
|
|
if (ima->rr != NULL) {
|
|
|
|
ima->rr->framenr = framenr;
|
|
|
|
BKE_stamp_info_from_imbuf(ima->rr, ibuf);
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* set proper views */
|
|
|
|
image_init_multilayer_multiview(ima, ima->rr);
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
#endif /* WITH_OPENEXR */
|
2006-12-20 17:57:56 +00:00
|
|
|
|
|
|
|
/* common stuff to do with images after loading */
|
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 image_initialize_after_load(Image *ima, ImageUser *iuser, ImBuf *UNUSED(ibuf))
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Preview is NULL when it has never been used as an icon before.
|
|
|
|
* Never handle previews/icons outside of main thread. */
|
|
|
|
if (G.background == 0 && ima->preview == NULL && BLI_thread_is_main()) {
|
|
|
|
BKE_icon_changed(BKE_icon_id_ensure(&ima->id));
|
|
|
|
}
|
2010-11-05 09:01:00 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* timer */
|
|
|
|
BKE_image_tag_time(ima);
|
2012-06-23 23:22:19 +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
|
|
|
ImageTile *tile = BKE_image_get_tile_from_iuser(ima, iuser);
|
2020-01-14 11:23:12 +01:00
|
|
|
/* Images should never get loaded if the corresponding tile does not exist,
|
|
|
|
* but we should at least not crash if it happens due to a bug elsewhere. */
|
|
|
|
BLI_assert(tile != NULL);
|
|
|
|
if (tile != NULL) {
|
|
|
|
tile->ok = IMA_OK_LOADED;
|
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
2012-12-31 13:52:13 +00:00
|
|
|
static int imbuf_alpha_flags_for_image(Image *ima)
|
|
|
|
{
|
2019-05-18 20:52:20 +02:00
|
|
|
switch (ima->alpha_mode) {
|
|
|
|
case IMA_ALPHA_STRAIGHT:
|
|
|
|
return 0;
|
|
|
|
case IMA_ALPHA_PREMUL:
|
|
|
|
return IB_alphamode_premul;
|
|
|
|
case IMA_ALPHA_CHANNEL_PACKED:
|
|
|
|
return IB_alphamode_channel_packed;
|
|
|
|
case IMA_ALPHA_IGNORE:
|
|
|
|
return IB_alphamode_ignore;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-12-31 13:52:13 +00:00
|
|
|
|
2019-05-18 20:52:20 +02:00
|
|
|
return 0;
|
2012-12-31 13:52:13 +00:00
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* the number of files will vary according to the stereo format */
|
2015-10-24 01:01:10 +11:00
|
|
|
static int image_num_files(Image *ima)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const bool is_multiview = BKE_image_is_multiview(ima);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (!is_multiview) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (ima->views_format == R_IMF_VIEWS_STEREO_3D) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
/* R_IMF_VIEWS_INDIVIDUAL */
|
|
|
|
else {
|
|
|
|
return BLI_listbase_count(&ima->views);
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
static ImBuf *load_sequence_single(
|
|
|
|
Image *ima, ImageUser *iuser, int frame, const int view_id, bool *r_assign)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct ImBuf *ibuf;
|
|
|
|
char name[FILE_MAX];
|
|
|
|
int flag;
|
|
|
|
ImageUser iuser_t = {0};
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ima->lastframe = frame;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (iuser) {
|
|
|
|
iuser_t = *iuser;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* TODO(sergey): Do we need to initialize something here? */
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
iuser_t.view = view_id;
|
|
|
|
BKE_image_user_file_path(&iuser_t, ima, name);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
flag = IB_rect | IB_multilayer | IB_metadata;
|
|
|
|
flag |= imbuf_alpha_flags_for_image(ima);
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* read ibuf */
|
|
|
|
ibuf = IMB_loadiffname(name, flag, ima->colorspace_settings.name);
|
2011-05-01 14:02:40 +00:00
|
|
|
|
|
|
|
#if 0
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf) {
|
|
|
|
printf(AT " loaded %s\n", name);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf(AT " missed %s\n", name);
|
|
|
|
}
|
2011-05-01 14:02:40 +00:00
|
|
|
#endif
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf) {
|
2006-12-24 20:19:56 +00:00
|
|
|
#ifdef WITH_OPENEXR
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf->ftype == IMB_FTYPE_OPENEXR && ibuf->userdata) {
|
|
|
|
/* Handle multilayer and multiview cases, don't assign ibuf here.
|
|
|
|
* will be set layer in BKE_image_acquire_ibuf from ima->rr. */
|
|
|
|
if (IMB_exr_has_multilayer(ibuf->userdata)) {
|
|
|
|
image_create_multilayer(ima, ibuf, frame);
|
|
|
|
ima->type = IMA_TYPE_MULTILAYER;
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
ibuf = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
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_initialize_after_load(ima, iuser, ibuf);
|
2019-04-17 06:17:24 +02:00
|
|
|
*r_assign = true;
|
|
|
|
}
|
2006-12-24 20:19:56 +00:00
|
|
|
#else
|
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_initialize_after_load(ima, iuser, ibuf);
|
2019-04-17 06:17:24 +02:00
|
|
|
*r_assign = true;
|
2006-12-24 20:19:56 +00:00
|
|
|
#endif
|
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
|
|
|
else {
|
|
|
|
ImageTile *tile = BKE_image_get_tile_from_iuser(ima, iuser);
|
|
|
|
if (tile != NULL) {
|
|
|
|
tile->ok = 0;
|
|
|
|
}
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return ibuf;
|
2015-04-06 10:40:12 -03: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 ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int entry, int frame)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct ImBuf *ibuf = NULL;
|
|
|
|
const bool is_multiview = BKE_image_is_multiview(ima);
|
|
|
|
const int totfiles = image_num_files(ima);
|
|
|
|
bool assign = false;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (!is_multiview) {
|
|
|
|
ibuf = load_sequence_single(ima, iuser, frame, 0, &assign);
|
|
|
|
if (assign) {
|
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_assign_ibuf(ima, ibuf, 0, entry);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const int totviews = BLI_listbase_count(&ima->views);
|
|
|
|
int i;
|
|
|
|
struct ImBuf **ibuf_arr;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf_arr = MEM_mallocN(sizeof(ImBuf *) * totviews, "Image Views Imbufs");
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
for (i = 0; i < totfiles; i++) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf_arr[i] = load_sequence_single(ima, iuser, frame, i, &assign);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (BKE_image_is_stereo(ima) && ima->views_format == R_IMF_VIEWS_STEREO_3D) {
|
2019-04-17 06:17:24 +02:00
|
|
|
IMB_ImBufFromStereo3d(ima->stereo3d_format, ibuf_arr[0], &ibuf_arr[0], &ibuf_arr[1]);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* return the original requested ImBuf */
|
|
|
|
ibuf = ibuf_arr[(iuser ? iuser->multi_index : 0)];
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (assign) {
|
|
|
|
for (i = 0; i < totviews; i++) {
|
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_assign_ibuf(ima, ibuf_arr[i], i, entry);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* "remove" the others (decrease their refcount) */
|
|
|
|
for (i = 0; i < totviews; i++) {
|
|
|
|
if (ibuf_arr[i] != ibuf) {
|
|
|
|
IMB_freeImBuf(ibuf_arr[i]);
|
|
|
|
}
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* cleanup */
|
|
|
|
MEM_freeN(ibuf_arr);
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return ibuf;
|
2006-12-20 17:57:56 +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 ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int entry, int frame)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct ImBuf *ibuf = NULL;
|
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
|
|
|
ImageTile *tile = BKE_image_get_tile_from_iuser(ima, iuser);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* either we load from RenderResult, or we have to load a new one */
|
|
|
|
|
|
|
|
/* check for new RenderResult */
|
|
|
|
if (ima->rr == NULL || frame != ima->rr->framenr) {
|
|
|
|
if (ima->rr) {
|
|
|
|
/* Cached image buffers shares pointers with render result,
|
|
|
|
* need to ensure there's no image buffers are hanging around
|
|
|
|
* with dead links after freeing the render result.
|
|
|
|
*/
|
|
|
|
image_free_cached_frames(ima);
|
|
|
|
RE_FreeRenderResult(ima->rr);
|
|
|
|
ima->rr = NULL;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
ibuf = image_load_sequence_file(ima, iuser, entry, frame);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
if (ibuf) { /* actually an error */
|
|
|
|
ima->type = IMA_TYPE_IMAGE;
|
|
|
|
printf("error, multi is normal image\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ima->rr) {
|
|
|
|
RenderPass *rpass = BKE_image_multilayer_index(ima->rr, iuser);
|
|
|
|
|
|
|
|
if (rpass) {
|
|
|
|
// printf("load from pass %s\n", rpass->name);
|
|
|
|
/* since we free render results, we copy the rect */
|
|
|
|
ibuf = IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0);
|
|
|
|
ibuf->rect_float = MEM_dupallocN(rpass->rect);
|
|
|
|
ibuf->flags |= IB_rectfloat;
|
|
|
|
ibuf->mall = IB_rectfloat;
|
|
|
|
ibuf->channels = rpass->channels;
|
|
|
|
|
|
|
|
BKE_imbuf_stamp_info(ima->rr, ibuf);
|
|
|
|
|
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_initialize_after_load(ima, iuser, ibuf);
|
|
|
|
image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : 0, entry);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
// else printf("pass not found\n");
|
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
else {
|
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
|
|
|
tile->ok = 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (iuser) {
|
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
|
|
|
iuser->ok = tile->ok;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
return ibuf;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2015-10-24 01:01:10 +11:00
|
|
|
static ImBuf *load_movie_single(Image *ima, ImageUser *iuser, int frame, const int view_id)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct ImBuf *ibuf = NULL;
|
|
|
|
ImageAnim *ia;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ia = BLI_findlink(&ima->anims, view_id);
|
2012-06-23 23:22:19 +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
|
|
|
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ia->anim == NULL) {
|
|
|
|
char str[FILE_MAX];
|
|
|
|
int flags = IB_rect;
|
|
|
|
ImageUser iuser_t;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ima->flag & IMA_DEINTERLACE) {
|
|
|
|
flags |= IB_animdeinterlace;
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (iuser) {
|
2019-04-17 06:17:24 +02:00
|
|
|
iuser_t = *iuser;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
iuser_t.view = view_id;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_image_user_file_path(&iuser_t, ima, str);
|
2011-10-08 11:11:54 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* FIXME: make several stream accessible in image editor, too*/
|
|
|
|
ia->anim = openanim(str, flags, 0, ima->colorspace_settings.name);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* let's initialize this user */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ia->anim && iuser && iuser->frames == 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
iuser->frames = IMB_anim_get_duration(ia->anim, IMB_TC_RECORD_RUN);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ia->anim) {
|
|
|
|
int dur = IMB_anim_get_duration(ia->anim, IMB_TC_RECORD_RUN);
|
|
|
|
int fra = frame - 1;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (fra < 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
fra = 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
if (fra > (dur - 1)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
fra = dur - 1;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf = IMB_makeSingleUser(IMB_anim_absolute(ia->anim, fra, IMB_TC_RECORD_RUN, IMB_PROXY_NONE));
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf) {
|
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_initialize_after_load(ima, iuser, ibuf);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
else {
|
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
|
|
|
tile->ok = 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
else {
|
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
|
|
|
tile->ok = 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return ibuf;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct ImBuf *ibuf = NULL;
|
|
|
|
const bool is_multiview = BKE_image_is_multiview(ima);
|
|
|
|
const int totfiles = image_num_files(ima);
|
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
|
|
|
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
2019-04-17 06:17:24 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (totfiles != BLI_listbase_count_at_most(&ima->anims, totfiles + 1)) {
|
|
|
|
image_free_anims(ima);
|
|
|
|
|
|
|
|
for (i = 0; i < totfiles; i++) {
|
|
|
|
/* allocate the ImageAnim */
|
|
|
|
ImageAnim *ia = MEM_callocN(sizeof(ImageAnim), "Image Anim");
|
|
|
|
BLI_addtail(&ima->anims, ia);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_multiview) {
|
|
|
|
ibuf = load_movie_single(ima, iuser, frame, 0);
|
|
|
|
image_assign_ibuf(ima, ibuf, 0, frame);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
struct ImBuf **ibuf_arr;
|
|
|
|
const int totviews = BLI_listbase_count(&ima->views);
|
|
|
|
|
|
|
|
ibuf_arr = MEM_mallocN(sizeof(ImBuf *) * totviews, "Image Views (movie) Imbufs");
|
|
|
|
|
|
|
|
for (i = 0; i < totfiles; i++) {
|
|
|
|
ibuf_arr[i] = load_movie_single(ima, iuser, frame, i);
|
|
|
|
}
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (BKE_image_is_stereo(ima) && ima->views_format == R_IMF_VIEWS_STEREO_3D) {
|
2019-04-17 06:17:24 +02:00
|
|
|
IMB_ImBufFromStereo3d(ima->stereo3d_format, ibuf_arr[0], &ibuf_arr[0], &ibuf_arr[1]);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
for (i = 0; i < totviews; i++) {
|
|
|
|
if (ibuf_arr[i]) {
|
|
|
|
image_assign_ibuf(ima, ibuf_arr[i], i, frame);
|
|
|
|
}
|
|
|
|
else {
|
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
|
|
|
tile->ok = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return the original requested ImBuf */
|
|
|
|
ibuf = ibuf_arr[(iuser ? iuser->multi_index : 0)];
|
|
|
|
|
|
|
|
/* "remove" the others (decrease their refcount) */
|
|
|
|
for (i = 0; i < totviews; i++) {
|
|
|
|
if (ibuf_arr[i] != ibuf) {
|
|
|
|
IMB_freeImBuf(ibuf_arr[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
MEM_freeN(ibuf_arr);
|
|
|
|
}
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (iuser) {
|
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
|
|
|
iuser->ok = tile->ok;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
return ibuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ImBuf *load_image_single(Image *ima,
|
|
|
|
ImageUser *iuser,
|
|
|
|
int cfra,
|
|
|
|
const int view_id,
|
|
|
|
const bool has_packed,
|
|
|
|
bool *r_assign)
|
|
|
|
{
|
|
|
|
char filepath[FILE_MAX];
|
|
|
|
struct ImBuf *ibuf = NULL;
|
|
|
|
int flag;
|
|
|
|
|
|
|
|
/* is there a PackedFile with this image ? */
|
|
|
|
if (has_packed) {
|
|
|
|
ImagePackedFile *imapf;
|
|
|
|
|
|
|
|
flag = IB_rect | IB_multilayer;
|
|
|
|
flag |= imbuf_alpha_flags_for_image(ima);
|
|
|
|
|
|
|
|
imapf = BLI_findlink(&ima->packedfiles, view_id);
|
|
|
|
if (imapf->packedfile) {
|
|
|
|
ibuf = IMB_ibImageFromMemory((unsigned char *)imapf->packedfile->data,
|
|
|
|
imapf->packedfile->size,
|
|
|
|
flag,
|
|
|
|
ima->colorspace_settings.name,
|
|
|
|
"<packed data>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ImageUser iuser_t;
|
|
|
|
|
|
|
|
flag = IB_rect | IB_multilayer | IB_metadata;
|
|
|
|
flag |= imbuf_alpha_flags_for_image(ima);
|
|
|
|
|
|
|
|
/* get the correct filepath */
|
2019-06-17 11:39:52 +02:00
|
|
|
BKE_image_user_frame_calc(ima, iuser, cfra);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (iuser) {
|
2019-04-17 06:17:24 +02:00
|
|
|
iuser_t = *iuser;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
iuser_t.framenr = ima->lastframe;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
iuser_t.view = view_id;
|
|
|
|
|
|
|
|
BKE_image_user_file_path(&iuser_t, ima, filepath);
|
|
|
|
|
|
|
|
/* read ibuf */
|
|
|
|
ibuf = IMB_loadiffname(filepath, flag, ima->colorspace_settings.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ibuf) {
|
2015-04-06 10:40:12 -03:00
|
|
|
#ifdef WITH_OPENEXR
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf->ftype == IMB_FTYPE_OPENEXR && ibuf->userdata) {
|
|
|
|
/* Handle multilayer and multiview cases, don't assign ibuf here.
|
|
|
|
* will be set layer in BKE_image_acquire_ibuf from ima->rr. */
|
|
|
|
if (IMB_exr_has_multilayer(ibuf->userdata)) {
|
|
|
|
image_create_multilayer(ima, ibuf, cfra);
|
|
|
|
ima->type = IMA_TYPE_MULTILAYER;
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
ibuf = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2015-06-27 09:52:52 +02:00
|
|
|
#endif
|
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
|
|
|
image_initialize_after_load(ima, iuser, ibuf);
|
2019-04-17 06:17:24 +02:00
|
|
|
*r_assign = true;
|
2006-12-20 17:57:56 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* make packed file for autopack */
|
|
|
|
if ((has_packed == false) && (G.fileflags & G_FILE_AUTOPACK)) {
|
|
|
|
ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image Packefile");
|
|
|
|
BLI_addtail(&ima->packedfiles, imapf);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
STRNCPY(imapf->filepath, filepath);
|
2019-07-07 23:57:35 +10:00
|
|
|
imapf->packedfile = BKE_packedfile_new(
|
|
|
|
NULL, filepath, ID_BLEND_PATH_FROM_GLOBAL(&ima->id));
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
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
|
|
|
ImageTile *tile = BKE_image_get_tile_from_iuser(ima, iuser);
|
|
|
|
tile->ok = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return ibuf;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* warning, 'iuser' can be NULL
|
|
|
|
* note: Image->views was already populated (in image_update_views_format)
|
|
|
|
*/
|
|
|
|
static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct ImBuf *ibuf = NULL;
|
|
|
|
bool assign = false;
|
|
|
|
const bool is_multiview = BKE_image_is_multiview(ima);
|
|
|
|
const int totfiles = image_num_files(ima);
|
|
|
|
bool has_packed = BKE_image_has_packedfile(ima);
|
|
|
|
|
|
|
|
/* always ensure clean ima */
|
|
|
|
BKE_image_free_buffers(ima);
|
|
|
|
|
|
|
|
/* this should never happen, but just playing safe */
|
|
|
|
if (has_packed) {
|
|
|
|
if (totfiles != BLI_listbase_count_at_most(&ima->packedfiles, totfiles + 1)) {
|
|
|
|
image_free_packedfiles(ima);
|
|
|
|
has_packed = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_multiview) {
|
|
|
|
ibuf = load_image_single(ima, iuser, cfra, 0, has_packed, &assign);
|
|
|
|
if (assign) {
|
|
|
|
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
struct ImBuf **ibuf_arr;
|
|
|
|
const int totviews = BLI_listbase_count(&ima->views);
|
|
|
|
int i;
|
|
|
|
BLI_assert(totviews > 0);
|
|
|
|
|
|
|
|
ibuf_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Image Views Imbufs");
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
for (i = 0; i < totfiles; i++) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf_arr[i] = load_image_single(ima, iuser, cfra, i, has_packed, &assign);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* multi-views/multi-layers OpenEXR files directly populate ima, and return NULL ibuf... */
|
|
|
|
if (BKE_image_is_stereo(ima) && ima->views_format == R_IMF_VIEWS_STEREO_3D && ibuf_arr[0] &&
|
|
|
|
totfiles == 1 && totviews >= 2) {
|
|
|
|
IMB_ImBufFromStereo3d(ima->stereo3d_format, ibuf_arr[0], &ibuf_arr[0], &ibuf_arr[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return the original requested ImBuf */
|
|
|
|
i = (iuser && iuser->multi_index < totviews) ? iuser->multi_index : 0;
|
|
|
|
ibuf = ibuf_arr[i];
|
|
|
|
|
|
|
|
if (assign) {
|
|
|
|
for (i = 0; i < totviews; i++) {
|
|
|
|
image_assign_ibuf(ima, ibuf_arr[i], i, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* "remove" the others (decrease their refcount) */
|
|
|
|
for (i = 0; i < totviews; i++) {
|
|
|
|
if (ibuf_arr[i] != ibuf) {
|
|
|
|
IMB_freeImBuf(ibuf_arr[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
MEM_freeN(ibuf_arr);
|
|
|
|
}
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (iuser) {
|
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
|
|
|
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
|
|
|
iuser->ok = tile->ok;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
return ibuf;
|
2006-07-05 17:32:49 +00:00
|
|
|
}
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImBuf *ibuf = NULL;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ima->rr == NULL) {
|
|
|
|
ibuf = image_load_image_file(ima, iuser, 0);
|
|
|
|
if (ibuf) { /* actually an error */
|
|
|
|
ima->type = IMA_TYPE_IMAGE;
|
|
|
|
return ibuf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ima->rr) {
|
|
|
|
RenderPass *rpass = BKE_image_multilayer_index(ima->rr, iuser);
|
2006-12-20 17:57:56 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (rpass) {
|
|
|
|
ibuf = IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0);
|
2012-06-23 23:22:19 +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
|
|
|
image_initialize_after_load(ima, iuser, ibuf);
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->rect_float = rpass->rect;
|
|
|
|
ibuf->flags |= IB_rectfloat;
|
|
|
|
ibuf->channels = rpass->channels;
|
2008-04-28 20:57:03 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_imbuf_stamp_info(ima->rr, ibuf);
|
2019-02-05 14:23:50 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : IMA_NO_INDEX, 0);
|
|
|
|
}
|
|
|
|
}
|
2012-06-23 23:22:19 +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
|
|
|
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ibuf == NULL) {
|
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
|
|
|
tile->ok = 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
if (iuser) {
|
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
|
|
|
iuser->ok = tile->ok;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return ibuf;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* showing RGBA result itself (from compo/sequence) or
|
2012-03-03 20:19:11 +00:00
|
|
|
* like exr, using layers etc */
|
2009-02-05 19:28:28 +00:00
|
|
|
/* always returns a single ibuf, also during render progress */
|
2015-05-08 07:25:39 +10:00
|
|
|
static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_lock)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Render *re;
|
|
|
|
RenderResult rres;
|
|
|
|
RenderView *rv;
|
|
|
|
float *rectf, *rectz;
|
|
|
|
unsigned int *rect;
|
|
|
|
float dither;
|
|
|
|
int channels, layer, pass;
|
|
|
|
ImBuf *ibuf;
|
|
|
|
int from_render = (ima->render_slot == ima->last_render_slot);
|
|
|
|
int actview;
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!(iuser && iuser->scene)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* if we the caller is not going to release the lock, don't give the image */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!r_lock) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
re = RE_GetSceneRender(iuser->scene);
|
|
|
|
|
|
|
|
channels = 4;
|
|
|
|
layer = iuser->layer;
|
|
|
|
pass = iuser->pass;
|
|
|
|
actview = iuser->view;
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (BKE_image_is_stereo(ima) && (iuser->flag & IMA_SHOW_STEREO)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
actview = iuser->multiview_eye;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
RenderSlot *slot;
|
|
|
|
if (from_render) {
|
|
|
|
RE_AcquireResultImage(re, &rres, actview);
|
|
|
|
}
|
|
|
|
else if ((slot = BKE_image_get_renderslot(ima, ima->render_slot))->render) {
|
|
|
|
rres = *(slot->render);
|
|
|
|
rres.have_combined = ((RenderView *)rres.views.first)->rectf != NULL;
|
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
memset(&rres, 0, sizeof(RenderResult));
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
if (!(rres.rectx > 0 && rres.recty > 0)) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (from_render) {
|
2019-04-17 06:17:24 +02:00
|
|
|
RE_ReleaseResultImage(re);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* release is done in BKE_image_release_ibuf using r_lock */
|
|
|
|
if (from_render) {
|
|
|
|
BLI_thread_lock(LOCK_VIEWER);
|
|
|
|
*r_lock = re;
|
|
|
|
rv = NULL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rv = BLI_findlink(&rres.views, actview);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (rv == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
rv = rres.views.first;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* this gives active layer, composite or sequence result */
|
|
|
|
if (rv == NULL) {
|
|
|
|
rect = (unsigned int *)rres.rect32;
|
|
|
|
rectf = rres.rectf;
|
|
|
|
rectz = rres.rectz;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rect = (unsigned int *)rv->rect32;
|
|
|
|
rectf = rv->rectf;
|
|
|
|
rectz = rv->rectz;
|
|
|
|
}
|
|
|
|
|
|
|
|
dither = iuser->scene->r.dither_intensity;
|
|
|
|
|
|
|
|
/* combined layer gets added as first layer */
|
|
|
|
if (rres.have_combined && layer == 0) {
|
|
|
|
/* pass */
|
|
|
|
}
|
|
|
|
else if (rect && layer == 0) {
|
|
|
|
/* rect32 is set when there's a Sequence pass, this pass seems
|
|
|
|
* to have layer=0 (this is from image_buttons.c)
|
|
|
|
* in this case we ignore float buffer, because it could have
|
|
|
|
* hung from previous pass which was float
|
|
|
|
*/
|
|
|
|
rectf = NULL;
|
|
|
|
}
|
|
|
|
else if (rres.layers.first) {
|
|
|
|
RenderLayer *rl = BLI_findlink(&rres.layers, layer - (rres.have_combined ? 1 : 0));
|
|
|
|
if (rl) {
|
|
|
|
RenderPass *rpass = image_render_pass_get(rl, pass, actview, NULL);
|
|
|
|
if (rpass) {
|
|
|
|
rectf = rpass->rect;
|
2019-06-18 12:36:42 +02:00
|
|
|
if (pass != 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
channels = rpass->channels;
|
|
|
|
dither = 0.0f; /* don't dither passes */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
for (rpass = rl->passes.first; rpass; rpass = rpass->next) {
|
|
|
|
if (STREQ(rpass->name, RE_PASSNAME_Z) && rpass->view_id == actview) {
|
2019-04-17 06:17:24 +02:00
|
|
|
rectz = rpass->rect;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
ibuf = image_get_cached_ibuf_for_index_entry(ima, IMA_NO_INDEX, 0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* make ibuf if needed, and initialize it */
|
|
|
|
if (ibuf == NULL) {
|
|
|
|
ibuf = IMB_allocImBuf(rres.rectx, rres.recty, 32, 0);
|
|
|
|
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set color space settings for a byte buffer.
|
|
|
|
*
|
|
|
|
* This is mainly to make it so color management treats byte buffer
|
|
|
|
* from render result with Save Buffers enabled as final display buffer
|
|
|
|
* and doesn't apply any color management on it.
|
|
|
|
*
|
|
|
|
* For other cases we need to be sure it stays to default byte buffer space.
|
|
|
|
*/
|
|
|
|
if (ibuf->rect != rect) {
|
2019-06-18 12:36:42 +02:00
|
|
|
const char *colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_BYTE);
|
|
|
|
IMB_colormanagement_assign_rect_colorspace(ibuf, colorspace);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* invalidate color managed buffers if render result changed */
|
|
|
|
BLI_thread_lock(LOCK_COLORMANAGE);
|
|
|
|
if (ibuf->x != rres.rectx || ibuf->y != rres.recty || ibuf->rect_float != rectf) {
|
|
|
|
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
ibuf->x = rres.rectx;
|
|
|
|
ibuf->y = rres.recty;
|
|
|
|
|
|
|
|
if (rect) {
|
|
|
|
imb_freerectImBuf(ibuf);
|
|
|
|
ibuf->rect = rect;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* byte buffer of render result has been freed, make sure image buffers
|
|
|
|
* does not reference to this buffer anymore
|
|
|
|
* need check for whether byte buffer was allocated and owned by image itself
|
|
|
|
* or if it's reusing buffer from render result
|
|
|
|
*/
|
2019-04-22 09:39:35 +10:00
|
|
|
if ((ibuf->mall & IB_rect) == 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->rect = NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rectf) {
|
|
|
|
ibuf->rect_float = rectf;
|
|
|
|
ibuf->flags |= IB_rectfloat;
|
|
|
|
ibuf->channels = channels;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ibuf->rect_float = NULL;
|
|
|
|
ibuf->flags &= ~IB_rectfloat;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rectz) {
|
|
|
|
ibuf->zbuf_float = rectz;
|
|
|
|
ibuf->flags |= IB_zbuffloat;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ibuf->zbuf_float = NULL;
|
|
|
|
ibuf->flags &= ~IB_zbuffloat;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO(sergey): Make this faster by either simply referencing the stamp
|
|
|
|
* or by changing both ImBug and RenderResult to use same data type to
|
|
|
|
* store metadata. */
|
|
|
|
if (ibuf->metadata != NULL) {
|
|
|
|
IMB_metadata_free(ibuf->metadata);
|
|
|
|
ibuf->metadata = NULL;
|
|
|
|
}
|
|
|
|
BKE_imbuf_stamp_info(&rres, ibuf);
|
|
|
|
|
|
|
|
BLI_thread_unlock(LOCK_COLORMANAGE);
|
|
|
|
|
|
|
|
ibuf->dither = dither;
|
|
|
|
|
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
|
|
|
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
|
|
|
tile->ok = IMA_OK_LOADED;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
return ibuf;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
2015-10-24 01:01:10 +11:00
|
|
|
static int image_get_multiview_index(Image *ima, ImageUser *iuser)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const bool is_multilayer = BKE_image_is_multilayer(ima);
|
|
|
|
const bool is_backdrop = (ima->source == IMA_SRC_VIEWER) && (ima->type == IMA_TYPE_COMPOSITE) &&
|
|
|
|
(iuser == NULL);
|
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
|
|
|
int index = BKE_image_has_multiple_ibufs(ima) ? 0 : IMA_NO_INDEX;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (is_multilayer) {
|
|
|
|
return iuser ? iuser->multi_index : index;
|
|
|
|
}
|
|
|
|
else if (is_backdrop) {
|
|
|
|
if (BKE_image_is_stereo(ima)) {
|
|
|
|
/* backdrop hackaround (since there is no iuser */
|
|
|
|
return ima->eye;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (BKE_image_is_multiview(ima)) {
|
|
|
|
return iuser ? iuser->multi_index : index;
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return index;
|
2015-04-06 10:40:12 -03: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 image_get_entry_and_index(Image *ima, ImageUser *iuser, int *r_entry, int *r_index)
|
2013-01-21 08:49:42 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
int frame = 0, index = image_get_multiview_index(ima, iuser);
|
2013-01-21 08:49:42 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* see if we already have an appropriate ibuf, with image source and type */
|
|
|
|
if (ima->source == IMA_SRC_MOVIE) {
|
|
|
|
frame = iuser ? iuser->framenr : ima->lastframe;
|
|
|
|
}
|
|
|
|
else if (ima->source == IMA_SRC_SEQUENCE) {
|
|
|
|
if (ima->type == IMA_TYPE_IMAGE) {
|
|
|
|
frame = iuser ? iuser->framenr : ima->lastframe;
|
|
|
|
}
|
|
|
|
else if (ima->type == IMA_TYPE_MULTILAYER) {
|
|
|
|
frame = iuser ? iuser->framenr : ima->lastframe;
|
|
|
|
}
|
|
|
|
}
|
2019-12-20 21:46:36 +01:00
|
|
|
else if (ima->source == IMA_SRC_TILED) {
|
|
|
|
frame = (iuser && iuser->tile) ? iuser->tile : 1001;
|
|
|
|
}
|
2013-01-21 08:49:42 +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
|
|
|
*r_entry = frame;
|
2019-04-17 06:17:24 +02:00
|
|
|
*r_index = index;
|
2013-01-21 08:49:42 +00:00
|
|
|
}
|
|
|
|
|
2013-12-13 16:22:08 +06:00
|
|
|
/* Get the ibuf from an image cache for a given image user.
|
|
|
|
*
|
|
|
|
* Returns referenced image buffer if it exists, callee is to
|
|
|
|
* call IMB_freeImBuf to de-reference the image buffer after
|
|
|
|
* it's done handling it.
|
|
|
|
*/
|
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 ImBuf *image_get_cached_ibuf(Image *ima, ImageUser *iuser, int *r_entry, int *r_index)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImBuf *ibuf = NULL;
|
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
|
|
|
int entry = 0, index = image_get_multiview_index(ima, iuser);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* see if we already have an appropriate ibuf, with image source and type */
|
|
|
|
if (ima->source == IMA_SRC_MOVIE) {
|
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
|
|
|
entry = iuser ? iuser->framenr : ima->lastframe;
|
|
|
|
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, entry);
|
|
|
|
ima->lastframe = entry;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else if (ima->source == IMA_SRC_SEQUENCE) {
|
|
|
|
if (ima->type == IMA_TYPE_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
|
|
|
entry = iuser ? iuser->framenr : ima->lastframe;
|
|
|
|
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, entry);
|
|
|
|
ima->lastframe = entry;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* counter the fact that image is set as invalid when loading a frame
|
|
|
|
* that is not in the cache (through image_acquire_ibuf for instance),
|
|
|
|
* yet we have valid frames in the cache loaded */
|
|
|
|
if (ibuf) {
|
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
|
|
|
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
|
|
|
tile->ok = IMA_OK_LOADED;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (iuser) {
|
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
|
|
|
iuser->ok = tile->ok;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ima->type == IMA_TYPE_MULTILAYER) {
|
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
|
|
|
entry = iuser ? iuser->framenr : ima->lastframe;
|
|
|
|
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, entry);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ima->source == IMA_SRC_FILE) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ima->type == IMA_TYPE_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
|
|
|
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, 0);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (ima->type == IMA_TYPE_MULTILAYER) {
|
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
|
|
|
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, 0);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else if (ima->source == 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
|
|
|
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, 0);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else if (ima->source == IMA_SRC_VIEWER) {
|
|
|
|
/* always verify entirely, not that this shouldn't happen
|
|
|
|
* as part of texture sampling in rendering anyway, so not
|
|
|
|
* a big bottleneck */
|
|
|
|
}
|
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
|
|
|
else if (ima->source == IMA_SRC_TILED) {
|
|
|
|
if (ELEM(ima->type, IMA_TYPE_IMAGE, IMA_TYPE_MULTILAYER)) {
|
|
|
|
entry = (iuser && iuser->tile) ? iuser->tile : 1001;
|
|
|
|
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, entry);
|
|
|
|
|
|
|
|
if ((ima->type == IMA_TYPE_IMAGE) && ibuf != NULL) {
|
|
|
|
ImageTile *tile = BKE_image_get_tile(ima, entry);
|
|
|
|
tile->ok = IMA_OK_LOADED;
|
|
|
|
|
|
|
|
/* iuser->ok is useless for tiled images because iuser->tile changes all the time. */
|
|
|
|
if (iuser != NULL) {
|
|
|
|
iuser->ok = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
if (r_entry) {
|
|
|
|
*r_entry = entry;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (r_index) {
|
2019-04-17 06:17:24 +02:00
|
|
|
*r_index = index;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
return ibuf;
|
2008-04-28 20:57:03 +00:00
|
|
|
}
|
|
|
|
|
2014-01-22 02:48:11 +11:00
|
|
|
BLI_INLINE bool image_quick_test(Image *ima, ImageUser *iuser)
|
2013-01-21 11:38:15 +00:00
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ima == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2013-01-21 11:38:15 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (iuser) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (iuser->ok == 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-01-14 11:23:12 +01:00
|
|
|
|
|
|
|
ImageTile *tile = BKE_image_get_tile_from_iuser(ima, iuser);
|
|
|
|
if (tile == NULL) {
|
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
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (tile->ok == 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2013-01-21 11:38:15 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return true;
|
2013-01-21 11:38:15 +00:00
|
|
|
}
|
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
/* Checks optional ImageUser and verifies/creates ImBuf.
|
|
|
|
*
|
|
|
|
* not thread-safe, so callee should worry about thread locks
|
|
|
|
*/
|
2015-05-08 07:25:39 +10:00
|
|
|
static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
|
2008-04-28 20:57:03 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImBuf *ibuf = NULL;
|
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
|
|
|
int entry = 0, index = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (r_lock) {
|
2019-04-17 06:17:24 +02:00
|
|
|
*r_lock = NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* quick reject tests */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!image_quick_test(ima, iuser)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
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
|
|
|
ibuf = image_get_cached_ibuf(ima, iuser, &entry, &index);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
if (ibuf == NULL) {
|
|
|
|
/* we are sure we have to load the ibuf, using source and type */
|
|
|
|
if (ima->source == IMA_SRC_MOVIE) {
|
|
|
|
/* source is from single file, use flipbook to store ibuf */
|
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
|
|
|
ibuf = image_load_movie_file(ima, iuser, entry);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else if (ima->source == IMA_SRC_SEQUENCE) {
|
|
|
|
if (ima->type == IMA_TYPE_IMAGE) {
|
|
|
|
/* regular files, ibufs in flipbook, allows saving */
|
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
|
|
|
ibuf = image_load_sequence_file(ima, iuser, entry, entry);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
/* no else; on load the ima type can change */
|
|
|
|
if (ima->type == IMA_TYPE_MULTILAYER) {
|
|
|
|
/* only 1 layer/pass stored in imbufs, no exrhandle anim storage, no saving */
|
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
|
|
|
ibuf = image_load_sequence_multilayer(ima, iuser, entry, entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ima->source == IMA_SRC_TILED) {
|
|
|
|
if (ima->type == IMA_TYPE_IMAGE) {
|
|
|
|
/* regular files, ibufs in flipbook, allows saving */
|
|
|
|
ibuf = image_load_sequence_file(ima, iuser, entry, 0);
|
|
|
|
}
|
|
|
|
/* no else; on load the ima type can change */
|
|
|
|
if (ima->type == IMA_TYPE_MULTILAYER) {
|
|
|
|
/* only 1 layer/pass stored in imbufs, no exrhandle anim storage, no saving */
|
|
|
|
ibuf = image_load_sequence_multilayer(ima, iuser, entry, 0);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ima->source == IMA_SRC_FILE) {
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ima->type == IMA_TYPE_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
|
|
|
ibuf = image_load_image_file(ima, iuser, entry); /* cfra only for '#', this global is OK */
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
/* no else; on load the ima type can change */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ima->type == IMA_TYPE_MULTILAYER) {
|
2019-04-17 06:17:24 +02:00
|
|
|
/* keeps render result, stores ibufs in listbase, allows saving */
|
|
|
|
ibuf = image_get_ibuf_multilayer(ima, iuser);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else if (ima->source == IMA_SRC_GENERATED) {
|
|
|
|
/* generated is: ibuf is allocated dynamically */
|
|
|
|
/* UV testgrid or black or solid etc */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ima->gen_x == 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ima->gen_x = 1024;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
if (ima->gen_y == 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ima->gen_y = 1024;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
if (ima->gen_depth == 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ima->gen_depth = 24;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf = add_ibuf_size(ima->gen_x,
|
|
|
|
ima->gen_y,
|
|
|
|
ima->name,
|
|
|
|
ima->gen_depth,
|
|
|
|
(ima->gen_flag & IMA_GEN_FLOAT) != 0,
|
|
|
|
ima->gen_type,
|
|
|
|
ima->gen_color,
|
|
|
|
&ima->colorspace_settings);
|
|
|
|
image_assign_ibuf(ima, ibuf, index, 0);
|
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
|
|
|
ImageTile *tile = BKE_image_get_tile(ima, 0);
|
|
|
|
tile->ok = IMA_OK_LOADED;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else if (ima->source == IMA_SRC_VIEWER) {
|
|
|
|
if (ima->type == IMA_TYPE_R_RESULT) {
|
|
|
|
/* always verify entirely, and potentially
|
|
|
|
* returns pointer to release later */
|
|
|
|
ibuf = image_get_render_result(ima, iuser, r_lock);
|
|
|
|
}
|
|
|
|
else if (ima->type == IMA_TYPE_COMPOSITE) {
|
|
|
|
/* requires lock/unlock, otherwise don't return image */
|
|
|
|
if (r_lock) {
|
|
|
|
/* unlock in BKE_image_release_ibuf */
|
|
|
|
BLI_thread_lock(LOCK_VIEWER);
|
|
|
|
*r_lock = ima;
|
|
|
|
|
|
|
|
/* XXX anim play for viewer nodes not yet supported */
|
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
|
|
|
entry = 0; // XXX iuser ? iuser->framenr : 0;
|
|
|
|
ibuf = image_get_cached_ibuf_for_index_entry(ima, index, entry);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
if (!ibuf) {
|
|
|
|
/* Composite Viewer, all handled in compositor */
|
|
|
|
/* fake ibuf, will be filled in compositor */
|
|
|
|
ibuf = IMB_allocImBuf(256, 256, 32, IB_rect | IB_rectfloat);
|
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_assign_ibuf(ima, ibuf, index, entry);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We only want movies and sequences to be memory limited. */
|
|
|
|
if (ibuf != NULL && !ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
|
|
|
|
ibuf->userflags |= IB_PERSISTENT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BKE_image_tag_time(ima);
|
|
|
|
|
|
|
|
return ibuf;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
/* return image buffer for given image and user
|
|
|
|
*
|
|
|
|
* - will lock render result if image type is render result and lock is not NULL
|
|
|
|
* - will return NULL if image type if render or composite result and lock is NULL
|
|
|
|
*
|
|
|
|
* references the result, BKE_image_release_ibuf should be used to de-reference
|
|
|
|
*/
|
2015-05-08 07:25:39 +10:00
|
|
|
ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
|
2009-09-30 18:18:32 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImBuf *ibuf;
|
2012-11-15 15:59:58 +00:00
|
|
|
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_lock(image_mutex);
|
2012-11-15 15:59:58 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf = image_acquire_ibuf(ima, iuser, r_lock);
|
2012-11-15 15:59:58 +00:00
|
|
|
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_unlock(image_mutex);
|
2012-11-15 15:59:58 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return ibuf;
|
2012-11-15 15:59:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (lock != NULL) {
|
|
|
|
/* for getting image during threaded render / compositing, need to release */
|
|
|
|
if (lock == ima) {
|
|
|
|
BLI_thread_unlock(LOCK_VIEWER); /* viewer image */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
RE_ReleaseResultImage(lock); /* render result */
|
|
|
|
BLI_thread_unlock(LOCK_VIEWER); /* view image imbuf */
|
|
|
|
}
|
|
|
|
}
|
2012-11-15 15:59:58 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf) {
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_lock(image_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
IMB_freeImBuf(ibuf);
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_unlock(image_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-09-30 18:18:32 +00:00
|
|
|
}
|
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
/* checks whether there's an image buffer for given image and user */
|
2014-02-03 18:55:59 +11:00
|
|
|
bool BKE_image_has_ibuf(Image *ima, ImageUser *iuser)
|
2009-09-30 18:18:32 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImBuf *ibuf;
|
2012-11-19 17:31:31 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* quick reject tests */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!image_quick_test(ima, iuser)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-11-19 17:31:31 +00:00
|
|
|
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_lock(image_mutex);
|
2012-11-15 15:59:58 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf = image_get_cached_ibuf(ima, iuser, NULL, NULL);
|
2012-11-15 15:59:58 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!ibuf) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf = image_acquire_ibuf(ima, iuser, NULL);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-11-15 15:59:58 +00:00
|
|
|
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_unlock(image_mutex);
|
2012-11-15 15:59:58 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
IMB_freeImBuf(ibuf);
|
2012-11-15 15:59:58 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return ibuf != NULL;
|
2009-09-30 18:18:32 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-01-21 08:49:42 +00:00
|
|
|
/* ******** Pool for image buffers ******** */
|
|
|
|
|
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
|
|
|
typedef struct ImagePoolItem {
|
|
|
|
struct ImagePoolItem *next, *prev;
|
2019-04-17 06:17:24 +02:00
|
|
|
Image *image;
|
|
|
|
ImBuf *ibuf;
|
|
|
|
int index;
|
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
|
|
|
int entry;
|
|
|
|
} ImagePoolItem;
|
2013-01-21 08:49:42 +00:00
|
|
|
|
|
|
|
typedef struct ImagePool {
|
2019-04-17 06:17:24 +02:00
|
|
|
ListBase image_buffers;
|
|
|
|
BLI_mempool *memory_pool;
|
2013-01-21 08:49:42 +00:00
|
|
|
} ImagePool;
|
|
|
|
|
|
|
|
ImagePool *BKE_image_pool_new(void)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImagePool *pool = MEM_callocN(sizeof(ImagePool), "Image Pool");
|
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
|
|
|
pool->memory_pool = BLI_mempool_create(sizeof(ImagePoolItem), 0, 128, BLI_MEMPOOL_NOP);
|
2013-01-21 08:49:42 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return pool;
|
2013-01-21 08:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_pool_free(ImagePool *pool)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Use single lock to dereference all the image buffers. */
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_lock(image_mutex);
|
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
|
|
|
for (ImagePoolItem *item = pool->image_buffers.first; item != NULL; item = item->next) {
|
|
|
|
if (item->ibuf != NULL) {
|
|
|
|
IMB_freeImBuf(item->ibuf);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_unlock(image_mutex);
|
2013-01-21 08:49:42 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_mempool_destroy(pool->memory_pool);
|
|
|
|
MEM_freeN(pool);
|
2013-01-21 08:49:42 +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
|
|
|
BLI_INLINE ImBuf *image_pool_find_item(
|
|
|
|
ImagePool *pool, Image *image, int entry, int index, bool *found)
|
2013-01-21 08:49:42 +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
|
|
|
ImagePoolItem *item;
|
2013-01-21 08:49:42 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
*found = false;
|
2013-01-21 08:49:42 +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
|
|
|
for (item = pool->image_buffers.first; item; item = item->next) {
|
|
|
|
if (item->image == image && item->entry == entry && item->index == index) {
|
2019-04-17 06:17:24 +02:00
|
|
|
*found = true;
|
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
|
|
|
return item->ibuf;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
2013-01-21 08:49:42 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2013-01-21 08:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ImBuf *BKE_image_pool_acquire_ibuf(Image *ima, ImageUser *iuser, ImagePool *pool)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImBuf *ibuf;
|
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
|
|
|
int index, entry;
|
2019-04-17 06:17:24 +02:00
|
|
|
bool found;
|
2013-01-21 08:49:42 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!image_quick_test(ima, iuser)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2013-01-21 11:38:15 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (pool == NULL) {
|
|
|
|
/* pool could be NULL, in this case use general acquire function */
|
|
|
|
return BKE_image_acquire_ibuf(ima, iuser, NULL);
|
|
|
|
}
|
2013-01-21 08:49:42 +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
|
|
|
image_get_entry_and_index(ima, iuser, &entry, &index);
|
2013-01-21 08:49:42 +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
|
|
|
ibuf = image_pool_find_item(pool, ima, entry, index, &found);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (found) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return ibuf;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2013-01-21 08:49:42 +00:00
|
|
|
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_lock(image_mutex);
|
2013-01-21 08:49:42 +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
|
|
|
ibuf = image_pool_find_item(pool, ima, entry, index, &found);
|
2013-01-21 08:49:42 +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
|
|
|
/* will also create item even in cases image buffer failed to load,
|
2019-04-17 06:17:24 +02:00
|
|
|
* prevents trying to load the same buggy file multiple times
|
|
|
|
*/
|
|
|
|
if (!found) {
|
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
|
|
|
ImagePoolItem *item;
|
2013-01-21 08:49:42 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf = image_acquire_ibuf(ima, iuser, NULL);
|
2013-01-21 08:49:42 +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
|
|
|
item = BLI_mempool_alloc(pool->memory_pool);
|
|
|
|
item->image = ima;
|
|
|
|
item->entry = entry;
|
|
|
|
item->index = index;
|
|
|
|
item->ibuf = ibuf;
|
2013-01-21 08:49:42 +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
|
|
|
BLI_addtail(&pool->image_buffers, item);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2013-01-21 08:49:42 +00:00
|
|
|
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_unlock(image_mutex);
|
2013-01-21 08:49:42 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return ibuf;
|
2013-01-21 08:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_image_pool_release_ibuf(Image *ima, ImBuf *ibuf, ImagePool *pool)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* if pool wasn't actually used, use general release stuff,
|
|
|
|
* for pools image buffers will be dereferenced on pool free
|
|
|
|
*/
|
|
|
|
if (pool == NULL) {
|
|
|
|
BKE_image_release_ibuf(ima, ibuf, NULL);
|
|
|
|
}
|
2013-01-21 08:49:42 +00:00
|
|
|
}
|
|
|
|
|
2018-09-10 14:05:33 +10:00
|
|
|
int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, bool *r_is_in_range)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const int len = iuser->frames;
|
|
|
|
|
|
|
|
if (r_is_in_range) {
|
|
|
|
*r_is_in_range = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int framenr;
|
|
|
|
cfra = cfra - iuser->sfra + 1;
|
|
|
|
|
|
|
|
/* cyclic */
|
|
|
|
if (iuser->cycl) {
|
|
|
|
cfra = ((cfra) % len);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (cfra < 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
cfra += len;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
if (cfra == 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
cfra = len;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
if (r_is_in_range) {
|
|
|
|
*r_is_in_range = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cfra < 0) {
|
|
|
|
cfra = 0;
|
|
|
|
}
|
|
|
|
else if (cfra > len) {
|
|
|
|
cfra = len;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (r_is_in_range) {
|
|
|
|
*r_is_in_range = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* transform to images space */
|
|
|
|
framenr = cfra;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (framenr > iuser->frames) {
|
2019-04-17 06:17:24 +02:00
|
|
|
framenr = iuser->frames;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
if (iuser->cycl) {
|
|
|
|
framenr = ((framenr) % len);
|
2019-04-22 09:39:35 +10:00
|
|
|
while (framenr < 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
framenr += len;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
if (framenr == 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
framenr = len;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* important to apply after else we cant loop on frames 100 - 110 for eg. */
|
|
|
|
framenr += iuser->offset;
|
|
|
|
|
|
|
|
return framenr;
|
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2011-05-01 14:02:40 +00:00
|
|
|
|
2019-06-17 11:39:52 +02:00
|
|
|
void BKE_image_user_frame_calc(Image *ima, ImageUser *iuser, int cfra)
|
2011-05-01 14:02:40 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (iuser) {
|
|
|
|
bool is_in_range;
|
|
|
|
const int framenr = BKE_image_user_frame_get(iuser, cfra, &is_in_range);
|
2012-07-03 14:04:39 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (is_in_range) {
|
|
|
|
iuser->flag |= IMA_USER_FRAME_IN_RANGE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
iuser->flag &= ~IMA_USER_FRAME_IN_RANGE;
|
|
|
|
}
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
iuser->framenr = framenr;
|
2019-06-17 11:39:52 +02:00
|
|
|
|
2019-06-19 17:49:39 +02:00
|
|
|
if (ima && BKE_image_is_animated(ima) && ima->gpuframenr != framenr) {
|
2019-06-17 11:39:52 +02:00
|
|
|
/* Note: a single texture and refresh doesn't really work when
|
|
|
|
* multiple image users may use different frames, this is to
|
|
|
|
* be improved with perhaps a GPU texture cache. */
|
|
|
|
ima->gpuflag |= IMA_GPU_REFRESH;
|
|
|
|
ima->gpuframenr = framenr;
|
|
|
|
}
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (iuser->ok == 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
iuser->ok = 1;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-06-17 11:39:52 +02:00
|
|
|
|
2020-02-26 15:55:30 +01:00
|
|
|
if (ima) {
|
|
|
|
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
|
|
|
|
if (tile->ok == 0) {
|
|
|
|
tile->ok = IMA_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-17 11:39:52 +02:00
|
|
|
iuser->flag &= ~IMA_NEED_FRAME_RECALC;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2011-05-01 14:02:40 +00:00
|
|
|
}
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
|
2019-02-18 13:23:49 +01:00
|
|
|
/* goes over all ImageUsers, and sets frame numbers if auto-refresh is set */
|
2019-06-26 19:34:35 +02:00
|
|
|
static void image_editors_update_frame(Image *ima,
|
|
|
|
ID *UNUSED(iuser_id),
|
|
|
|
ImageUser *iuser,
|
|
|
|
void *customdata)
|
2012-06-04 10:41:18 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
int cfra = *(int *)customdata;
|
2012-06-04 10:41:18 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if ((iuser->flag & IMA_ANIM_ALWAYS) || (iuser->flag & IMA_NEED_FRAME_RECALC)) {
|
2019-06-17 11:39:52 +02:00
|
|
|
BKE_image_user_frame_calc(ima, iuser, cfra);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-06-04 10:41:18 +00:00
|
|
|
}
|
|
|
|
|
2019-02-18 13:23:49 +01:00
|
|
|
void BKE_image_editors_update_frame(const Main *bmain, int cfra)
|
2013-05-22 22:17:07 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* This only updates images used by the user interface. For others the
|
|
|
|
* dependency graph will call BKE_image_user_id_eval_animation. */
|
|
|
|
wmWindowManager *wm = bmain->wm.first;
|
|
|
|
image_walk_id_all_users(&wm->id, false, &cfra, image_editors_update_frame);
|
2019-02-18 13:23:49 +01:00
|
|
|
}
|
|
|
|
|
2019-06-26 19:34:35 +02:00
|
|
|
static void image_user_id_has_animation(Image *ima,
|
|
|
|
ID *UNUSED(iuser_id),
|
|
|
|
ImageUser *UNUSED(iuser),
|
|
|
|
void *customdata)
|
2019-02-18 13:23:49 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ima && BKE_image_is_animated(ima)) {
|
|
|
|
*(bool *)customdata = true;
|
|
|
|
}
|
2019-02-18 13:23:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BKE_image_user_id_has_animation(ID *id)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* For the dependency graph, this does not consider nested node
|
|
|
|
* trees as these are handled as their own datablock. */
|
|
|
|
bool has_animation = false;
|
|
|
|
bool skip_nested_nodes = true;
|
|
|
|
image_walk_id_all_users(id, skip_nested_nodes, &has_animation, image_user_id_has_animation);
|
|
|
|
return has_animation;
|
2019-02-18 13:23:49 +01:00
|
|
|
}
|
|
|
|
|
2019-06-26 19:34:35 +02:00
|
|
|
static void image_user_id_eval_animation(Image *ima,
|
|
|
|
ID *UNUSED(iduser_id),
|
|
|
|
ImageUser *iuser,
|
|
|
|
void *customdata)
|
2019-02-18 13:23:49 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ima && BKE_image_is_animated(ima)) {
|
|
|
|
Depsgraph *depsgraph = (Depsgraph *)customdata;
|
2019-02-18 13:23:49 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if ((iuser->flag & IMA_ANIM_ALWAYS) || (iuser->flag & IMA_NEED_FRAME_RECALC) ||
|
|
|
|
(DEG_get_mode(depsgraph) == DAG_EVAL_RENDER)) {
|
|
|
|
float cfra = DEG_get_ctime(depsgraph);
|
2019-02-18 13:23:49 +01:00
|
|
|
|
2019-06-17 11:39:52 +02:00
|
|
|
BKE_image_user_frame_calc(ima, iuser, cfra);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
2013-05-22 22:17:07 +00:00
|
|
|
}
|
|
|
|
|
2019-02-18 13:23:49 +01:00
|
|
|
void BKE_image_user_id_eval_animation(Depsgraph *depsgraph, ID *id)
|
2013-05-22 22:17:07 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* This is called from the dependency graph to update the image
|
2019-06-12 09:04:10 +10:00
|
|
|
* users in data-blocks. It computes the current frame number
|
2019-04-17 06:17:24 +02:00
|
|
|
* and tags the image to be refreshed.
|
|
|
|
* This does not consider nested node trees as these are handled
|
2019-06-12 09:04:10 +10:00
|
|
|
* as their own data-block. */
|
2019-04-17 06:17:24 +02:00
|
|
|
bool skip_nested_nodes = true;
|
|
|
|
image_walk_id_all_users(id, skip_nested_nodes, depsgraph, image_user_id_eval_animation);
|
2013-05-22 22:17:07 +00:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:35:45 +00:00
|
|
|
void BKE_image_user_file_path(ImageUser *iuser, Image *ima, char *filepath)
|
2012-06-04 19:38:33 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (BKE_image_is_multiview(ima)) {
|
|
|
|
ImageView *iv = BLI_findlink(&ima->views, iuser->view);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (iv->filepath[0]) {
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_strncpy(filepath, iv->filepath, FILE_MAX);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_strncpy(filepath, ima->name, FILE_MAX);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_strncpy(filepath, ima->name, FILE_MAX);
|
|
|
|
}
|
2012-06-04 19:38:33 +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
|
|
|
if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_TILED)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
char head[FILE_MAX], tail[FILE_MAX];
|
|
|
|
unsigned short numlen;
|
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
|
|
|
|
|
|
|
int index;
|
|
|
|
if (ima->source == IMA_SRC_SEQUENCE) {
|
|
|
|
index = iuser ? iuser->framenr : ima->lastframe;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
index = (iuser && iuser->tile) ? iuser->tile : 1001;
|
|
|
|
}
|
2012-06-04 19:38:33 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_stringdec(filepath, head, tail, &numlen);
|
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
|
|
|
BLI_stringenc(filepath, head, tail, numlen, index);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-06-04 19:38:33 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&ima->id));
|
2012-06-04 19:38:33 +00:00
|
|
|
}
|
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
bool BKE_image_has_alpha(struct Image *image)
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImBuf *ibuf;
|
|
|
|
void *lock;
|
|
|
|
int planes;
|
2012-06-23 23:22:19 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);
|
|
|
|
planes = (ibuf ? ibuf->planes : 0);
|
|
|
|
BKE_image_release_ibuf(image, ibuf, lock);
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (planes == 32) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return true;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
}
|
2012-09-13 05:29:38 +00:00
|
|
|
|
2020-03-25 17:58:58 +11:00
|
|
|
void BKE_image_get_size(Image *image, ImageUser *iuser, int *r_width, int *r_height)
|
2012-09-13 05:29:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImBuf *ibuf = NULL;
|
|
|
|
void *lock;
|
|
|
|
|
|
|
|
if (image != NULL) {
|
|
|
|
ibuf = BKE_image_acquire_ibuf(image, iuser, &lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ibuf && ibuf->x > 0 && ibuf->y > 0) {
|
2020-03-25 17:58:58 +11:00
|
|
|
*r_width = ibuf->x;
|
|
|
|
*r_height = ibuf->y;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else if (image != NULL && image->type == IMA_TYPE_R_RESULT && iuser != NULL &&
|
|
|
|
iuser->scene != NULL) {
|
|
|
|
Scene *scene = iuser->scene;
|
2020-03-25 17:58:58 +11:00
|
|
|
*r_width = (scene->r.xsch * scene->r.size) / 100;
|
|
|
|
*r_height = (scene->r.ysch * scene->r.size) / 100;
|
2019-04-17 06:17:24 +02:00
|
|
|
if ((scene->r.mode & R_BORDER) && (scene->r.mode & R_CROP)) {
|
2020-03-25 17:58:58 +11:00
|
|
|
*r_width *= BLI_rctf_size_x(&scene->r.border);
|
|
|
|
*r_height *= BLI_rctf_size_y(&scene->r.border);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2020-03-25 17:58:58 +11:00
|
|
|
*r_width = IMG_SIZE_FALLBACK;
|
|
|
|
*r_height = IMG_SIZE_FALLBACK;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (image != NULL) {
|
|
|
|
BKE_image_release_ibuf(image, ibuf, lock);
|
|
|
|
}
|
2012-09-13 05:29:38 +00:00
|
|
|
}
|
|
|
|
|
2020-03-25 17:58:58 +11:00
|
|
|
void BKE_image_get_size_fl(Image *image, ImageUser *iuser, float r_size[2])
|
2012-09-13 05:29:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
int width, height;
|
|
|
|
BKE_image_get_size(image, iuser, &width, &height);
|
2012-09-13 05:29:38 +00:00
|
|
|
|
2020-03-25 17:58:58 +11:00
|
|
|
r_size[0] = (float)width;
|
|
|
|
r_size[1] = (float)height;
|
2012-09-13 05:29:38 +00:00
|
|
|
}
|
|
|
|
|
2020-03-25 17:58:58 +11:00
|
|
|
void BKE_image_get_aspect(Image *image, float *r_aspx, float *r_aspy)
|
2012-09-13 05:29:38 +00:00
|
|
|
{
|
2020-03-25 17:58:58 +11:00
|
|
|
*r_aspx = 1.0;
|
2012-09-13 05:29:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* x is always 1 */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (image) {
|
2020-03-25 17:58:58 +11:00
|
|
|
*r_aspy = image->aspy / image->aspx;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2020-03-25 17:58:58 +11:00
|
|
|
*r_aspy = 1.0f;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-09-13 05:29:38 +00: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
|
|
|
|
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
|
|
|
unsigned char *BKE_image_get_pixels_for_frame(struct Image *image, int frame, int tile)
|
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
|
|
|
{
|
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
|
|
|
ImageUser iuser;
|
|
|
|
BKE_imageuser_default(&iuser);
|
2019-04-17 06:17:24 +02:00
|
|
|
void *lock;
|
|
|
|
ImBuf *ibuf;
|
|
|
|
unsigned char *pixels = NULL;
|
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
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
iuser.framenr = frame;
|
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
|
|
|
iuser.tile = tile;
|
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
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
|
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
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf) {
|
|
|
|
pixels = (unsigned char *)ibuf->rect;
|
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
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pixels) {
|
2019-04-17 06:17:24 +02:00
|
|
|
pixels = MEM_dupallocN(pixels);
|
2019-04-22 09:39:35 +10: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
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_image_release_ibuf(image, ibuf, lock);
|
|
|
|
}
|
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
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!pixels) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10: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
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return pixels;
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
float *BKE_image_get_float_pixels_for_frame(struct Image *image, int frame, int tile)
|
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
|
|
|
{
|
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
|
|
|
ImageUser iuser;
|
|
|
|
BKE_imageuser_default(&iuser);
|
2019-04-17 06:17:24 +02:00
|
|
|
void *lock;
|
|
|
|
ImBuf *ibuf;
|
|
|
|
float *pixels = NULL;
|
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
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
iuser.framenr = frame;
|
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
|
|
|
iuser.tile = tile;
|
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
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
|
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
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf) {
|
|
|
|
pixels = ibuf->rect_float;
|
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
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pixels) {
|
2019-04-17 06:17:24 +02:00
|
|
|
pixels = MEM_dupallocN(pixels);
|
2019-04-22 09:39:35 +10: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
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_image_release_ibuf(image, ibuf, lock);
|
|
|
|
}
|
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
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!pixels) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10: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
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return pixels;
|
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
|
|
|
}
|
2013-03-27 11:26:10 +00:00
|
|
|
|
|
|
|
int BKE_image_sequence_guess_offset(Image *image)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return BLI_stringdec(image->name, NULL, NULL, NULL);
|
2013-03-27 11:26:10 +00:00
|
|
|
}
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
bool BKE_image_has_anim(Image *ima)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return (BLI_listbase_is_empty(&ima->anims) == false);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BKE_image_has_packedfile(Image *ima)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return (BLI_listbase_is_empty(&ima->packedfiles) == false);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
2018-03-04 22:45:22 +01:00
|
|
|
bool BKE_image_has_filepath(Image *ima)
|
|
|
|
{
|
|
|
|
/* This could be improved to detect cases like //../../, currently path
|
|
|
|
* remapping empty file paths empty. */
|
|
|
|
return ima->name[0] != '\0';
|
|
|
|
}
|
|
|
|
|
2019-02-18 13:23:49 +01:00
|
|
|
/* Checks the image buffer changes with time (not keyframed values). */
|
2014-01-14 04:59:58 +11:00
|
|
|
bool BKE_image_is_animated(Image *image)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return ELEM(image->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE);
|
2014-01-14 04:59:58 +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
|
|
|
/* Checks whether the image consists of multiple buffers. */
|
|
|
|
bool BKE_image_has_multiple_ibufs(Image *image)
|
|
|
|
{
|
|
|
|
return ELEM(image->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE, IMA_SRC_TILED);
|
|
|
|
}
|
|
|
|
|
2019-05-14 17:28:13 +02:00
|
|
|
/* Image modifications */
|
2019-06-19 14:28:54 +02:00
|
|
|
bool BKE_image_is_dirty_writable(Image *image, bool *r_is_writable)
|
2013-12-13 16:22:08 +06:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bool is_dirty = false;
|
2019-06-19 14:28:54 +02:00
|
|
|
bool is_writable = false;
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_lock(image_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (image->cache != NULL) {
|
|
|
|
struct MovieCacheIter *iter = IMB_moviecacheIter_new(image->cache);
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
while (!IMB_moviecacheIter_done(iter)) {
|
|
|
|
ImBuf *ibuf = IMB_moviecacheIter_getImBuf(iter);
|
|
|
|
if (ibuf->userflags & IB_BITMAPDIRTY) {
|
2019-06-19 14:28:54 +02:00
|
|
|
is_writable = BKE_image_buffer_format_writable(ibuf);
|
2019-04-17 06:17:24 +02:00
|
|
|
is_dirty = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
IMB_moviecacheIter_step(iter);
|
|
|
|
}
|
|
|
|
IMB_moviecacheIter_free(iter);
|
|
|
|
}
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_unlock(image_mutex);
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2019-06-19 14:28:54 +02:00
|
|
|
if (r_is_writable) {
|
|
|
|
*r_is_writable = is_writable;
|
|
|
|
}
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return is_dirty;
|
2013-12-13 16:22:08 +06:00
|
|
|
}
|
|
|
|
|
2019-06-19 14:28:54 +02:00
|
|
|
bool BKE_image_is_dirty(Image *image)
|
|
|
|
{
|
|
|
|
return BKE_image_is_dirty_writable(image, NULL);
|
|
|
|
}
|
|
|
|
|
2019-05-14 17:28:13 +02:00
|
|
|
void BKE_image_mark_dirty(Image *UNUSED(image), ImBuf *ibuf)
|
|
|
|
{
|
|
|
|
ibuf->userflags |= IB_BITMAPDIRTY;
|
|
|
|
}
|
|
|
|
|
2019-06-19 14:28:54 +02:00
|
|
|
bool BKE_image_buffer_format_writable(ImBuf *ibuf)
|
|
|
|
{
|
|
|
|
ImageFormatData im_format;
|
|
|
|
ImbFormatOptions options_dummy;
|
|
|
|
BKE_imbuf_to_image_format(&im_format, ibuf);
|
|
|
|
return (BKE_image_imtype_to_ftype(im_format.imtype, &options_dummy) == ibuf->ftype);
|
|
|
|
}
|
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
void BKE_image_file_format_set(Image *image, int ftype, const ImbFormatOptions *options)
|
2013-12-13 16:22:08 +06:00
|
|
|
{
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_lock(image_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (image->cache != NULL) {
|
|
|
|
struct MovieCacheIter *iter = IMB_moviecacheIter_new(image->cache);
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
while (!IMB_moviecacheIter_done(iter)) {
|
|
|
|
ImBuf *ibuf = IMB_moviecacheIter_getImBuf(iter);
|
|
|
|
ibuf->ftype = ftype;
|
|
|
|
ibuf->foptions = *options;
|
|
|
|
IMB_moviecacheIter_step(iter);
|
|
|
|
}
|
|
|
|
IMB_moviecacheIter_free(iter);
|
|
|
|
}
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_unlock(image_mutex);
|
2013-12-13 16:22:08 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BKE_image_has_loaded_ibuf(Image *image)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bool has_loaded_ibuf = false;
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_lock(image_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (image->cache != NULL) {
|
|
|
|
struct MovieCacheIter *iter = IMB_moviecacheIter_new(image->cache);
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
while (!IMB_moviecacheIter_done(iter)) {
|
|
|
|
has_loaded_ibuf = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
IMB_moviecacheIter_free(iter);
|
|
|
|
}
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_unlock(image_mutex);
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return has_loaded_ibuf;
|
2013-12-13 16:22:08 +06:00
|
|
|
}
|
|
|
|
|
2019-04-14 10:48:42 +02:00
|
|
|
/**
|
|
|
|
* References the result, #BKE_image_release_ibuf is to be called to de-reference.
|
|
|
|
* Use lock=NULL when calling #BKE_image_release_ibuf().
|
2014-01-03 23:00:53 +06:00
|
|
|
*/
|
2013-12-13 16:22:08 +06:00
|
|
|
ImBuf *BKE_image_get_ibuf_with_name(Image *image, const char *name)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImBuf *ibuf = NULL;
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_lock(image_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (image->cache != NULL) {
|
|
|
|
struct MovieCacheIter *iter = IMB_moviecacheIter_new(image->cache);
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
while (!IMB_moviecacheIter_done(iter)) {
|
|
|
|
ImBuf *current_ibuf = IMB_moviecacheIter_getImBuf(iter);
|
|
|
|
if (STREQ(current_ibuf->name, name)) {
|
|
|
|
ibuf = current_ibuf;
|
|
|
|
IMB_refImBuf(ibuf);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
IMB_moviecacheIter_step(iter);
|
|
|
|
}
|
|
|
|
IMB_moviecacheIter_free(iter);
|
|
|
|
}
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_unlock(image_mutex);
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return ibuf;
|
2013-12-13 16:22:08 +06:00
|
|
|
}
|
|
|
|
|
2019-04-14 10:48:42 +02:00
|
|
|
/**
|
|
|
|
* References the result, #BKE_image_release_ibuf is to be called to de-reference.
|
|
|
|
* Use lock=NULL when calling #BKE_image_release_ibuf().
|
2013-12-13 16:22:08 +06: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
|
|
|
* TODO(sergey): This is actually "get first item from the cache", which is
|
2013-12-13 16:22:08 +06:00
|
|
|
* not so much predictable. But using first loaded image buffer
|
|
|
|
* was also malicious logic and all the areas which uses this
|
|
|
|
* function are to be re-considered.
|
|
|
|
*/
|
|
|
|
ImBuf *BKE_image_get_first_ibuf(Image *image)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImBuf *ibuf = NULL;
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_lock(image_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (image->cache != NULL) {
|
|
|
|
struct MovieCacheIter *iter = IMB_moviecacheIter_new(image->cache);
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
while (!IMB_moviecacheIter_done(iter)) {
|
|
|
|
ibuf = IMB_moviecacheIter_getImBuf(iter);
|
|
|
|
IMB_refImBuf(ibuf);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
IMB_moviecacheIter_free(iter);
|
|
|
|
}
|
2019-11-19 07:37:16 -07:00
|
|
|
BLI_mutex_unlock(image_mutex);
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return ibuf;
|
2013-12-13 16:22:08 +06:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
static void image_update_views_format(Image *ima, ImageUser *iuser)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
SceneRenderView *srv;
|
|
|
|
ImageView *iv;
|
|
|
|
Scene *scene = iuser->scene;
|
|
|
|
const bool is_multiview = ((scene->r.scemode & R_MULTIVIEW) != 0) &&
|
|
|
|
((ima->flag & IMA_USE_VIEWS) != 0);
|
|
|
|
|
|
|
|
/* reset the image views */
|
|
|
|
BKE_image_free_views(ima);
|
|
|
|
|
|
|
|
if (!is_multiview) {
|
|
|
|
/* nothing to do */
|
|
|
|
}
|
|
|
|
else if (ima->views_format == R_IMF_VIEWS_STEREO_3D) {
|
|
|
|
int i;
|
|
|
|
const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
image_add_view(ima, names[i], ima->name);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* R_IMF_VIEWS_INDIVIDUAL */
|
|
|
|
char prefix[FILE_MAX] = {'\0'};
|
|
|
|
char *name = ima->name;
|
|
|
|
const char *ext = NULL;
|
|
|
|
|
|
|
|
BKE_scene_multiview_view_prefix_get(scene, name, prefix, &ext);
|
|
|
|
|
|
|
|
if (prefix[0] == '\0') {
|
|
|
|
BKE_image_free_views(ima);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create all the image views */
|
|
|
|
for (srv = scene->r.views.first; srv; srv = srv->next) {
|
|
|
|
if (BKE_scene_multiview_is_render_view_active(&scene->r, srv)) {
|
|
|
|
char filepath[FILE_MAX];
|
|
|
|
SNPRINTF(filepath, "%s%s%s", prefix, srv->suffix, ext);
|
|
|
|
image_add_view(ima, srv->name, filepath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if the files are all available */
|
|
|
|
iv = ima->views.last;
|
|
|
|
while (iv) {
|
|
|
|
int file;
|
|
|
|
char str[FILE_MAX];
|
|
|
|
|
|
|
|
STRNCPY(str, iv->filepath);
|
2019-10-04 07:03:53 +10:00
|
|
|
BLI_path_abs(str, ID_BLEND_PATH_FROM_GLOBAL(&ima->id));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* exists? */
|
|
|
|
file = BLI_open(str, O_BINARY | O_RDONLY, 0);
|
|
|
|
if (file == -1) {
|
|
|
|
ImageView *iv_del = iv;
|
|
|
|
iv = iv->prev;
|
|
|
|
BLI_remlink(&ima->views, iv_del);
|
|
|
|
MEM_freeN(iv_del);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
iv = iv->prev;
|
|
|
|
close(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* all good */
|
|
|
|
if (!BKE_image_is_multiview(ima)) {
|
|
|
|
BKE_image_free_views(ima);
|
|
|
|
}
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
2018-06-14 22:46:30 +02:00
|
|
|
|
2018-06-19 16:07:10 +02:00
|
|
|
/**************************** Render Slots ***************************/
|
|
|
|
|
2018-06-14 22:46:30 +02:00
|
|
|
RenderSlot *BKE_image_add_renderslot(Image *ima, const char *name)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
RenderSlot *slot = MEM_callocN(sizeof(RenderSlot), "Image new Render Slot");
|
|
|
|
if (name && name[0]) {
|
|
|
|
BLI_strncpy(slot->name, name, sizeof(slot->name));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int n = BLI_listbase_count(&ima->renderslots) + 1;
|
|
|
|
BLI_snprintf(slot->name, sizeof(slot->name), "Slot %d", n);
|
|
|
|
}
|
|
|
|
BLI_addtail(&ima->renderslots, slot);
|
|
|
|
return slot;
|
2018-06-14 22:46:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BKE_image_remove_renderslot(Image *ima, ImageUser *iuser, int index)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
int num_slots = BLI_listbase_count(&ima->renderslots);
|
|
|
|
if (index >= num_slots || num_slots == 1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
RenderSlot *remove_slot = BLI_findlink(&ima->renderslots, index);
|
|
|
|
RenderSlot *current_slot = BLI_findlink(&ima->renderslots, ima->render_slot);
|
|
|
|
RenderSlot *current_last_slot = BLI_findlink(&ima->renderslots, ima->last_render_slot);
|
|
|
|
|
|
|
|
RenderSlot *next_slot;
|
|
|
|
if (current_slot == remove_slot) {
|
|
|
|
next_slot = BLI_findlink(&ima->renderslots, (index == num_slots - 1) ? index - 1 : index + 1);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
next_slot = current_slot;
|
|
|
|
}
|
|
|
|
|
2019-04-27 12:07:07 +10:00
|
|
|
/* If the slot to be removed is the slot with the last render,
|
|
|
|
* make another slot the last render slot. */
|
2019-04-17 06:17:24 +02:00
|
|
|
if (remove_slot == current_last_slot) {
|
2019-04-27 12:07:07 +10:00
|
|
|
/* Choose the currently selected slot unless that one is being removed,
|
|
|
|
* in that case take the next one. */
|
2019-04-17 06:17:24 +02:00
|
|
|
RenderSlot *next_last_slot;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (current_slot == remove_slot) {
|
2019-04-17 06:17:24 +02:00
|
|
|
next_last_slot = next_slot;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
next_last_slot = current_slot;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!iuser) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
Render *re = RE_GetSceneRender(iuser->scene);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!re) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
RE_SwapResult(re, ¤t_last_slot->render);
|
|
|
|
RE_SwapResult(re, &next_last_slot->render);
|
|
|
|
current_last_slot = next_last_slot;
|
|
|
|
}
|
|
|
|
|
|
|
|
current_slot = next_slot;
|
|
|
|
|
|
|
|
BLI_remlink(&ima->renderslots, remove_slot);
|
|
|
|
|
|
|
|
ima->render_slot = BLI_findindex(&ima->renderslots, current_slot);
|
|
|
|
ima->last_render_slot = BLI_findindex(&ima->renderslots, current_last_slot);
|
|
|
|
|
|
|
|
if (remove_slot->render) {
|
|
|
|
RE_FreeRenderResult(remove_slot->render);
|
|
|
|
}
|
|
|
|
MEM_freeN(remove_slot);
|
|
|
|
|
|
|
|
return true;
|
2018-06-14 22:46:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BKE_image_clear_renderslot(Image *ima, ImageUser *iuser, int index)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (index == ima->last_render_slot) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!iuser) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
if (G.is_rendering) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
Render *re = RE_GetSceneRender(iuser->scene);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!re) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
RE_ClearResult(re);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
RenderSlot *slot = BLI_findlink(&ima->renderslots, index);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!slot) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
if (slot->render) {
|
|
|
|
RE_FreeRenderResult(slot->render);
|
|
|
|
slot->render = NULL;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2018-06-14 22:46:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
RenderSlot *BKE_image_get_renderslot(Image *ima, int index)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Can be NULL for images without render slots. */
|
|
|
|
return BLI_findlink(&ima->renderslots, index);
|
2018-06-14 22:46:30 +02:00
|
|
|
}
|