2011-02-23 10:52:22 +00: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
|
|
|
* ***** BEGIN GPLLICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* 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
|
2012-06-13 17:27:49 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
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
|
|
|
*
|
|
|
|
|
* 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.
|
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
|
|
|
*
|
|
|
|
|
* Copyright by Gernot Ziegler <gz@lysator.liu.se>.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): Austin Benesh, Ton Roosendaal (float, half, speedup, cleanup...).
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
2012-03-09 18:28:30 +00:00
|
|
|
/** \file blender/imbuf/intern/openexr/openexr_api.cpp
|
|
|
|
|
* \ingroup openexr
|
|
|
|
|
*/
|
|
|
|
|
|
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
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdio.h>
|
2011-01-27 00:02:25 +00:00
|
|
|
#include <stddef.h>
|
2015-10-28 14:05:49 -02:00
|
|
|
#include <stdexcept>
|
2012-08-24 12:10:35 +00:00
|
|
|
#include <fstream>
|
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
|
|
|
#include <string>
|
2012-04-03 11:53:38 +00:00
|
|
|
#include <set>
|
2012-08-24 14:04:21 +00:00
|
|
|
#include <errno.h>
|
2013-11-29 14:50:59 -05:00
|
|
|
#include <algorithm>
|
2016-05-05 21:39:10 +02:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
#include <half.h>
|
|
|
|
|
#include <Iex.h>
|
|
|
|
|
#include <ImfVersion.h>
|
|
|
|
|
#include <ImathBox.h>
|
|
|
|
|
#include <ImfArray.h>
|
|
|
|
|
#include <ImfIO.h>
|
|
|
|
|
#include <ImfChannelList.h>
|
|
|
|
|
#include <ImfPixelType.h>
|
|
|
|
|
#include <ImfInputFile.h>
|
|
|
|
|
#include <ImfOutputFile.h>
|
|
|
|
|
#include <ImfCompression.h>
|
|
|
|
|
#include <ImfCompressionAttribute.h>
|
|
|
|
|
#include <ImfStringAttribute.h>
|
|
|
|
|
#include <ImfStandardAttributes.h>
|
|
|
|
|
|
|
|
|
|
/* multiview/multipart */
|
|
|
|
|
#include <ImfMultiView.h>
|
|
|
|
|
#include <ImfMultiPartInputFile.h>
|
|
|
|
|
#include <ImfInputPart.h>
|
|
|
|
|
#include <ImfOutputPart.h>
|
|
|
|
|
#include <ImfMultiPartOutputFile.h>
|
|
|
|
|
#include <ImfTiledOutputPart.h>
|
|
|
|
|
#include <ImfPartType.h>
|
|
|
|
|
#include <ImfPartHelper.h>
|
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
|
|
|
|
2015-03-12 14:02:33 +01:00
|
|
|
#include "DNA_scene_types.h" /* For OpenEXR compression constants */
|
|
|
|
|
|
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
|
|
|
#include <openexr_api.h>
|
|
|
|
|
|
2017-05-27 15:34:55 -04:00
|
|
|
#if defined (WIN32)
|
2012-08-24 12:10:35 +00:00
|
|
|
#include "utfconv.h"
|
|
|
|
|
#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
|
|
|
extern "C"
|
|
|
|
|
{
|
2006-11-18 02:48:18 +00:00
|
|
|
|
|
|
|
|
// The following prevents a linking error in debug mode for MSVC using the libs in CVS
|
2017-05-27 15:34:55 -04:00
|
|
|
#if defined(WITH_OPENEXR) && defined(_WIN32) && defined(DEBUG) && _MSC_VER < 1900
|
2006-11-18 02:48:18 +00:00
|
|
|
_CRTIMP void __cdecl _invalid_parameter_noinfo(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2010-07-12 11:28:16 +00:00
|
|
|
#include "BLI_math_color.h"
|
2012-04-02 11:04:24 +00:00
|
|
|
#include "BLI_threads.h"
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
|
2015-01-31 17:15:43 +01:00
|
|
|
#include "BKE_idprop.h"
|
2015-05-26 12:02:14 +02:00
|
|
|
#include "BKE_image.h"
|
2015-01-31 17:15:43 +01: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
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
|
#include "IMB_allocimbuf.h"
|
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
|
|
|
#include "IMB_metadata.h"
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
|
|
|
|
|
#include "openexr_multi.h"
|
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
|
|
|
}
|
|
|
|
|
|
2016-01-26 09:57:25 +01:00
|
|
|
extern "C" {
|
|
|
|
|
#include "IMB_colormanagement.h"
|
|
|
|
|
#include "IMB_colormanagement_intern.h"
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
using namespace Imf;
|
|
|
|
|
using namespace Imath;
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
/* prototype */
|
|
|
|
|
static struct ExrPass *imb_exr_get_pass(ListBase *lb, char *passname);
|
|
|
|
|
static bool exr_has_multiview(MultiPartInputFile& file);
|
|
|
|
|
static bool exr_has_multipart_file(MultiPartInputFile& file);
|
2015-04-20 23:37:04 +10:00
|
|
|
static bool exr_has_alpha(MultiPartInputFile& file);
|
|
|
|
|
static bool exr_has_zbuffer(MultiPartInputFile& file);
|
2015-04-06 10:40:12 -03:00
|
|
|
static void exr_printf(const char *__restrict format, ...);
|
|
|
|
|
static void imb_exr_type_by_channels(ChannelList& channels, StringVector& views,
|
|
|
|
|
bool *r_singlelayer, bool *r_multilayer, bool *r_multiview);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-24 14:04:21 +00:00
|
|
|
/* Memory Input Stream */
|
|
|
|
|
|
2012-06-13 17:27:49 +00:00
|
|
|
class Mem_IStream : public Imf::IStream
|
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
|
|
|
{
|
|
|
|
|
public:
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2016-06-22 14:02:51 +10:00
|
|
|
Mem_IStream(unsigned char *exrbuf, size_t exrsize) :
|
2013-07-19 16:44:17 +00:00
|
|
|
IStream("dummy"), _exrpos(0), _exrsize(exrsize)
|
|
|
|
|
{
|
2012-06-13 17:27:49 +00:00
|
|
|
_exrbuf = exrbuf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual bool read(char c[], int n);
|
|
|
|
|
virtual Int64 tellg();
|
|
|
|
|
virtual void seekg(Int64 pos);
|
|
|
|
|
virtual void clear();
|
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
|
|
|
//virtual ~Mem_IStream() {}; // unused
|
2012-06-13 17:27:49 +00: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
|
|
|
private:
|
2011-10-06 22:04:01 +00:00
|
|
|
|
|
|
|
|
Int64 _exrpos;
|
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
|
|
|
Int64 _exrsize;
|
|
|
|
|
unsigned char *_exrbuf;
|
|
|
|
|
};
|
|
|
|
|
|
2012-06-13 17:27:49 +00:00
|
|
|
bool Mem_IStream::read(char c[], int n)
|
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
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
if (n + _exrpos <= _exrsize) {
|
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
|
|
|
memcpy(c, (void *)(&_exrbuf[_exrpos]), n);
|
|
|
|
|
_exrpos += n;
|
|
|
|
|
return true;
|
2011-10-06 22:04:01 +00: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
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-13 17:27:49 +00:00
|
|
|
Int64 Mem_IStream::tellg()
|
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
|
|
|
{
|
|
|
|
|
return _exrpos;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-13 17:27:49 +00:00
|
|
|
void Mem_IStream::seekg(Int64 pos)
|
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
|
|
|
{
|
|
|
|
|
_exrpos = pos;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-13 17:27:49 +00:00
|
|
|
void Mem_IStream::clear()
|
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
2012-08-24 14:04:21 +00:00
|
|
|
/* File Input Stream */
|
|
|
|
|
|
2012-08-26 07:27:51 +00:00
|
|
|
class IFileStream : public Imf::IStream
|
2012-08-24 14:04:21 +00:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
IFileStream(const char *filename)
|
|
|
|
|
: IStream(filename)
|
|
|
|
|
{
|
|
|
|
|
/* utf-8 file path support on windows */
|
2017-05-27 15:34:55 -04:00
|
|
|
#if defined (WIN32)
|
2012-08-24 14:04:21 +00:00
|
|
|
wchar_t *wfilename = alloc_utf16_from_8(filename, 0);
|
|
|
|
|
ifs.open(wfilename, std::ios_base::binary);
|
|
|
|
|
free(wfilename);
|
|
|
|
|
#else
|
|
|
|
|
ifs.open(filename, std::ios_base::binary);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (!ifs)
|
|
|
|
|
Iex::throwErrnoExc();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual bool read(char c[], int n)
|
|
|
|
|
{
|
|
|
|
|
if (!ifs)
|
|
|
|
|
throw Iex::InputExc("Unexpected end of file.");
|
|
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
|
ifs.read(c, n);
|
|
|
|
|
return check_error();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual Int64 tellg()
|
|
|
|
|
{
|
|
|
|
|
return std::streamoff(ifs.tellg());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void seekg(Int64 pos)
|
|
|
|
|
{
|
|
|
|
|
ifs.seekg(pos);
|
|
|
|
|
check_error();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void clear()
|
|
|
|
|
{
|
|
|
|
|
ifs.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool check_error()
|
|
|
|
|
{
|
|
|
|
|
if (!ifs) {
|
|
|
|
|
if (errno)
|
|
|
|
|
Iex::throwErrnoExc();
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::ifstream ifs;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* File Output Stream */
|
|
|
|
|
|
|
|
|
|
class OFileStream : public OStream
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
OFileStream(const char *filename)
|
|
|
|
|
: OStream(filename)
|
|
|
|
|
{
|
|
|
|
|
/* utf-8 file path support on windows */
|
2017-05-27 15:34:55 -04:00
|
|
|
#if defined (WIN32)
|
2012-08-24 14:04:21 +00:00
|
|
|
wchar_t *wfilename = alloc_utf16_from_8(filename, 0);
|
|
|
|
|
ofs.open(wfilename, std::ios_base::binary);
|
|
|
|
|
free(wfilename);
|
|
|
|
|
#else
|
|
|
|
|
ofs.open(filename, std::ios_base::binary);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (!ofs)
|
|
|
|
|
Iex::throwErrnoExc();
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-03 15:35:03 +00:00
|
|
|
virtual void write(const char c[], int n)
|
2012-08-24 14:04:21 +00:00
|
|
|
{
|
|
|
|
|
errno = 0;
|
|
|
|
|
ofs.write(c, n);
|
|
|
|
|
check_error();
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-03 15:35:03 +00:00
|
|
|
virtual Int64 tellp()
|
2012-08-24 14:04:21 +00:00
|
|
|
{
|
|
|
|
|
return std::streamoff(ofs.tellp());
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-03 15:35:03 +00:00
|
|
|
virtual void seekp(Int64 pos)
|
2012-08-24 14:04:21 +00:00
|
|
|
{
|
|
|
|
|
ofs.seekp(pos);
|
|
|
|
|
check_error();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void check_error()
|
|
|
|
|
{
|
|
|
|
|
if (!ofs) {
|
|
|
|
|
if (errno)
|
|
|
|
|
Iex::throwErrnoExc();
|
|
|
|
|
|
|
|
|
|
throw Iex::ErrnoExc("File output failed.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::ofstream ofs;
|
|
|
|
|
};
|
|
|
|
|
|
2012-06-13 17:27:49 +00:00
|
|
|
struct _RGBAZ {
|
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
|
|
|
half r;
|
|
|
|
|
half g;
|
|
|
|
|
half b;
|
|
|
|
|
half a;
|
|
|
|
|
half z;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef struct _RGBAZ RGBAZ;
|
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2014-05-14 15:00:47 +10:00
|
|
|
/**
|
|
|
|
|
* Test presence of OpenEXR file.
|
|
|
|
|
* \param mem pointer to loaded OpenEXR bitstream
|
|
|
|
|
*/
|
2015-07-11 23:52:18 +10:00
|
|
|
int imb_is_a_openexr(const unsigned char *mem)
|
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
|
|
|
{
|
2012-06-13 17:27:49 +00:00
|
|
|
return Imf::isImfMagic((const char *)mem);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void openexr_header_compression(Header *header, int compression)
|
|
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (compression) {
|
2015-03-12 14:02:33 +01:00
|
|
|
case R_IMF_EXR_CODEC_NONE:
|
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
|
|
|
header->compression() = NO_COMPRESSION;
|
|
|
|
|
break;
|
2015-03-12 14:02:33 +01:00
|
|
|
case R_IMF_EXR_CODEC_PXR24:
|
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
|
|
|
header->compression() = PXR24_COMPRESSION;
|
|
|
|
|
break;
|
2015-03-12 14:02:33 +01:00
|
|
|
case R_IMF_EXR_CODEC_ZIP:
|
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
|
|
|
header->compression() = ZIP_COMPRESSION;
|
|
|
|
|
break;
|
2015-03-12 14:02:33 +01:00
|
|
|
case R_IMF_EXR_CODEC_PIZ:
|
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
|
|
|
header->compression() = PIZ_COMPRESSION;
|
|
|
|
|
break;
|
2015-03-12 14:02:33 +01:00
|
|
|
case R_IMF_EXR_CODEC_RLE:
|
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
|
|
|
header->compression() = RLE_COMPRESSION;
|
|
|
|
|
break;
|
2015-03-12 14:02:33 +01:00
|
|
|
case R_IMF_EXR_CODEC_ZIPS:
|
|
|
|
|
header->compression() = ZIPS_COMPRESSION;
|
|
|
|
|
break;
|
|
|
|
|
case R_IMF_EXR_CODEC_B44:
|
|
|
|
|
header->compression() = B44_COMPRESSION;
|
|
|
|
|
break;
|
|
|
|
|
case R_IMF_EXR_CODEC_B44A:
|
|
|
|
|
header->compression() = B44A_COMPRESSION;
|
|
|
|
|
break;
|
|
|
|
|
#if OPENEXR_VERSION_MAJOR >= 2 && OPENEXR_VERSION_MINOR >= 2
|
|
|
|
|
case R_IMF_EXR_CODEC_DWAA:
|
|
|
|
|
header->compression() = DWAA_COMPRESSION;
|
|
|
|
|
break;
|
|
|
|
|
case R_IMF_EXR_CODEC_DWAB:
|
|
|
|
|
header->compression() = DWAB_COMPRESSION;
|
|
|
|
|
break;
|
|
|
|
|
#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
|
|
|
default:
|
2006-12-21 10:41:43 +00:00
|
|
|
header->compression() = ZIP_COMPRESSION;
|
2012-06-13 17:27:49 +00:00
|
|
|
break;
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
static void openexr_header_metadata(Header *header, struct ImBuf *ibuf)
|
|
|
|
|
{
|
2015-01-31 17:15:43 +01:00
|
|
|
if (ibuf->metadata) {
|
|
|
|
|
IDProperty *prop;
|
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
|
|
|
|
2015-01-31 17:15:43 +01:00
|
|
|
for (prop = (IDProperty *)ibuf->metadata->data.group.first; prop; prop = prop->next) {
|
|
|
|
|
if (prop->type == IDP_STRING) {
|
|
|
|
|
header->insert(prop->name, StringAttribute(IDP_String(prop)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-03-13 07:16:53 +00:00
|
|
|
|
2013-04-16 13:01:46 +00:00
|
|
|
if (ibuf->ppm[0] > 0.0)
|
|
|
|
|
addXDensity(*header, ibuf->ppm[0] / 39.3700787); /* 1 meter = 39.3700787 inches */
|
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
|
|
|
}
|
|
|
|
|
|
2015-07-01 15:23:09 +02:00
|
|
|
static void openexr_header_metadata_callback(void *data, const char *propname, char *prop, int UNUSED(len))
|
2015-05-26 12:02:14 +02:00
|
|
|
{
|
|
|
|
|
Header *header = (Header *)data;
|
|
|
|
|
header->insert(propname, StringAttribute(prop));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-10-24 01:01:10 +11:00
|
|
|
static bool imb_save_openexr_half(
|
|
|
|
|
ImBuf *ibuf, const char *name, const int flags, const int totviews,
|
|
|
|
|
const char * (*getview)(void *base, int view_id),
|
|
|
|
|
ImBuf *(*getbuffer)(void *base, const int view_id))
|
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
|
|
|
{
|
2012-06-14 11:44:05 +00:00
|
|
|
const int channels = ibuf->channels;
|
2015-04-20 23:37:04 +10:00
|
|
|
const bool is_alpha = (channels >= 4) && (ibuf->planes == 32);
|
|
|
|
|
const bool is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; /* summarize */
|
2012-06-14 11:44:05 +00:00
|
|
|
const int width = ibuf->x;
|
|
|
|
|
const int height = ibuf->y;
|
2015-04-06 10:40:12 -03:00
|
|
|
const bool is_multiview = (flags & IB_multiview) && ibuf->userdata;
|
|
|
|
|
|
|
|
|
|
BLI_assert((!is_multiview) || (getview && getbuffer));
|
|
|
|
|
|
|
|
|
|
std::vector <string> views;
|
2015-10-24 01:01:10 +11:00
|
|
|
int view_id;
|
2012-06-13 17:27:49 +00: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
|
|
|
try
|
|
|
|
|
{
|
2012-06-13 17:27:49 +00:00
|
|
|
Header header(width, height);
|
|
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
openexr_header_compression(&header, ibuf->foptions.flag & OPENEXR_COMPRESS);
|
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
|
|
|
openexr_header_metadata(&header, ibuf);
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* create views when possible */
|
|
|
|
|
for (view_id = 0; view_id < totviews; view_id ++)
|
|
|
|
|
views.push_back(is_multiview ? getview(ibuf->userdata, view_id) : "");
|
|
|
|
|
|
|
|
|
|
if (is_multiview)
|
|
|
|
|
addMultiView(header, views);
|
|
|
|
|
|
|
|
|
|
for (view_id = 0; view_id < totviews; view_id ++) {
|
|
|
|
|
header.channels().insert(insertViewName("R", views, view_id), Channel(HALF));
|
|
|
|
|
header.channels().insert(insertViewName("G", views, view_id), Channel(HALF));
|
|
|
|
|
header.channels().insert(insertViewName("B", views, view_id), Channel(HALF));
|
|
|
|
|
if (is_alpha)
|
|
|
|
|
header.channels().insert(insertViewName("A", views, view_id), Channel(HALF));
|
|
|
|
|
if (is_zbuf) // z we do as float always
|
|
|
|
|
header.channels().insert(insertViewName("Z", views, view_id), Channel(Imf::FLOAT));
|
|
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
|
|
|
|
FrameBuffer frameBuffer;
|
2012-08-24 12:10:35 +00:00
|
|
|
|
|
|
|
|
/* manually create ofstream, so we can handle utf-8 filepaths on windows */
|
2012-08-24 14:04:21 +00:00
|
|
|
OFileStream file_stream(name);
|
|
|
|
|
OutputFile file(file_stream, header);
|
2012-06-13 17:27:49 +00: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
|
|
|
/* we store first everything in half array */
|
2016-02-20 15:48:15 +01:00
|
|
|
std::vector<RGBAZ> pixels(height * width * totviews);
|
2012-06-14 11:44:05 +00:00
|
|
|
int xstride = sizeof(RGBAZ);
|
2012-06-13 17:27:49 +00:00
|
|
|
int ystride = xstride * width;
|
2008-04-29 16:57:39 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
for (view_id = 0; view_id < totviews; view_id ++) {
|
|
|
|
|
ImBuf *view_ibuf = is_multiview ? getbuffer(ibuf->userdata, view_id) : ibuf;
|
|
|
|
|
const size_t offset = view_id * width * height;
|
2016-02-20 15:48:15 +01:00
|
|
|
RGBAZ *to = &pixels[offset];
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2015-10-28 14:05:49 -02:00
|
|
|
/* TODO (dfelinto)
|
|
|
|
|
* In some cases we get NULL ibufs, it needs investigation, meanwhile prevent crash
|
|
|
|
|
* Multiview Render + Image Editor + OpenEXR + Multi-View
|
|
|
|
|
*/
|
|
|
|
|
if (view_ibuf == NULL) {
|
|
|
|
|
throw std::runtime_error(std::string("Missing data to write to ") + name);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* indicate used buffers */
|
|
|
|
|
frameBuffer.insert(insertViewName("R", views, view_id), Slice(HALF, (char *) &pixels[offset].r, xstride, ystride));
|
|
|
|
|
frameBuffer.insert(insertViewName("G", views, view_id), Slice(HALF, (char *) &pixels[offset].g, xstride, ystride));
|
|
|
|
|
frameBuffer.insert(insertViewName("B", views, view_id), Slice(HALF, (char *) &pixels[offset].b, xstride, ystride));
|
|
|
|
|
if (is_alpha)
|
|
|
|
|
frameBuffer.insert(insertViewName("A", views, view_id), Slice(HALF, (char *) &pixels[offset].a, xstride, ystride));
|
|
|
|
|
if (is_zbuf)
|
|
|
|
|
frameBuffer.insert(insertViewName("Z", views, view_id), Slice(Imf::FLOAT, (char *)(view_ibuf->zbuf_float + (height - 1) * width),
|
|
|
|
|
sizeof(float), sizeof(float) * -width));
|
|
|
|
|
if (view_ibuf->rect_float) {
|
|
|
|
|
float *from;
|
|
|
|
|
|
|
|
|
|
for (int i = view_ibuf->y - 1; i >= 0; i--) {
|
|
|
|
|
from = view_ibuf->rect_float + channels * i * width;
|
|
|
|
|
|
|
|
|
|
for (int j = view_ibuf->x; j > 0; j--) {
|
|
|
|
|
to->r = from[0];
|
|
|
|
|
to->g = (channels >= 2) ? from[1] : from[0];
|
|
|
|
|
to->b = (channels >= 3) ? from[2] : from[0];
|
|
|
|
|
to->a = (channels >= 4) ? from[3] : 1.0f;
|
|
|
|
|
to++; from += channels;
|
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
else {
|
|
|
|
|
unsigned char *from;
|
|
|
|
|
|
|
|
|
|
for (int i = view_ibuf->y - 1; i >= 0; i--) {
|
|
|
|
|
from = (unsigned char *)view_ibuf->rect + 4 * i * width;
|
|
|
|
|
|
|
|
|
|
for (int j = view_ibuf->x; j > 0; j--) {
|
|
|
|
|
to->r = srgb_to_linearrgb((float)from[0] / 255.0f);
|
|
|
|
|
to->g = srgb_to_linearrgb((float)from[1] / 255.0f);
|
|
|
|
|
to->b = srgb_to_linearrgb((float)from[2] / 255.0f);
|
|
|
|
|
to->a = channels >= 4 ? (float)from[3] / 255.0f : 1.0f;
|
|
|
|
|
to++; from += 4;
|
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
if (is_multiview)
|
|
|
|
|
IMB_freeImBuf(view_ibuf);
|
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
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
exr_printf("OpenEXR-save: Writing OpenEXR file of height %d.\n", height);
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2012-08-24 12:10:35 +00:00
|
|
|
file.setFrameBuffer(frameBuffer);
|
|
|
|
|
file.writePixels(height);
|
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
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
catch (const std::exception& exc)
|
2011-10-06 22:04:01 +00: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
|
|
|
printf("OpenEXR-save: ERROR: %s\n", exc.what());
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
return false;
|
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
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
return true;
|
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
|
|
|
}
|
|
|
|
|
|
2015-10-24 01:01:10 +11:00
|
|
|
static bool imb_save_openexr_float(
|
|
|
|
|
ImBuf *ibuf, const char *name, const int flags, const int totviews,
|
|
|
|
|
const char * (*getview)(void *base, const int view_id),
|
|
|
|
|
ImBuf *(*getbuffer)(void *base, const int view_id))
|
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
|
|
|
{
|
2012-06-14 11:44:05 +00:00
|
|
|
const int channels = ibuf->channels;
|
2015-04-20 23:37:04 +10:00
|
|
|
const bool is_alpha = (channels >= 4) && (ibuf->planes == 32);
|
|
|
|
|
const bool is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; /* summarize */
|
2012-06-14 11:44:05 +00:00
|
|
|
const int width = ibuf->x;
|
|
|
|
|
const int height = ibuf->y;
|
2015-04-06 10:40:12 -03:00
|
|
|
const bool is_multiview = (flags & IB_multiview) && ibuf->userdata;
|
|
|
|
|
|
|
|
|
|
BLI_assert((!is_multiview) || (getview && getbuffer));
|
|
|
|
|
|
|
|
|
|
std::vector <string> views;
|
2015-10-24 01:01:10 +11:00
|
|
|
int view_id;
|
2006-01-11 22:36:31 +00: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
|
|
|
try
|
|
|
|
|
{
|
2012-06-13 17:27:49 +00:00
|
|
|
Header header(width, height);
|
|
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
openexr_header_compression(&header, ibuf->foptions.flag & OPENEXR_COMPRESS);
|
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
|
|
|
openexr_header_metadata(&header, ibuf);
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* create views when possible */
|
|
|
|
|
for (view_id = 0; view_id < totviews; view_id ++)
|
|
|
|
|
views.push_back(is_multiview ? getview(ibuf->userdata, view_id) : "");
|
|
|
|
|
|
|
|
|
|
if (is_multiview)
|
|
|
|
|
addMultiView(header, views);
|
|
|
|
|
|
|
|
|
|
for (view_id = 0; view_id < totviews; view_id ++) {
|
|
|
|
|
header.channels().insert(insertViewName("R", views, view_id), Channel(Imf::FLOAT));
|
|
|
|
|
header.channels().insert(insertViewName("G", views, view_id), Channel(Imf::FLOAT));
|
|
|
|
|
header.channels().insert(insertViewName("B", views, view_id), Channel(Imf::FLOAT));
|
|
|
|
|
if (is_alpha)
|
|
|
|
|
header.channels().insert(insertViewName("A", views, view_id), Channel(Imf::FLOAT));
|
|
|
|
|
if (is_zbuf)
|
|
|
|
|
header.channels().insert(insertViewName("Z", views, view_id), Channel(Imf::FLOAT));
|
|
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
|
|
|
|
FrameBuffer frameBuffer;
|
2012-08-24 12:10:35 +00:00
|
|
|
|
|
|
|
|
/* manually create ofstream, so we can handle utf-8 filepaths on windows */
|
2012-08-24 14:04:21 +00:00
|
|
|
OFileStream file_stream(name);
|
|
|
|
|
OutputFile file(file_stream, header);
|
2012-08-24 12:10:35 +00:00
|
|
|
|
2011-10-20 12:15:39 +00:00
|
|
|
int xstride = sizeof(float) * channels;
|
2012-06-13 17:27:49 +00:00
|
|
|
int ystride = -xstride * width;
|
2011-10-20 12:15:39 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
for (view_id = 0; view_id < totviews; view_id ++) {
|
|
|
|
|
float *rect[4] = {NULL, NULL, NULL, NULL};
|
|
|
|
|
ImBuf *view_ibuf = is_multiview ? getbuffer(ibuf->userdata, view_id) : ibuf;
|
|
|
|
|
|
2015-10-28 14:05:49 -02:00
|
|
|
/* TODO (dfelinto)
|
|
|
|
|
* In some cases we get NULL ibufs, it needs investigation, meanwhile prevent crash
|
|
|
|
|
* Multiview Render + Image Editor + OpenEXR + Multi-View
|
|
|
|
|
*/
|
|
|
|
|
if (view_ibuf == NULL) {
|
|
|
|
|
throw std::runtime_error(std::string("Missing data to write to ") + name);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* last scanline, stride negative */
|
|
|
|
|
rect[0] = view_ibuf->rect_float + channels * (height - 1) * width;
|
|
|
|
|
rect[1] = (channels >= 2) ? rect[0] + 1 : rect[0];
|
|
|
|
|
rect[2] = (channels >= 3) ? rect[0] + 2 : rect[0];
|
|
|
|
|
rect[3] = (channels >= 4) ? rect[0] + 3 : rect[0]; /* red as alpha, is this needed since alpha isn't written? */
|
|
|
|
|
|
|
|
|
|
frameBuffer.insert(insertViewName("R", views, view_id), Slice(Imf::FLOAT, (char *)rect[0], xstride, ystride));
|
|
|
|
|
frameBuffer.insert(insertViewName("G", views, view_id), Slice(Imf::FLOAT, (char *)rect[1], xstride, ystride));
|
|
|
|
|
frameBuffer.insert(insertViewName("B", views, view_id), Slice(Imf::FLOAT, (char *)rect[2], xstride, ystride));
|
|
|
|
|
if (is_alpha)
|
|
|
|
|
frameBuffer.insert(insertViewName("A", views, view_id), Slice(Imf::FLOAT, (char *)rect[3], xstride, ystride));
|
|
|
|
|
if (is_zbuf)
|
|
|
|
|
frameBuffer.insert(insertViewName("Z", views, view_id), Slice(Imf::FLOAT, (char *) (view_ibuf->zbuf_float + (height - 1) * width),
|
|
|
|
|
sizeof(float), sizeof(float) * -width));
|
|
|
|
|
|
|
|
|
|
if (is_multiview)
|
|
|
|
|
IMB_freeImBuf(view_ibuf);
|
|
|
|
|
}
|
2012-08-24 12:10:35 +00:00
|
|
|
file.setFrameBuffer(frameBuffer);
|
|
|
|
|
file.writePixels(height);
|
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
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
catch (const std::exception& exc)
|
2011-10-06 22:04:01 +00: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
|
|
|
printf("OpenEXR-save: ERROR: %s\n", exc.what());
|
2015-04-06 10:40:12 -03:00
|
|
|
return false;
|
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
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
return true;
|
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
|
|
|
}
|
|
|
|
|
|
2010-11-19 02:14:18 +00:00
|
|
|
int imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags)
|
2006-01-09 10:55:41 +00:00
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
if (flags & IB_mem) {
|
2006-01-09 10:55:41 +00:00
|
|
|
printf("OpenEXR-save: Create EXR in memory CURRENTLY NOT SUPPORTED !\n");
|
|
|
|
|
imb_addencodedbufferImBuf(ibuf);
|
2012-06-13 17:27:49 +00:00
|
|
|
ibuf->encodedsize = 0;
|
2006-01-09 10:55:41 +00:00
|
|
|
return(0);
|
2012-06-13 17:27:49 +00:00
|
|
|
}
|
|
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
if (ibuf->foptions.flag & OPENEXR_HALF)
|
2015-04-06 10:40:12 -03:00
|
|
|
return (int) imb_save_openexr_half(ibuf, name, flags, 1, NULL, NULL);
|
|
|
|
|
else {
|
|
|
|
|
/* when no float rect, we save as half (16 bits is sufficient) */
|
|
|
|
|
if (ibuf->rect_float == NULL)
|
|
|
|
|
return (int) imb_save_openexr_half(ibuf, name, flags, 1, NULL, NULL);
|
|
|
|
|
else
|
|
|
|
|
return (int) imb_save_openexr_float(ibuf, name, flags, 1, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-24 01:01:10 +11:00
|
|
|
static bool imb_save_openexr_multiview(
|
|
|
|
|
ImBuf *ibuf, const char *name, const int flags, const int totviews,
|
|
|
|
|
const char *(*getview)(void *base, const int view_id),
|
|
|
|
|
ImBuf *(*getbuffer)(void *base, const int view_id))
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
|
|
|
|
if (flags & IB_mem) {
|
|
|
|
|
printf("OpenEXR-save: Create multiview EXR in memory CURRENTLY NOT SUPPORTED !\n");
|
|
|
|
|
imb_addencodedbufferImBuf(ibuf);
|
|
|
|
|
ibuf->encodedsize = 0;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
if (ibuf->foptions.flag & OPENEXR_HALF)
|
2015-04-06 10:40:12 -03:00
|
|
|
return imb_save_openexr_half(ibuf, name, flags, totviews, getview, getbuffer);
|
2006-01-09 10:55:41 +00:00
|
|
|
else {
|
|
|
|
|
/* when no float rect, we save as half (16 bits is sufficient) */
|
2012-06-13 17:27:49 +00:00
|
|
|
if (ibuf->rect_float == NULL)
|
2015-04-06 10:40:12 -03:00
|
|
|
return imb_save_openexr_half(ibuf, name, flags, totviews, getview, getbuffer);
|
2006-01-09 10:55:41 +00:00
|
|
|
else
|
2015-04-06 10:40:12 -03:00
|
|
|
return imb_save_openexr_float(ibuf, name, flags, totviews, getview, getbuffer);
|
2006-01-09 10:55:41 +00: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
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* Save single-layer multiview OpenEXR
|
|
|
|
|
* If we have more multiview formats in the future, the function below could be incorporated
|
|
|
|
|
* in our ImBuf write functions, meanwhile this is an OpenEXR special case only */
|
2015-10-24 01:01:10 +11:00
|
|
|
bool IMB_exr_multiview_save(
|
|
|
|
|
ImBuf *ibuf, const char *name, const int flags, const int totviews,
|
|
|
|
|
const char *(*getview)(void *base, const int view_id),
|
|
|
|
|
ImBuf *(*getbuffer)(void *base, const int view_id))
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
|
|
|
|
return imb_save_openexr_multiview(ibuf, name, flags, totviews, getview, getbuffer);
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* ********************* Nicer API, MultiLayer and with Tile file support ************************************ */
|
|
|
|
|
|
|
|
|
|
/* naming rules:
|
2012-03-09 18:28:30 +00:00
|
|
|
* - parse name from right to left
|
|
|
|
|
* - last character is channel ID, 1 char like 'A' 'R' 'G' 'B' 'X' 'Y' 'Z' 'W' 'U' 'V'
|
|
|
|
|
* - separated with a dot; the Pass name (like "Depth", "Color", "Diffuse" or "Combined")
|
|
|
|
|
* - separated with a dot: the Layer name (like "Lamp1" or "Walls" or "Characters")
|
|
|
|
|
*/
|
2006-12-20 17:57:56 +00:00
|
|
|
|
2012-06-13 17:27:49 +00:00
|
|
|
static ListBase exrhandles = {NULL, NULL};
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
typedef struct ExrHandle {
|
2006-12-20 17:57:56 +00:00
|
|
|
struct ExrHandle *next, *prev;
|
2015-04-06 10:40:12 -03:00
|
|
|
char name[FILE_MAX];
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-06-03 16:23:32 +10:00
|
|
|
IStream *ifile_stream;
|
2015-04-06 10:40:12 -03:00
|
|
|
MultiPartInputFile *ifile;
|
2012-08-24 12:10:35 +00:00
|
|
|
|
2012-08-24 14:04:21 +00:00
|
|
|
OFileStream *ofile_stream;
|
2015-04-06 10:40:12 -03:00
|
|
|
MultiPartOutputFile *mpofile;
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
OutputFile *ofile;
|
2012-08-24 12:10:35 +00:00
|
|
|
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
int tilex, tiley;
|
|
|
|
|
int width, height;
|
2008-02-06 13:45:07 +00:00
|
|
|
int mipmap;
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
StringVector *multiView; /* it needs to be a pointer due to Windows release builds of EXR2.0 segfault when opening EXR bug */
|
|
|
|
|
int parts;
|
|
|
|
|
|
2012-06-13 17:27:49 +00:00
|
|
|
ListBase channels; /* flattened out, ExrChannel */
|
|
|
|
|
ListBase layers; /* hierarchical, pointing in end to ExrChannel */
|
2015-06-19 13:00:18 +02:00
|
|
|
|
|
|
|
|
int num_half_channels; /* used during filr save, allows faster temporary buffers allocation */
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
} ExrHandle;
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* flattened out channel */
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
typedef struct ExrChannel {
|
|
|
|
|
struct ExrChannel *next, *prev;
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
char name[EXR_TOT_MAXNAME + 1]; /* full name with everything */
|
|
|
|
|
struct MultiViewChannelName *m; /* struct to store all multipart channel info */
|
2012-06-13 17:27:49 +00:00
|
|
|
int xstride, ystride; /* step to next pixel, to next scanline */
|
|
|
|
|
float *rect; /* first pointer to write in */
|
|
|
|
|
char chan_id; /* quick lookup of channel char */
|
2015-04-06 10:40:12 -03:00
|
|
|
int view_id; /* quick lookup of channel view */
|
2015-06-19 13:00:18 +02:00
|
|
|
bool use_half_float; /* when saving use half float for file storage */
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
} ExrChannel;
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
|
|
|
|
|
/* hierarchical; layers -> passes -> channels[] */
|
|
|
|
|
typedef struct ExrPass {
|
|
|
|
|
struct ExrPass *next, *prev;
|
|
|
|
|
char name[EXR_PASS_MAXNAME];
|
|
|
|
|
int totchan;
|
|
|
|
|
float *rect;
|
|
|
|
|
struct ExrChannel *chan[EXR_PASS_MAXCHAN];
|
|
|
|
|
char chan_id[EXR_PASS_MAXCHAN];
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
char internal_name[EXR_PASS_MAXNAME]; /* name with no view */
|
|
|
|
|
char view[EXR_VIEW_MAXNAME];
|
|
|
|
|
int view_id;
|
2006-12-20 17:57:56 +00:00
|
|
|
} ExrPass;
|
|
|
|
|
|
|
|
|
|
typedef struct ExrLayer {
|
|
|
|
|
struct ExrLayer *next, *prev;
|
2012-06-13 17:27:49 +00:00
|
|
|
char name[EXR_LAY_MAXNAME + 1];
|
2006-12-20 17:57:56 +00:00
|
|
|
ListBase passes;
|
|
|
|
|
} ExrLayer;
|
|
|
|
|
|
|
|
|
|
/* ********************** */
|
|
|
|
|
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
void *IMB_exr_get_handle(void)
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
{
|
2012-06-13 17:27:49 +00:00
|
|
|
ExrHandle *data = (ExrHandle *)MEM_callocN(sizeof(ExrHandle), "exr handle");
|
2015-04-06 10:40:12 -03:00
|
|
|
data->multiView = new StringVector();
|
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
BLI_addtail(&exrhandles, data);
|
|
|
|
|
return data;
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
void *IMB_exr_get_handle_name(const char *name)
|
|
|
|
|
{
|
|
|
|
|
ExrHandle *data = (ExrHandle *) BLI_rfindstring(&exrhandles, name, offsetof(ExrHandle, name));
|
|
|
|
|
|
|
|
|
|
if (data == NULL) {
|
|
|
|
|
data = (ExrHandle *)IMB_exr_get_handle();
|
|
|
|
|
BLI_strncpy(data->name, name, strlen(name) + 1);
|
|
|
|
|
}
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* multiview functions */
|
|
|
|
|
} // extern "C"
|
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
void IMB_exr_add_view(void *handle, const char *name)
|
|
|
|
|
{
|
|
|
|
|
ExrHandle *data = (ExrHandle *)handle;
|
|
|
|
|
data->multiView->push_back(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int imb_exr_get_multiView_id(StringVector& views, const std::string& name)
|
|
|
|
|
{
|
|
|
|
|
int count = 0;
|
|
|
|
|
for (StringVector::const_iterator i = views.begin(); count < views.size(); ++i) {
|
|
|
|
|
if (name == *i)
|
|
|
|
|
return count;
|
|
|
|
|
else
|
|
|
|
|
count ++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* no views or wrong name */
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void imb_exr_get_views(MultiPartInputFile& file, StringVector& views)
|
|
|
|
|
{
|
|
|
|
|
if (exr_has_multipart_file(file) == false) {
|
|
|
|
|
if (exr_has_multiview(file)) {
|
|
|
|
|
StringVector sv = multiView(file.header(0));
|
|
|
|
|
for (StringVector::const_iterator i = sv.begin(); i != sv.end(); ++i)
|
|
|
|
|
views.push_back(*i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
for (int p = 0; p < file.parts(); p++) {
|
|
|
|
|
std::string view = "";
|
|
|
|
|
if (file.header(p).hasView())
|
|
|
|
|
view = file.header(p).view();
|
|
|
|
|
|
|
|
|
|
if (imb_exr_get_multiView_id(views, view) == -1)
|
|
|
|
|
views.push_back(view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Multilayer Blender files have the view name in all the passes (even the default view one) */
|
2015-07-12 01:43:32 +10:00
|
|
|
static void imb_exr_insert_view_name(char *name_full, const char *passname, const char *viewname)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2015-07-12 01:43:32 +10:00
|
|
|
BLI_assert(!ELEM(name_full, passname, viewname));
|
2015-07-12 01:43:32 +10:00
|
|
|
|
2015-07-12 01:43:32 +10:00
|
|
|
if (viewname == NULL || viewname[0] == '\0') {
|
|
|
|
|
BLI_strncpy(name_full, passname, sizeof(((ExrChannel *)NULL)->name));
|
2015-07-12 01:43:32 +10:00
|
|
|
return;
|
2015-07-12 01:43:32 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2015-06-27 10:24:00 +02:00
|
|
|
const char delims[] = {'.', '\0'};
|
2015-06-27 11:00:47 +02:00
|
|
|
const char *sep;
|
|
|
|
|
const char *token;
|
2015-06-27 10:24:00 +02:00
|
|
|
size_t len;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2015-06-27 10:24:00 +02:00
|
|
|
len = BLI_str_rpartition(passname, delims, &sep, &token);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2015-06-27 10:24:00 +02:00
|
|
|
if (sep) {
|
2015-07-12 01:43:32 +10:00
|
|
|
BLI_snprintf(name_full, EXR_PASS_MAXNAME, "%.*s.%s.%s", (int)len, passname, viewname, token);
|
2015-06-27 10:24:00 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2015-07-12 01:43:32 +10:00
|
|
|
BLI_snprintf(name_full, EXR_PASS_MAXNAME, "%s.%s", passname, viewname);
|
2015-06-27 10:24:00 +02:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* adds flattened ExrChannels */
|
|
|
|
|
/* xstride, ystride and rect can be done in set_channel too, for tile writing */
|
2015-04-06 10:40:12 -03:00
|
|
|
/* passname does not include view */
|
2015-06-19 13:00:18 +02:00
|
|
|
void IMB_exr_add_channel(void *handle,
|
|
|
|
|
const char *layname, const char *passname, const char *viewname,
|
|
|
|
|
int xstride, int ystride, float *rect,
|
|
|
|
|
bool use_half_float)
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
{
|
2012-06-13 17:27:49 +00:00
|
|
|
ExrHandle *data = (ExrHandle *)handle;
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
ExrChannel *echan;
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
echan = (ExrChannel *)MEM_callocN(sizeof(ExrChannel), "exr channel");
|
|
|
|
|
echan->m = new MultiViewChannelName ();
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (layname && layname[0] != '\0') {
|
|
|
|
|
echan->m->name = layname;
|
|
|
|
|
echan->m->name.append(".");
|
|
|
|
|
echan->m->name.append(passname);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echan->m->name.assign(passname);
|
|
|
|
|
}
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
echan->m->internal_name = echan->m->name;
|
|
|
|
|
|
|
|
|
|
echan->m->view.assign(viewname ? viewname : "");
|
|
|
|
|
|
|
|
|
|
/* quick look up */
|
|
|
|
|
echan->view_id = std::max(0, imb_exr_get_multiView_id(*data->multiView, echan->m->view));
|
|
|
|
|
|
|
|
|
|
/* name has to be unique, thus it's a combination of layer, pass, view, and channel */
|
|
|
|
|
if (layname && layname[0] != '\0') {
|
2015-07-12 01:43:32 +10:00
|
|
|
imb_exr_insert_view_name(echan->name, echan->m->name.c_str(), echan->m->view.c_str());
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
else if (data->multiView->size() > 1) {
|
|
|
|
|
std::string raw_name = insertViewName(echan->m->name, *data->multiView, echan->view_id);
|
|
|
|
|
BLI_strncpy(echan->name, raw_name.c_str(), sizeof(echan->name));
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
else {
|
2015-04-06 10:40:12 -03:00
|
|
|
BLI_strncpy(echan->name, echan->m->name.c_str(), sizeof(echan->name));
|
2012-06-13 17:27:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echan->xstride = xstride;
|
|
|
|
|
echan->ystride = ystride;
|
|
|
|
|
echan->rect = rect;
|
2015-06-19 13:00:18 +02:00
|
|
|
echan->use_half_float = use_half_float;
|
|
|
|
|
|
|
|
|
|
if (echan->use_half_float) {
|
|
|
|
|
data->num_half_channels++;
|
|
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
exr_printf("added channel %s\n", echan->name);
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
BLI_addtail(&data->channels, echan);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* used for output files (from RenderResult) (single and multilayer, single and multiview) */
|
2015-05-26 17:49:08 +02:00
|
|
|
int IMB_exr_begin_write(void *handle, const char *filename, int width, int height, int compress, const StampData *stamp)
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
{
|
2012-06-13 17:27:49 +00:00
|
|
|
ExrHandle *data = (ExrHandle *)handle;
|
|
|
|
|
Header header(width, height);
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
ExrChannel *echan;
|
2012-06-13 17:27:49 +00:00
|
|
|
|
|
|
|
|
data->width = width;
|
|
|
|
|
data->height = height;
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
bool is_singlelayer, is_multilayer, is_multiview;
|
|
|
|
|
|
2015-06-19 13:00:18 +02:00
|
|
|
for (echan = (ExrChannel *)data->channels.first; echan; echan = echan->next) {
|
|
|
|
|
header.channels().insert(echan->name,
|
|
|
|
|
Channel(echan->use_half_float ? Imf::HALF : Imf::FLOAT));
|
|
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2006-12-21 10:41:43 +00:00
|
|
|
openexr_header_compression(&header, compress);
|
2015-07-01 15:23:09 +02:00
|
|
|
BKE_stamp_info_callback(&header, const_cast<StampData *>(stamp), openexr_header_metadata_callback, false);
|
2007-01-24 15:03:20 +00:00
|
|
|
/* header.lineOrder() = DECREASING_Y; this crashes in windows for file read! */
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
imb_exr_type_by_channels(header.channels(), *data->multiView, &is_singlelayer, &is_multilayer, &is_multiview);
|
|
|
|
|
|
|
|
|
|
if (is_multilayer)
|
|
|
|
|
header.insert("BlenderMultiChannel", StringAttribute("Blender V2.55.1 and newer"));
|
|
|
|
|
|
|
|
|
|
if (is_multiview)
|
|
|
|
|
addMultiView(header, *data->multiView);
|
2011-08-30 23:08:38 +00:00
|
|
|
|
2012-03-18 07:38:51 +00:00
|
|
|
/* avoid crash/abort when we don't have permission to write here */
|
2012-08-24 12:10:35 +00:00
|
|
|
/* manually create ofstream, so we can handle utf-8 filepaths on windows */
|
2011-08-30 23:08:38 +00:00
|
|
|
try {
|
2012-08-24 14:04:21 +00:00
|
|
|
data->ofile_stream = new OFileStream(filename);
|
|
|
|
|
data->ofile = new OutputFile(*(data->ofile_stream), header);
|
2011-08-30 23:08:38 +00:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
catch (const std::exception& exc) {
|
2011-08-30 23:08:38 +00:00
|
|
|
std::cerr << "IMB_exr_begin_write: ERROR: " << exc.what() << std::endl;
|
2012-08-24 12:10:35 +00:00
|
|
|
|
|
|
|
|
delete data->ofile;
|
2012-08-24 14:04:21 +00:00
|
|
|
delete data->ofile_stream;
|
2012-08-24 12:10:35 +00:00
|
|
|
|
2011-08-30 23:08:38 +00:00
|
|
|
data->ofile = NULL;
|
2012-08-24 14:04:21 +00:00
|
|
|
data->ofile_stream = NULL;
|
2011-08-30 23:08:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (data->ofile != NULL);
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* only used for writing temp. render results (not image files)
|
|
|
|
|
* (FSA and Save Buffers) */
|
2010-11-16 14:40:46 +00:00
|
|
|
void IMB_exrtile_begin_write(void *handle, const char *filename, int mipmap, int width, int height, int tilex, int tiley)
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
{
|
2012-06-13 17:27:49 +00:00
|
|
|
ExrHandle *data = (ExrHandle *)handle;
|
|
|
|
|
Header header(width, height);
|
2015-04-06 10:40:12 -03:00
|
|
|
std::vector<Header> headers;
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
ExrChannel *echan;
|
2012-06-13 17:27:49 +00:00
|
|
|
|
|
|
|
|
data->tilex = tilex;
|
|
|
|
|
data->tiley = tiley;
|
|
|
|
|
data->width = width;
|
|
|
|
|
data->height = height;
|
|
|
|
|
data->mipmap = mipmap;
|
|
|
|
|
|
|
|
|
|
header.setTileDescription(TileDescription(tilex, tiley, (mipmap) ? MIPMAP_LEVELS : ONE_LEVEL));
|
2010-05-19 16:23:09 +00:00
|
|
|
header.compression() = RLE_COMPRESSION;
|
2015-04-06 10:40:12 -03:00
|
|
|
header.setType(TILEDIMAGE);
|
2012-06-13 17:27:49 +00:00
|
|
|
|
|
|
|
|
header.insert("BlenderMultiChannel", StringAttribute("Blender V2.43"));
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
int numparts = data->multiView->size();
|
|
|
|
|
|
|
|
|
|
/* copy header from all parts of input to our header array
|
|
|
|
|
* those temporary files have one part per view */
|
|
|
|
|
for (int i = 0; i < numparts; i++) {
|
|
|
|
|
headers.push_back (header);
|
|
|
|
|
headers[headers.size() - 1].setView((*(data->multiView))[i]);
|
|
|
|
|
headers[headers.size() - 1].setName((*(data->multiView))[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exr_printf("\nIMB_exrtile_begin_write\n");
|
|
|
|
|
exr_printf("%s %-6s %-22s \"%s\"\n", "p", "view", "name", "internal_name");
|
|
|
|
|
exr_printf("---------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
|
|
/* assign channels */
|
|
|
|
|
for (echan = (ExrChannel *)data->channels.first; echan; echan = echan->next) {
|
2015-06-19 13:00:18 +02:00
|
|
|
/* Tiles are expected to be saved with full float currently. */
|
|
|
|
|
BLI_assert(echan->use_half_float == 0);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
echan->m->internal_name = echan->m->name;
|
|
|
|
|
echan->m->part_number = echan->view_id;
|
|
|
|
|
|
|
|
|
|
headers[echan->view_id].channels().insert(echan->m->internal_name, Channel(Imf::FLOAT));
|
|
|
|
|
exr_printf("%d %-6s %-22s \"%s\"\n", echan->m->part_number, echan->m->view.c_str(), echan->m->name.c_str(), echan->m->internal_name.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-24 12:10:35 +00:00
|
|
|
/* avoid crash/abort when we don't have permission to write here */
|
|
|
|
|
/* manually create ofstream, so we can handle utf-8 filepaths on windows */
|
|
|
|
|
try {
|
2012-08-24 14:04:21 +00:00
|
|
|
data->ofile_stream = new OFileStream(filename);
|
2015-04-06 10:40:12 -03:00
|
|
|
data->mpofile = new MultiPartOutputFile(*(data->ofile_stream), &headers[0], headers.size());
|
2012-08-24 12:10:35 +00:00
|
|
|
}
|
2013-06-21 12:33:19 +00:00
|
|
|
catch (const std::exception &) {
|
2015-04-06 10:40:12 -03:00
|
|
|
delete data->mpofile;
|
2012-08-24 14:04:21 +00:00
|
|
|
delete data->ofile_stream;
|
2012-08-24 12:10:35 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
data->mpofile = NULL;
|
2012-08-24 14:04:21 +00:00
|
|
|
data->ofile_stream = NULL;
|
2012-08-24 12:10:35 +00:00
|
|
|
}
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
}
|
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* read from file */
|
2010-11-16 14:40:46 +00:00
|
|
|
int IMB_exr_begin_read(void *handle, const char *filename, int *width, int *height)
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
{
|
2012-06-13 17:27:49 +00:00
|
|
|
ExrHandle *data = (ExrHandle *)handle;
|
2015-04-06 10:40:12 -03:00
|
|
|
ExrChannel *echan;
|
2012-06-13 17:27:49 +00:00
|
|
|
|
|
|
|
|
if (BLI_exists(filename) && BLI_file_size(filename) > 32) { /* 32 is arbitrary, but zero length files crashes exr */
|
2012-08-24 12:10:35 +00:00
|
|
|
/* avoid crash/abort when we don't have permission to write here */
|
|
|
|
|
try {
|
2012-08-24 14:04:21 +00:00
|
|
|
data->ifile_stream = new IFileStream(filename);
|
2015-04-06 10:40:12 -03:00
|
|
|
data->ifile = new MultiPartInputFile(*(data->ifile_stream));
|
2012-08-24 12:10:35 +00:00
|
|
|
}
|
2013-06-21 12:33:19 +00:00
|
|
|
catch (const std::exception &) {
|
2012-08-24 12:10:35 +00:00
|
|
|
delete data->ifile;
|
2012-08-24 14:04:21 +00:00
|
|
|
delete data->ifile_stream;
|
2012-08-24 12:10:35 +00:00
|
|
|
|
|
|
|
|
data->ifile = NULL;
|
2012-08-24 14:04:21 +00:00
|
|
|
data->ifile_stream = NULL;
|
2012-08-24 12:10:35 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
if (data->ifile) {
|
2015-04-06 10:40:12 -03:00
|
|
|
Box2i dw = data->ifile->header(0).dataWindow();
|
2012-06-13 17:27:49 +00:00
|
|
|
data->width = *width = dw.max.x - dw.min.x + 1;
|
|
|
|
|
data->height = *height = dw.max.y - dw.min.y + 1;
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
imb_exr_get_views(*data->ifile, *data->multiView);
|
|
|
|
|
|
|
|
|
|
std::vector<MultiViewChannelName> channels;
|
|
|
|
|
GetChannelsInMultiPartFile(*data->ifile, channels);
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
for (size_t i = 0; i < channels.size(); i++) {
|
2015-06-19 13:00:18 +02:00
|
|
|
IMB_exr_add_channel(data, NULL, channels[i].name.c_str(), channels[i].view.c_str(), 0, 0, NULL, false);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
echan = (ExrChannel *)data->channels.last;
|
|
|
|
|
echan->m->name = channels[i].name;
|
|
|
|
|
echan->m->view = channels[i].view;
|
|
|
|
|
echan->m->part_number = channels[i].part_number;
|
|
|
|
|
echan->m->internal_name = channels[i].internal_name;
|
|
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
Memory saving for large renders:
New option "Save Buffers", in first Output panel of renderbuttons, will not
allocate all render buffers, but instead save the rendered tiles to exr.
For each scene rendered, a single exr file then is created.
After rendering, the files get read, and only then the memory allocation is
done.
The exr files are saved in the temp dir (from user settings), and have
names derived from the filename+scene name. That way these buffers remain
relatively unique, and can be re-used later too.
Saving all render-layers and passes in a single file (as F3 command) will
be done later. Also reading back the current muli-layer exr files is not
supported yet (will read black). The purpose is that these files then can
be used as input for the Compositor.
One fun thing I added; after rendering once with this option, close
Blender, and restart it. If you have a Composite set up press 'R' on an
active RenderResult node. This will refresh the node(s) and load the exr,
so you can composite again without a re-render.
2006-03-14 21:29:42 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
/* still clumsy name handling, layers/channels can be ordered as list in list later */
|
2015-04-06 10:40:12 -03:00
|
|
|
/* passname here is the raw channel name without the layer */
|
2010-12-03 17:05:21 +00:00
|
|
|
void IMB_exr_set_channel(void *handle, const char *layname, const char *passname, int xstride, int ystride, float *rect)
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
{
|
2012-06-13 17:27:49 +00:00
|
|
|
ExrHandle *data = (ExrHandle *)handle;
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
ExrChannel *echan;
|
2006-12-20 17:57:56 +00:00
|
|
|
char name[EXR_TOT_MAXNAME + 1];
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2017-05-16 12:40:04 +02:00
|
|
|
if (layname && layname[0] != '\0') {
|
2012-06-13 17:27:49 +00:00
|
|
|
char lay[EXR_LAY_MAXNAME + 1], pass[EXR_PASS_MAXNAME + 1];
|
2006-12-20 17:57:56 +00:00
|
|
|
BLI_strncpy(lay, layname, EXR_LAY_MAXNAME);
|
|
|
|
|
BLI_strncpy(pass, passname, EXR_PASS_MAXNAME);
|
2012-06-13 17:27:49 +00:00
|
|
|
|
|
|
|
|
BLI_snprintf(name, sizeof(name), "%s.%s", lay, pass);
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
}
|
2017-05-16 12:40:04 +02:00
|
|
|
else {
|
2012-06-13 17:27:49 +00:00
|
|
|
BLI_strncpy(name, passname, EXR_TOT_MAXNAME - 1);
|
2017-05-16 12:40:04 +02:00
|
|
|
}
|
2010-05-17 16:42:53 +00:00
|
|
|
|
2012-06-13 17:27:49 +00:00
|
|
|
echan = (ExrChannel *)BLI_findstring(&data->channels, name, offsetof(ExrChannel, name));
|
2010-05-17 16:42:53 +00:00
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
if (echan) {
|
2012-06-13 17:27:49 +00:00
|
|
|
echan->xstride = xstride;
|
|
|
|
|
echan->ystride = ystride;
|
|
|
|
|
echan->rect = rect;
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
}
|
2017-05-16 12:40:04 +02:00
|
|
|
else {
|
2015-04-06 10:40:12 -03:00
|
|
|
printf("IMB_exr_set_channel error %s\n", name);
|
2017-05-16 12:40:04 +02:00
|
|
|
}
|
2006-12-21 19:37:53 +00:00
|
|
|
}
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
float *IMB_exr_channel_rect(void *handle, const char *layname, const char *passname, const char *viewname)
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
{
|
2012-06-13 17:27:49 +00:00
|
|
|
ExrHandle *data = (ExrHandle *)handle;
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
ExrChannel *echan;
|
2015-04-06 10:40:12 -03:00
|
|
|
char name[EXR_TOT_MAXNAME + 1];
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (layname) {
|
|
|
|
|
char lay[EXR_LAY_MAXNAME + 1], pass[EXR_PASS_MAXNAME + 1];
|
|
|
|
|
BLI_strncpy(lay, layname, EXR_LAY_MAXNAME);
|
|
|
|
|
BLI_strncpy(pass, passname, EXR_PASS_MAXNAME);
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
BLI_snprintf(name, sizeof(name), "%s.%s", lay, pass);
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
else
|
|
|
|
|
BLI_strncpy(name, passname, EXR_TOT_MAXNAME - 1);
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* name has to be unique, thus it's a combination of layer, pass, view, and channel */
|
|
|
|
|
if (layname && layname[0] != '\0') {
|
2015-07-12 01:43:32 +10:00
|
|
|
char temp_buf[EXR_PASS_MAXNAME];
|
|
|
|
|
imb_exr_insert_view_name(temp_buf, name, viewname);
|
|
|
|
|
BLI_strncpy(name, temp_buf, sizeof(name));
|
2008-01-28 21:28:32 +00:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
else if (data->multiView->size() > 1) {
|
2015-10-24 01:01:10 +11:00
|
|
|
const int view_id = std::max(0, imb_exr_get_multiView_id(*data->multiView, viewname));
|
2015-04-06 10:40:12 -03:00
|
|
|
std::string raw_name = insertViewName(name, *data->multiView, view_id);
|
|
|
|
|
BLI_strncpy(name, raw_name.c_str(), sizeof(name));
|
2008-01-28 21:28:32 +00:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
echan = (ExrChannel *)BLI_findstring(&data->channels, name, offsetof(ExrChannel, name));
|
|
|
|
|
|
|
|
|
|
if (echan)
|
|
|
|
|
return echan->rect;
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IMB_exr_clear_channels(void *handle)
|
|
|
|
|
{
|
|
|
|
|
ExrHandle *data = (ExrHandle *)handle;
|
|
|
|
|
ExrChannel *chan;
|
|
|
|
|
|
|
|
|
|
for (chan = (ExrChannel *)data->channels.first; chan; chan = chan->next)
|
|
|
|
|
delete chan->m;
|
|
|
|
|
|
|
|
|
|
BLI_freelistN(&data->channels);
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
}
|
|
|
|
|
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
void IMB_exr_write_channels(void *handle)
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
{
|
2012-06-13 17:27:49 +00:00
|
|
|
ExrHandle *data = (ExrHandle *)handle;
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
FrameBuffer frameBuffer;
|
|
|
|
|
ExrChannel *echan;
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
if (data->channels.first) {
|
2015-06-19 13:00:18 +02:00
|
|
|
const size_t num_pixels = ((size_t)data->width) * data->height;
|
|
|
|
|
half *rect_half = NULL, *current_rect_half;
|
|
|
|
|
|
|
|
|
|
/* We allocate teporary storage for half pixels for all the channels at once. */
|
|
|
|
|
if (data->num_half_channels != 0) {
|
2015-06-24 05:13:43 +10:00
|
|
|
rect_half = (half *)MEM_mallocN(sizeof(half) * data->num_half_channels * num_pixels, __func__);
|
2015-06-19 13:00:18 +02:00
|
|
|
current_rect_half = rect_half;
|
|
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-06-19 13:00:18 +02:00
|
|
|
for (echan = (ExrChannel *)data->channels.first; echan; echan = echan->next) {
|
|
|
|
|
/* Writting starts from last scanline, stride negative. */
|
|
|
|
|
if (echan->use_half_float) {
|
|
|
|
|
float *rect = echan->rect;
|
|
|
|
|
half *cur = current_rect_half;
|
|
|
|
|
for (size_t i = 0; i < num_pixels; ++i, ++cur) {
|
|
|
|
|
*cur = rect[i * echan->xstride];
|
|
|
|
|
}
|
|
|
|
|
half *rect_to_write = current_rect_half + (data->height - 1) * data->width;
|
|
|
|
|
frameBuffer.insert(echan->name, Slice(Imf::HALF, (char *)rect_to_write,
|
|
|
|
|
sizeof(half), -data->width * sizeof(half)));
|
|
|
|
|
current_rect_half += num_pixels;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
float *rect = echan->rect + echan->xstride * (data->height - 1) * data->width;
|
|
|
|
|
frameBuffer.insert(echan->name, Slice(Imf::FLOAT, (char *)rect,
|
|
|
|
|
echan->xstride * sizeof(float), -echan->ystride * sizeof(float)));
|
|
|
|
|
}
|
2010-11-27 19:33:40 +00:00
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
|
|
|
|
data->ofile->setFrameBuffer(frameBuffer);
|
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
|
|
|
try {
|
2012-06-13 17:27:49 +00:00
|
|
|
data->ofile->writePixels(data->height);
|
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
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
catch (const std::exception& exc) {
|
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
|
|
|
std::cerr << "OpenEXR-writePixels: ERROR: " << exc.what() << std::endl;
|
|
|
|
|
}
|
2015-06-19 13:00:18 +02:00
|
|
|
/* Free temporary buffers. */
|
|
|
|
|
if (rect_half != NULL) {
|
|
|
|
|
MEM_freeN(rect_half);
|
|
|
|
|
}
|
2009-06-08 20:08:19 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
printf("Error: attempt to save MultiLayer without layers.\n");
|
|
|
|
|
}
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* temporary function, used for FSA and Save Buffers */
|
|
|
|
|
/* called once per tile * view */
|
|
|
|
|
void IMB_exrtile_write_channels(void *handle, int partx, int party, int level, const char *viewname)
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
{
|
2012-06-13 17:27:49 +00:00
|
|
|
ExrHandle *data = (ExrHandle *)handle;
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
FrameBuffer frameBuffer;
|
|
|
|
|
ExrChannel *echan;
|
2015-04-06 10:40:12 -03:00
|
|
|
std::string view(viewname);
|
2015-10-24 01:01:10 +11:00
|
|
|
const int view_id = imb_exr_get_multiView_id(*data->multiView, view);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
exr_printf("\nIMB_exrtile_write_channels(view: %s)\n", viewname);
|
|
|
|
|
exr_printf("%s %-6s %-22s \"%s\"\n", "p", "view", "name", "internal_name");
|
|
|
|
|
exr_printf("---------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
|
|
for (echan = (ExrChannel *)data->channels.first; echan; echan = echan->next) {
|
|
|
|
|
|
|
|
|
|
/* eventually we can make the parts' channels to include
|
|
|
|
|
only the current view TODO */
|
|
|
|
|
if (strcmp(viewname, echan->m->view.c_str()) != 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
exr_printf("%d %-6s %-22s \"%s\"\n",
|
|
|
|
|
echan->m->part_number,
|
|
|
|
|
echan->m->view.c_str(),
|
|
|
|
|
echan->m->name.c_str(),
|
|
|
|
|
echan->m->internal_name.c_str()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
float *rect = echan->rect - echan->xstride * partx - echan->ystride * party;
|
|
|
|
|
frameBuffer.insert(echan->m->internal_name,
|
|
|
|
|
Slice(Imf::FLOAT,
|
|
|
|
|
(char *)rect,
|
|
|
|
|
echan->xstride * sizeof(float),
|
|
|
|
|
echan->ystride * sizeof(float)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TiledOutputPart out (*data->mpofile, view_id);
|
|
|
|
|
out.setFrameBuffer(frameBuffer);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// printf("write tile %d %d\n", partx/data->tilex, party/data->tiley);
|
|
|
|
|
out.writeTile(partx / data->tilex, party / data->tiley, level);
|
|
|
|
|
}
|
|
|
|
|
catch (const std::exception& exc) {
|
|
|
|
|
std::cerr << "OpenEXR-writeTile: ERROR: " << exc.what() << std::endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* called only when handle has all views */
|
|
|
|
|
void IMB_exrmultiview_write_channels(void *handle, const char *viewname)
|
|
|
|
|
{
|
|
|
|
|
ExrHandle *data = (ExrHandle *)handle;
|
2015-10-24 01:01:10 +11:00
|
|
|
const int view_id = viewname ? imb_exr_get_multiView_id(*data->multiView, viewname) : -1;
|
2015-04-06 10:40:12 -03:00
|
|
|
int numparts = (view_id == -1 ? data->parts : view_id + 1);
|
|
|
|
|
std::vector <FrameBuffer> frameBuffers(numparts);
|
|
|
|
|
std::vector <OutputPart> outputParts;
|
|
|
|
|
ExrChannel *echan;
|
|
|
|
|
int i, part;
|
|
|
|
|
|
|
|
|
|
if (data->channels.first == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
exr_printf("\nIMB_exrmultiview_write_channels()\n");
|
|
|
|
|
|
|
|
|
|
for (echan = (ExrChannel *)data->channels.first; echan; echan = echan->next) {
|
|
|
|
|
if (view_id != -1 && echan->view_id != view_id)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
part = (view_id == -1 ? echan->m->part_number : echan->view_id);
|
|
|
|
|
|
|
|
|
|
/* last scanline, stride negative */
|
|
|
|
|
float *rect = echan->rect + echan->xstride * (data->height - 1) * data->width;
|
|
|
|
|
frameBuffers[part].insert(echan->m->internal_name,
|
|
|
|
|
Slice(Imf::FLOAT,
|
|
|
|
|
(char *)rect,
|
|
|
|
|
echan->xstride * sizeof(float),
|
|
|
|
|
-echan->ystride * sizeof(float))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < numparts; i++) {
|
|
|
|
|
OutputPart out(*data->mpofile, i);
|
|
|
|
|
out.setFrameBuffer(frameBuffers[i]);
|
|
|
|
|
outputParts.push_back(out);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
for (i = 0; i < numparts; i++) {
|
|
|
|
|
if (view_id != -1 && i != view_id)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
outputParts[i].writePixels(data->height);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const std::exception& exc) {
|
|
|
|
|
std::cerr << "OpenEXR-write Multi Part: ERROR: " << exc.what() << std::endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IMB_exr_read_channels(void *handle)
|
|
|
|
|
{
|
|
|
|
|
ExrHandle *data = (ExrHandle *)handle;
|
|
|
|
|
ExrChannel *echan;
|
|
|
|
|
int numparts = data->ifile->parts();
|
|
|
|
|
std::vector<FrameBuffer> frameBuffers(numparts);
|
|
|
|
|
std::vector<InputPart> inputParts;
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2010-11-27 19:33:40 +00:00
|
|
|
/* check if exr was saved with previous versions of blender which flipped images */
|
2015-04-06 10:40:12 -03:00
|
|
|
const StringAttribute *ta = data->ifile->header(0).findTypedAttribute <StringAttribute> ("BlenderMultiChannel");
|
2015-01-26 16:03:11 +01:00
|
|
|
short flip = (ta && STREQLEN(ta->value().c_str(), "Blender V2.43", 13)); /* 'previous multilayer attribute, flipped */
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
exr_printf("\nIMB_exr_read_channels\n%s %-6s %-22s \"%s\"\n---------------------------------------------------------------------\n", "p", "view", "name", "internal_name");
|
|
|
|
|
|
2012-06-13 17:27:49 +00:00
|
|
|
for (echan = (ExrChannel *)data->channels.first; echan; echan = echan->next) {
|
2015-04-06 10:40:12 -03:00
|
|
|
exr_printf("%d %-6s %-22s \"%s\"\n", echan->m->part_number, echan->m->view.c_str(), echan->m->name.c_str(), echan->m->internal_name.c_str());
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
if (echan->rect) {
|
|
|
|
|
if (flip)
|
2015-04-06 10:40:12 -03:00
|
|
|
frameBuffers[echan->m->part_number].insert(echan->m->internal_name, Slice(Imf::FLOAT, (char *)echan->rect,
|
2012-06-13 17:27:49 +00:00
|
|
|
echan->xstride * sizeof(float), echan->ystride * sizeof(float)));
|
2010-11-27 19:33:40 +00:00
|
|
|
else
|
2015-04-06 10:40:12 -03:00
|
|
|
frameBuffers[echan->m->part_number].insert(echan->m->internal_name, Slice(Imf::FLOAT, (char *)(echan->rect + echan->xstride * (data->height - 1) * data->width),
|
2012-06-13 17:27:49 +00:00
|
|
|
echan->xstride * sizeof(float), -echan->ystride * sizeof(float)));
|
2010-11-27 19:33:40 +00:00
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
else
|
2015-04-06 10:40:12 -03:00
|
|
|
printf("warning, channel with no rect set %s\n", echan->m->internal_name.c_str());
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
for (int i = 0; i < numparts; i++) {
|
|
|
|
|
InputPart in (*data->ifile, i);
|
|
|
|
|
in.setFrameBuffer(frameBuffers[i]);
|
|
|
|
|
inputParts.push_back(in);
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
try {
|
2015-04-06 10:40:12 -03:00
|
|
|
for (int i = 0; i < numparts; i++) {
|
|
|
|
|
Header header = inputParts[i].header();
|
|
|
|
|
exr_printf("readPixels:readPixels[%d]: min.y: %d, max.y: %d\n", i, header.dataWindow().min.y, header.dataWindow().max.y);
|
|
|
|
|
inputParts[i].readPixels(header.dataWindow().min.y, header.dataWindow().max.y);
|
|
|
|
|
inputParts[i].readPixels(0, data->height - 1);
|
|
|
|
|
}
|
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
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
catch (const std::exception& exc) {
|
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
|
|
|
std::cerr << "OpenEXR-readPixels: ERROR: " << exc.what() << std::endl;
|
|
|
|
|
}
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
}
|
|
|
|
|
|
2012-06-13 17:27:49 +00:00
|
|
|
void IMB_exr_multilayer_convert(void *handle, void *base,
|
2015-04-06 10:40:12 -03:00
|
|
|
void * (*addview)(void *base, const char *str),
|
2012-07-08 00:04:41 +00:00
|
|
|
void * (*addlayer)(void *base, const char *str),
|
|
|
|
|
void (*addpass)(void *base, void *lay, const char *str,
|
2015-04-06 10:40:12 -03:00
|
|
|
float *rect, int totchan, const char *chan_id,
|
|
|
|
|
const char *view))
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2012-06-13 17:27:49 +00:00
|
|
|
ExrHandle *data = (ExrHandle *)handle;
|
2006-12-20 17:57:56 +00:00
|
|
|
ExrLayer *lay;
|
|
|
|
|
ExrPass *pass;
|
|
|
|
|
|
2015-04-23 18:16:33 -03:00
|
|
|
/* RenderResult needs at least one RenderView */
|
|
|
|
|
if (data->multiView->size() == 0) {
|
|
|
|
|
addview(base, "");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* add views to RenderResult */
|
|
|
|
|
for (StringVector::const_iterator i = data->multiView->begin(); i != data->multiView->end(); ++i) {
|
|
|
|
|
addview(base, (*i).c_str());
|
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
2014-02-08 06:07:10 +11:00
|
|
|
if (BLI_listbase_is_empty(&data->layers)) {
|
2006-12-20 17:57:56 +00:00
|
|
|
printf("cannot convert multilayer, no layers in handle\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-13 17:27:49 +00:00
|
|
|
for (lay = (ExrLayer *)data->layers.first; lay; lay = lay->next) {
|
|
|
|
|
void *laybase = addlayer(base, lay->name);
|
2012-03-24 07:52:14 +00:00
|
|
|
if (laybase) {
|
2012-06-13 17:27:49 +00:00
|
|
|
for (pass = (ExrPass *)lay->passes.first; pass; pass = pass->next) {
|
2015-04-06 10:40:12 -03:00
|
|
|
addpass(base, laybase, pass->internal_name, pass->rect, pass->totchan, pass->chan_id, pass->view);
|
2012-06-13 17:27:49 +00:00
|
|
|
pass->rect = NULL;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
void IMB_exr_multiview_convert(void *handle, void *base,
|
|
|
|
|
void (*addview)(void *base, const char *str),
|
|
|
|
|
void (*addbuffer)(void *base, const char *str, ImBuf *ibuf, const int frame),
|
|
|
|
|
const int frame)
|
|
|
|
|
{
|
|
|
|
|
ExrHandle *data = (ExrHandle *)handle;
|
|
|
|
|
MultiPartInputFile *file = data->ifile;
|
|
|
|
|
ExrLayer *lay;
|
|
|
|
|
ExrPass *pass;
|
|
|
|
|
ImBuf *ibuf = NULL;
|
2015-04-20 23:37:04 +10:00
|
|
|
const bool is_alpha = exr_has_alpha(*file);
|
2015-04-06 10:40:12 -03:00
|
|
|
Box2i dw = file->header(0).dataWindow();
|
|
|
|
|
const size_t width = dw.max.x - dw.min.x + 1;
|
|
|
|
|
const size_t height = dw.max.y - dw.min.y + 1;
|
|
|
|
|
const bool is_depth = exr_has_zbuffer(*file);
|
|
|
|
|
|
|
|
|
|
/* add views to RenderResult */
|
|
|
|
|
for (StringVector::const_iterator i = data->multiView->begin(); i != data->multiView->end(); ++i) {
|
|
|
|
|
addview(base, (*i).c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (BLI_listbase_is_empty(&data->layers)) {
|
|
|
|
|
printf("cannot convert multiviews, no views in handle\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* there is one float/pass per layer (layer here is a view) */
|
|
|
|
|
BLI_assert(BLI_listbase_count_ex(&data->layers, 2) == 1);
|
|
|
|
|
lay = (ExrLayer *)data->layers.first;
|
|
|
|
|
for (pass = (ExrPass *)lay->passes.first; pass; pass = pass->next) {
|
|
|
|
|
if (STREQ(pass->chan_id, "RGB") || STREQ(pass->chan_id, "RGBA")) {
|
|
|
|
|
ibuf = IMB_allocImBuf(width, height, is_alpha ? 32 : 24, IB_rectfloat);
|
|
|
|
|
|
|
|
|
|
if (!ibuf) {
|
|
|
|
|
printf("error creating multiview buffer\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IMB_buffer_float_from_float(
|
|
|
|
|
ibuf->rect_float, pass->rect, pass->totchan,
|
|
|
|
|
IB_PROFILE_LINEAR_RGB, IB_PROFILE_LINEAR_RGB, false,
|
|
|
|
|
ibuf->x, ibuf->y, ibuf->x, ibuf->x);
|
|
|
|
|
|
|
|
|
|
if (hasXDensity(file->header(0))) {
|
|
|
|
|
ibuf->ppm[0] = xDensity(file->header(0)) * 39.3700787f;
|
|
|
|
|
ibuf->ppm[1] = ibuf->ppm[0] * (double)file->header(0).pixelAspectRatio();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_depth) {
|
|
|
|
|
ExrPass *zpass;
|
|
|
|
|
for (zpass = (ExrPass *)lay->passes.first; zpass; zpass = zpass->next) {
|
|
|
|
|
if (STREQ(zpass->chan_id, "Z") && STREQ(zpass->view, pass->view)) {
|
|
|
|
|
addzbuffloatImBuf(ibuf);
|
|
|
|
|
memcpy(ibuf->zbuf_float, zpass->rect, sizeof(float) * ibuf->x * ibuf->y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addbuffer(base, pass->view, ibuf, frame);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
Work in progress commit on saving OpenEXR with all render-layers and
passes in single file. Code is currently disabled, commit is mainly to
have a nicer method of excluding OpenEXR dependency from render module.
This should compile with disabled WITH_OPENEXR too.
Reason why EXR is great to include by default in Blender is its feature
to store unlimited layers and channels, and write this tile based. I
need the feature for saving memory; while rendering tiles, all full-size
buffers for all layers and passes are kept in memory now, which can go
into 100s of MB easily.
The code I commit now doesn't allocate these buffers while rendering, but
saves the tiles to disk. In the end is it read back. Overhead for large
renders (like 300 meg buffers) is 10-15 seconds, not bad.
Two more interesting aspects:
- Blender can save such multi-layer files in the temp directory, storing
it with .blend file name and scene name. That way, on each restart of Blender,
or on switching scenes, these buffers can be read. So you always see what was
rendered last. Also great for compositing work.
- This can also become an output image type for rendering. There's plenty of
cases where you want specific layers or passes saved to disk for later use.
Anyhoo, finishing it is another days of work, and I got more urgent stuff
now!
2006-02-23 20:57:31 +00:00
|
|
|
|
|
|
|
|
void IMB_exr_close(void *handle)
|
|
|
|
|
{
|
2012-06-13 17:27:49 +00:00
|
|
|
ExrHandle *data = (ExrHandle *)handle;
|
2006-12-20 17:57:56 +00:00
|
|
|
ExrLayer *lay;
|
|
|
|
|
ExrPass *pass;
|
2015-04-06 10:40:12 -03:00
|
|
|
ExrChannel *chan;
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2012-08-24 12:10:35 +00:00
|
|
|
delete data->ifile;
|
2012-08-24 14:04:21 +00:00
|
|
|
delete data->ifile_stream;
|
2012-08-24 12:10:35 +00:00
|
|
|
delete data->ofile;
|
2015-04-06 10:40:12 -03:00
|
|
|
delete data->mpofile;
|
2012-08-24 14:04:21 +00:00
|
|
|
delete data->ofile_stream;
|
2015-06-02 22:42:51 +05:00
|
|
|
delete data->multiView;
|
2012-06-13 17:27:49 +00:00
|
|
|
|
|
|
|
|
data->ifile = NULL;
|
2012-08-24 14:04:21 +00:00
|
|
|
data->ifile_stream = NULL;
|
2012-06-13 17:27:49 +00:00
|
|
|
data->ofile = NULL;
|
2015-04-06 10:40:12 -03:00
|
|
|
data->mpofile = NULL;
|
2012-08-24 14:04:21 +00:00
|
|
|
data->ofile_stream = NULL;
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
for (chan = (ExrChannel *)data->channels.first; chan; chan = chan->next) {
|
|
|
|
|
delete chan->m;
|
|
|
|
|
}
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
BLI_freelistN(&data->channels);
|
2012-06-13 17:27:49 +00:00
|
|
|
|
|
|
|
|
for (lay = (ExrLayer *)data->layers.first; lay; lay = lay->next) {
|
|
|
|
|
for (pass = (ExrPass *)lay->passes.first; pass; pass = pass->next)
|
2012-03-24 07:52:14 +00:00
|
|
|
if (pass->rect)
|
2006-12-20 17:57:56 +00:00
|
|
|
MEM_freeN(pass->rect);
|
|
|
|
|
BLI_freelistN(&lay->passes);
|
|
|
|
|
}
|
|
|
|
|
BLI_freelistN(&data->layers);
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
BLI_remlink(&exrhandles, data);
|
|
|
|
|
MEM_freeN(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ********* */
|
|
|
|
|
|
2012-05-11 08:06:01 +00:00
|
|
|
/* get a substring from the end of the name, separated by '.' */
|
2015-06-27 10:24:00 +02:00
|
|
|
static int imb_exr_split_token(const char *str, const char *end, const char **token)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2015-06-27 10:24:00 +02:00
|
|
|
const char delims[] = {'.', '\0'};
|
2015-06-27 11:00:47 +02:00
|
|
|
const char *sep;
|
2015-06-27 10:24:00 +02:00
|
|
|
|
2015-06-27 11:00:47 +02:00
|
|
|
BLI_str_partition_ex(str, end, delims, &sep, token, true);
|
2015-06-27 10:24:00 +02:00
|
|
|
|
|
|
|
|
if (!sep) {
|
|
|
|
|
*token = str;
|
2012-08-22 16:44:32 +00:00
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-06-27 10:24:00 +02:00
|
|
|
return (int)(end - *token);
|
2012-05-11 08:06:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *passname)
|
|
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
const char *name = echan->m->name.c_str();
|
2012-05-11 08:06:01 +00:00
|
|
|
const char *end = name + strlen(name);
|
|
|
|
|
const char *token;
|
|
|
|
|
char tokenbuf[EXR_TOT_MAXNAME];
|
|
|
|
|
int len;
|
2013-02-09 16:54:10 +00:00
|
|
|
|
|
|
|
|
/* some multilayers have the combined buffer with names A B G R saved */
|
|
|
|
|
if (name[1] == 0) {
|
|
|
|
|
echan->chan_id = name[0];
|
2013-03-12 10:34:14 +00:00
|
|
|
layname[0] = '\0';
|
2014-01-25 17:44:15 +01:00
|
|
|
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(name[0], 'R', 'G', 'B', 'A'))
|
2014-01-25 17:44:15 +01:00
|
|
|
strcpy(passname, "Combined");
|
|
|
|
|
else if (name[0] == 'Z')
|
|
|
|
|
strcpy(passname, "Depth");
|
|
|
|
|
else
|
|
|
|
|
strcpy(passname, name);
|
|
|
|
|
|
2013-02-09 16:54:10 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2012-05-11 08:06:01 +00:00
|
|
|
/* last token is single character channel identifier */
|
2015-06-27 10:24:00 +02:00
|
|
|
len = imb_exr_split_token(name, end, &token);
|
2012-05-11 08:06:01 +00:00
|
|
|
if (len == 0) {
|
|
|
|
|
printf("multilayer read: bad channel name: %s\n", name);
|
2006-12-20 17:57:56 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
2013-06-10 13:54:09 +00:00
|
|
|
else if (len == 1) {
|
|
|
|
|
echan->chan_id = token[0];
|
|
|
|
|
}
|
2012-05-11 08:06:01 +00:00
|
|
|
else if (len > 1) {
|
2013-06-10 13:54:09 +00:00
|
|
|
bool ok = false;
|
|
|
|
|
|
|
|
|
|
if (len == 2) {
|
|
|
|
|
/* some multilayers are using two-letter channels name,
|
|
|
|
|
* like, MX or NZ, which is basically has structure of
|
|
|
|
|
* <pass_prefix><component>
|
|
|
|
|
*
|
|
|
|
|
* This is a bit silly, but see file from [#35658].
|
|
|
|
|
*
|
|
|
|
|
* Here we do some magic to distinguish such cases.
|
|
|
|
|
*/
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(token[1], 'X', 'Y', 'Z') ||
|
|
|
|
|
ELEM(token[1], 'R', 'G', 'B') ||
|
|
|
|
|
ELEM(token[1], 'U', 'V', 'A'))
|
2013-06-10 13:54:09 +00:00
|
|
|
{
|
|
|
|
|
echan->chan_id = token[1];
|
|
|
|
|
ok = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ok == false) {
|
|
|
|
|
BLI_strncpy(tokenbuf, token, std::min(len + 1, EXR_TOT_MAXNAME));
|
|
|
|
|
printf("multilayer read: channel token too long: %s\n", tokenbuf);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
end -= len + 1; /* +1 to skip '.' separator */
|
|
|
|
|
|
2012-05-11 08:06:01 +00:00
|
|
|
/* second token is pass name */
|
2015-06-27 10:24:00 +02:00
|
|
|
len = imb_exr_split_token(name, end, &token);
|
2012-05-11 08:06:01 +00:00
|
|
|
if (len == 0) {
|
|
|
|
|
printf("multilayer read: bad channel name: %s\n", name);
|
2006-12-20 17:57:56 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
BLI_strncpy(passname, token, len + 1);
|
|
|
|
|
end -= len + 1; /* +1 to skip '.' separator */
|
|
|
|
|
|
2012-05-11 08:06:01 +00:00
|
|
|
/* all preceding tokens combined as layer name */
|
|
|
|
|
if (end > name)
|
2012-06-13 17:27:49 +00:00
|
|
|
BLI_strncpy(layname, name, (int)(end - name) + 1);
|
2012-05-11 08:06:01 +00:00
|
|
|
else
|
|
|
|
|
layname[0] = '\0';
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2006-12-20 21:34:20 +00:00
|
|
|
return 1;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ExrLayer *imb_exr_get_layer(ListBase *lb, char *layname)
|
|
|
|
|
{
|
2012-06-13 17:27:49 +00:00
|
|
|
ExrLayer *lay = (ExrLayer *)BLI_findstring(lb, layname, offsetof(ExrLayer, name));
|
2010-05-17 16:42:53 +00:00
|
|
|
|
2012-06-13 17:27:49 +00:00
|
|
|
if (lay == NULL) {
|
|
|
|
|
lay = (ExrLayer *)MEM_callocN(sizeof(ExrLayer), "exr layer");
|
2010-05-17 16:42:53 +00:00
|
|
|
BLI_addtail(lb, lay);
|
|
|
|
|
BLI_strncpy(lay->name, layname, EXR_LAY_MAXNAME);
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2010-05-17 16:42:53 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
return lay;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ExrPass *imb_exr_get_pass(ListBase *lb, char *passname)
|
|
|
|
|
{
|
2012-06-13 17:27:49 +00:00
|
|
|
ExrPass *pass = (ExrPass *)BLI_findstring(lb, passname, offsetof(ExrPass, name));
|
2010-05-17 16:42:53 +00:00
|
|
|
|
2012-06-13 17:27:49 +00:00
|
|
|
if (pass == NULL) {
|
|
|
|
|
pass = (ExrPass *)MEM_callocN(sizeof(ExrPass), "exr pass");
|
|
|
|
|
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(passname, "Combined"))
|
2010-05-17 16:42:53 +00:00
|
|
|
BLI_addhead(lb, pass);
|
|
|
|
|
else
|
|
|
|
|
BLI_addtail(lb, pass);
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLI_strncpy(pass->name, passname, EXR_LAY_MAXNAME);
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
return pass;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* creates channels, makes a hierarchy and assigns memory to channels */
|
2015-06-03 16:23:32 +10:00
|
|
|
static ExrHandle *imb_exr_begin_read_mem(IStream &file_stream, MultiPartInputFile &file, int width, int height)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
|
|
|
|
ExrLayer *lay;
|
|
|
|
|
ExrPass *pass;
|
|
|
|
|
ExrChannel *echan;
|
2012-06-13 17:27:49 +00:00
|
|
|
ExrHandle *data = (ExrHandle *)IMB_exr_get_handle();
|
2006-12-20 17:57:56 +00:00
|
|
|
int a;
|
|
|
|
|
char layname[EXR_TOT_MAXNAME], passname[EXR_TOT_MAXNAME];
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-06-03 16:23:32 +10:00
|
|
|
data->ifile_stream = &file_stream;
|
2015-04-06 10:40:12 -03:00
|
|
|
data->ifile = &file;
|
2015-06-03 16:23:32 +10:00
|
|
|
|
2012-06-13 17:27:49 +00:00
|
|
|
data->width = width;
|
|
|
|
|
data->height = height;
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
std::vector<MultiViewChannelName> channels;
|
|
|
|
|
GetChannelsInMultiPartFile(*data->ifile, channels);
|
2006-12-20 21:34:20 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
imb_exr_get_views(*data->ifile, *data->multiView);
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < channels.size(); i++) {
|
2015-06-19 13:00:18 +02:00
|
|
|
IMB_exr_add_channel(data, NULL, channels[i].name.c_str(), channels[i].view.c_str(), 0, 0, NULL, false);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
echan = (ExrChannel *)data->channels.last;
|
|
|
|
|
echan->m->name = channels[i].name;
|
|
|
|
|
echan->m->view = channels[i].view;
|
|
|
|
|
echan->m->part_number = channels[i].part_number;
|
|
|
|
|
echan->m->internal_name = channels[i].internal_name;
|
|
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* now try to sort out how to assign memory to the channels */
|
|
|
|
|
/* first build hierarchical layer list */
|
2012-06-13 17:27:49 +00:00
|
|
|
for (echan = (ExrChannel *)data->channels.first; echan; echan = echan->next) {
|
2015-04-06 10:40:12 -03:00
|
|
|
if (imb_exr_split_channel_name(echan, layname, passname)) {
|
|
|
|
|
|
|
|
|
|
const char *view = echan->m->view.c_str();
|
|
|
|
|
char internal_name[EXR_PASS_MAXNAME];
|
|
|
|
|
|
|
|
|
|
BLI_strncpy(internal_name, passname, EXR_PASS_MAXNAME);
|
|
|
|
|
|
|
|
|
|
if (view[0] != '\0') {
|
|
|
|
|
char tmp_pass[EXR_PASS_MAXNAME];
|
|
|
|
|
BLI_snprintf(tmp_pass, sizeof(tmp_pass), "%s.%s", passname, view);
|
|
|
|
|
BLI_strncpy(passname, tmp_pass, sizeof(passname));
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-13 17:27:49 +00:00
|
|
|
ExrLayer *lay = imb_exr_get_layer(&data->layers, layname);
|
|
|
|
|
ExrPass *pass = imb_exr_get_pass(&lay->passes, passname);
|
|
|
|
|
|
|
|
|
|
pass->chan[pass->totchan] = echan;
|
2006-12-20 17:57:56 +00:00
|
|
|
pass->totchan++;
|
2015-04-06 10:40:12 -03:00
|
|
|
pass->view_id = echan->view_id;
|
|
|
|
|
BLI_strncpy(pass->view, view, sizeof(pass->view));
|
|
|
|
|
BLI_strncpy(pass->internal_name, internal_name, EXR_PASS_MAXNAME);
|
|
|
|
|
|
2012-06-13 17:27:49 +00:00
|
|
|
if (pass->totchan >= EXR_PASS_MAXCHAN)
|
2006-12-20 17:57:56 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-24 07:52:14 +00:00
|
|
|
if (echan) {
|
2015-04-06 10:40:12 -03:00
|
|
|
printf("error, too many channels in one pass: %s\n", echan->m->name.c_str());
|
2006-12-20 17:57:56 +00:00
|
|
|
IMB_exr_close(data);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* with some heuristics, try to merge the channels in buffers */
|
2012-06-13 17:27:49 +00:00
|
|
|
for (lay = (ExrLayer *)data->layers.first; lay; lay = lay->next) {
|
|
|
|
|
for (pass = (ExrPass *)lay->passes.first; pass; pass = pass->next) {
|
2012-03-24 07:52:14 +00:00
|
|
|
if (pass->totchan) {
|
2012-06-13 17:27:49 +00:00
|
|
|
pass->rect = (float *)MEM_mapallocN(width * height * pass->totchan * sizeof(float), "pass rect");
|
|
|
|
|
if (pass->totchan == 1) {
|
|
|
|
|
echan = pass->chan[0];
|
|
|
|
|
echan->rect = pass->rect;
|
|
|
|
|
echan->xstride = 1;
|
|
|
|
|
echan->ystride = width;
|
|
|
|
|
pass->chan_id[0] = echan->chan_id;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
char lookup[256];
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
memset(lookup, 0, sizeof(lookup));
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* we can have RGB(A), XYZ(W), UVA */
|
2012-06-13 17:27:49 +00:00
|
|
|
if (pass->totchan == 3 || pass->totchan == 4) {
|
|
|
|
|
if (pass->chan[0]->chan_id == 'B' || pass->chan[1]->chan_id == 'B' || pass->chan[2]->chan_id == 'B') {
|
|
|
|
|
lookup[(unsigned int)'R'] = 0;
|
|
|
|
|
lookup[(unsigned int)'G'] = 1;
|
|
|
|
|
lookup[(unsigned int)'B'] = 2;
|
|
|
|
|
lookup[(unsigned int)'A'] = 3;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
else if (pass->chan[0]->chan_id == 'Y' || pass->chan[1]->chan_id == 'Y' || pass->chan[2]->chan_id == 'Y') {
|
|
|
|
|
lookup[(unsigned int)'X'] = 0;
|
|
|
|
|
lookup[(unsigned int)'Y'] = 1;
|
|
|
|
|
lookup[(unsigned int)'Z'] = 2;
|
|
|
|
|
lookup[(unsigned int)'W'] = 3;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-06-13 17:27:49 +00:00
|
|
|
lookup[(unsigned int)'U'] = 0;
|
|
|
|
|
lookup[(unsigned int)'V'] = 1;
|
|
|
|
|
lookup[(unsigned int)'A'] = 2;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
for (a = 0; a < pass->totchan; a++) {
|
|
|
|
|
echan = pass->chan[a];
|
|
|
|
|
echan->rect = pass->rect + lookup[(unsigned int)echan->chan_id];
|
|
|
|
|
echan->xstride = pass->totchan;
|
|
|
|
|
echan->ystride = width * pass->totchan;
|
|
|
|
|
pass->chan_id[(unsigned int)lookup[(unsigned int)echan->chan_id]] = echan->chan_id;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else { /* unknown */
|
2012-06-13 17:27:49 +00:00
|
|
|
for (a = 0; a < pass->totchan; a++) {
|
|
|
|
|
echan = pass->chan[a];
|
|
|
|
|
echan->rect = pass->rect + a;
|
|
|
|
|
echan->xstride = pass->totchan;
|
|
|
|
|
echan->ystride = width * pass->totchan;
|
|
|
|
|
pass->chan_id[a] = echan->chan_id;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
return data;
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ********************************************************* */
|
2006-01-09 19:17:37 +00:00
|
|
|
|
2008-07-09 10:51:03 +00:00
|
|
|
/* debug only */
|
2015-04-06 10:40:12 -03:00
|
|
|
static void exr_printf(const char *fmt, ...)
|
2006-01-09 19:17:37 +00:00
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
#if 0
|
|
|
|
|
char output[1024];
|
|
|
|
|
va_list args;
|
|
|
|
|
va_start(args, fmt);
|
|
|
|
|
std::vsprintf(output, fmt, args);
|
|
|
|
|
va_end(args);
|
|
|
|
|
printf("%s", output);
|
|
|
|
|
#else
|
|
|
|
|
(void)fmt;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static void exr_print_filecontents(MultiPartInputFile& file)
|
|
|
|
|
{
|
|
|
|
|
int numparts = file.parts();
|
|
|
|
|
if (numparts == 1 && hasMultiView(file.header(0))) {
|
|
|
|
|
const StringVector views = multiView(file.header(0));
|
|
|
|
|
printf("OpenEXR-load: MultiView file\n");
|
|
|
|
|
printf("OpenEXR-load: Default view: %s\n", defaultViewName(views).c_str());
|
|
|
|
|
for (StringVector::const_iterator i = views.begin(); i != views.end(); ++i) {
|
|
|
|
|
printf("OpenEXR-load: Found view %s\n", (*i).c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (numparts > 1) {
|
|
|
|
|
printf("OpenEXR-load: MultiPart file\n");
|
|
|
|
|
for (int i = 0; i < numparts; i++) {
|
|
|
|
|
if (file.header(i).hasView())
|
|
|
|
|
printf("OpenEXR-load: Part %d: view = \"%s\"\n", i, file.header(i).view().c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < numparts; j++) {
|
|
|
|
|
const ChannelList& channels = file.header(j).channels();
|
|
|
|
|
for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); ++i) {
|
|
|
|
|
const Channel& channel = i.channel();
|
|
|
|
|
printf("OpenEXR-load: Found channel %s of type %d\n", i.name(), channel.type);
|
|
|
|
|
}
|
2006-01-09 19:17:37 +00:00
|
|
|
}
|
2006-01-10 21:41:37 +00:00
|
|
|
}
|
2008-07-09 10:51:03 +00:00
|
|
|
|
|
|
|
|
/* for non-multilayer, map R G B A channel names to something that's in this file */
|
2015-04-06 10:40:12 -03:00
|
|
|
static const char *exr_rgba_channelname(MultiPartInputFile& file, const char *chan)
|
2008-07-09 10:51:03 +00:00
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
const ChannelList& channels = file.header(0).channels();
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); ++i) {
|
2009-06-08 20:08:19 +00:00
|
|
|
/* const Channel &channel = i.channel(); */ /* Not used yet */
|
2012-06-13 17:27:49 +00:00
|
|
|
const char *str = i.name();
|
|
|
|
|
int len = strlen(str);
|
2012-03-24 07:52:14 +00:00
|
|
|
if (len) {
|
2012-06-13 17:27:49 +00:00
|
|
|
if (BLI_strcasecmp(chan, str + len - 1) == 0) {
|
2008-07-09 10:51:03 +00:00
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return chan;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static bool exr_has_rgb(MultiPartInputFile& file)
|
2014-06-09 16:41:28 +06:00
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
return file.header(0).channels().findChannel("R") != NULL &&
|
|
|
|
|
file.header(0).channels().findChannel("G") != NULL &&
|
|
|
|
|
file.header(0).channels().findChannel("B") != NULL;
|
2014-06-09 16:41:28 +06:00
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static bool exr_has_luma(MultiPartInputFile& file)
|
2014-06-09 16:41:28 +06:00
|
|
|
{
|
|
|
|
|
/* Y channel is the luma and should always present fir luma space images,
|
|
|
|
|
* optionally it could be also channels for chromas called BY and RY.
|
|
|
|
|
*/
|
2015-04-06 10:40:12 -03:00
|
|
|
return file.header(0).channels().findChannel("Y") != NULL;
|
2014-06-09 16:41:28 +06:00
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static bool exr_has_chroma(MultiPartInputFile& file)
|
2014-06-09 16:41:28 +06:00
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
return file.header(0).channels().findChannel("BY") != NULL &&
|
|
|
|
|
file.header(0).channels().findChannel("RY") != NULL;
|
2014-06-09 16:41:28 +06:00
|
|
|
}
|
|
|
|
|
|
2015-04-20 23:37:04 +10:00
|
|
|
static bool exr_has_zbuffer(MultiPartInputFile& file)
|
2006-01-10 21:41:37 +00:00
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
return !(file.header(0).channels().findChannel("Z") == NULL);
|
2006-01-09 19:17:37 +00:00
|
|
|
}
|
2006-01-10 21:41:37 +00:00
|
|
|
|
2015-04-20 23:37:04 +10:00
|
|
|
static bool exr_has_alpha(MultiPartInputFile& file)
|
2012-06-14 12:05:38 +00:00
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
return !(file.header(0).channels().findChannel("A") == NULL);
|
2012-06-14 12:05:38 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static bool imb_exr_is_multilayer_file(MultiPartInputFile& file)
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
const StringAttribute *comments = file.header(0).findTypedAttribute<StringAttribute>("BlenderMultiChannel");
|
|
|
|
|
const ChannelList& channels = file.header(0).channels();
|
2012-04-03 11:53:38 +00:00
|
|
|
std::set <std::string> layerNames;
|
|
|
|
|
|
2013-03-22 09:18:35 +00:00
|
|
|
/* will not include empty layer names */
|
2012-04-03 11:53:38 +00:00
|
|
|
channels.layers(layerNames);
|
|
|
|
|
|
2012-06-13 17:27:49 +00:00
|
|
|
if (comments || layerNames.size() > 1)
|
2015-04-06 10:40:12 -03:00
|
|
|
return true;
|
2012-04-03 11:53:38 +00:00
|
|
|
|
2013-03-22 09:18:35 +00:00
|
|
|
if (layerNames.size()) {
|
|
|
|
|
/* if layerNames is not empty, it means at least one layer is non-empty,
|
|
|
|
|
* but it also could be layers without names in the file and such case
|
|
|
|
|
* shall be considered a multilayer exr
|
|
|
|
|
*
|
|
|
|
|
* that's what we do here: test whether there're empty layer names together
|
|
|
|
|
* with non-empty ones in the file
|
|
|
|
|
*/
|
|
|
|
|
for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); i++) {
|
|
|
|
|
std::string layerName = i.name();
|
|
|
|
|
size_t pos = layerName.rfind ('.');
|
|
|
|
|
|
|
|
|
|
if (pos == std::string::npos)
|
2015-04-06 10:40:12 -03:00
|
|
|
return true;
|
2013-03-22 09:18:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void imb_exr_type_by_channels(ChannelList& channels, StringVector& views,
|
|
|
|
|
bool *r_singlelayer, bool *r_multilayer, bool *r_multiview)
|
|
|
|
|
{
|
|
|
|
|
std::set <std::string> layerNames;
|
|
|
|
|
|
|
|
|
|
*r_singlelayer = true;
|
|
|
|
|
*r_multilayer = *r_multiview = false;
|
|
|
|
|
|
|
|
|
|
/* will not include empty layer names */
|
|
|
|
|
channels.layers(layerNames);
|
|
|
|
|
|
2015-10-28 13:41:01 -02:00
|
|
|
if (views.size() && views[0] != "") {
|
2015-04-06 10:40:12 -03:00
|
|
|
*r_multiview = true;
|
2015-10-28 13:41:01 -02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
*r_singlelayer = false;
|
|
|
|
|
*r_multilayer = true;
|
|
|
|
|
*r_multiview = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
if (layerNames.size()) {
|
|
|
|
|
/* if layerNames is not empty, it means at least one layer is non-empty,
|
|
|
|
|
* but it also could be layers without names in the file and such case
|
|
|
|
|
* shall be considered a multilayer exr
|
|
|
|
|
*
|
|
|
|
|
* that's what we do here: test whether there're empty layer names together
|
|
|
|
|
* with non-empty ones in the file
|
|
|
|
|
*/
|
|
|
|
|
for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); i++)
|
|
|
|
|
for (std::set<string>::iterator i = layerNames.begin(); i != layerNames.end(); i++)
|
|
|
|
|
/* see if any layername differs from a viewname */
|
|
|
|
|
if (imb_exr_get_multiView_id(views, *i) == -1) {
|
|
|
|
|
std::string layerName = *i;
|
|
|
|
|
size_t pos = layerName.rfind ('.');
|
|
|
|
|
|
2015-10-28 13:41:01 -02:00
|
|
|
if (pos == std::string::npos) {
|
2015-04-06 10:40:12 -03:00
|
|
|
*r_multilayer = true;
|
|
|
|
|
*r_singlelayer = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
*r_singlelayer = true;
|
|
|
|
|
*r_multilayer = false;
|
|
|
|
|
*r_multiview = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLI_assert(r_singlelayer != r_multilayer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IMB_exr_has_singlelayer_multiview(void *handle)
|
|
|
|
|
{
|
|
|
|
|
ExrHandle *data = (ExrHandle *)handle;
|
|
|
|
|
MultiPartInputFile *file = data->ifile;
|
|
|
|
|
std::set <std::string> layerNames;
|
|
|
|
|
const ChannelList& channels = file->header(0).channels();
|
|
|
|
|
const StringAttribute *comments;
|
|
|
|
|
|
|
|
|
|
if (exr_has_multiview(*file) == false)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
comments = file->header(0).findTypedAttribute<StringAttribute>("BlenderMultiChannel");
|
|
|
|
|
|
|
|
|
|
if (comments)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/* will not include empty layer names */
|
|
|
|
|
channels.layers(layerNames);
|
|
|
|
|
|
|
|
|
|
/* returns false if any layer differs from views list */
|
|
|
|
|
if (layerNames.size())
|
|
|
|
|
for (std::set<string>::iterator i = layerNames.begin(); i != layerNames.end(); i++)
|
|
|
|
|
if (imb_exr_get_multiView_id(*data->multiView, *i) == -1)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IMB_exr_has_multilayer(void *handle)
|
|
|
|
|
{
|
|
|
|
|
ExrHandle *data = (ExrHandle *)handle;
|
|
|
|
|
return imb_exr_is_multilayer_file(*data->ifile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool exr_has_multiview(MultiPartInputFile& file)
|
|
|
|
|
{
|
|
|
|
|
return hasMultiView(file.header(0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool exr_has_multipart_file(MultiPartInputFile& file)
|
|
|
|
|
{
|
|
|
|
|
return file.parts() > 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* it returns true if the file is multilayer or multiview */
|
|
|
|
|
static bool imb_exr_is_multi(MultiPartInputFile& file)
|
|
|
|
|
{
|
|
|
|
|
/* multipart files are treated as multilayer in blender - even if they are single layer openexr with multiview */
|
|
|
|
|
if (exr_has_multipart_file(file))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if (exr_has_multiview(file))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if (imb_exr_is_multilayer_file(file))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
Four-in-one commit:
(NOTE: new include dependency in Render module, might need MSVC update!
It has to include the imbuf/intern/openexr/ directory in search path)
-> New Composite node: "Hue Saturation".
Works like the former 'post process' menu. There's no gamma, brightness or
multiply needed in this node, for that the Curves Node functions better.
-> Enabled Toolbox in Node editor
This now also replaces the SHIFT+A for adding nodes. The nodes are
automatically added to the menus, using the 'class' category from the
type definition.
Current classes are (compositor examples):
Inputs: RenderResult, Image
Outputs: Composite, Viewer
Color Ops: RGB Curves, Mix, Hue Saturation, AlphaOver
Vector Ops: Normal, Vector Curves, Map Value
Filters: Filter, Blur, VectorBlur
Convertors: ColorRamp, RGBtoBW, Separate RGBA, Separate HSVA, Set Alpha
Generators: RGB, Value, Time
Groups: the list of custom defined nodes
-> OpenEXR tile saving support
Created an API for for saving tile-based Images with an unlimited amount
of layers/channels. I've tested it for 'render result' now, with the idea
that this can (optionally) replace the current inserting of tiles in the
main result buffers. Especially with a lot of layers, the used memory for
these buffers can easily go into the 100s of megs.
Two other advantages:
- all 'render result' layers can be saved entirely in a single file, for
later use in compositing, also for animation output.
- on each render, per scene, a unique temp file can be stored, allowing
to re-use these temp files on starting Blender or loading files, showing
the last result of a render command.
The option is currently disabled, needs more work... but I had to commit
this because of the rest of the work I did!
-> Bug fix
The Image node didn't call an execute event when browsing another image.
2006-02-18 13:28:44 +00:00
|
|
|
}
|
2006-01-10 21:41:37 +00:00
|
|
|
|
2015-07-11 23:52:18 +10:00
|
|
|
struct ImBuf *imb_load_openexr(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
|
2012-06-14 12:05:38 +00:00
|
|
|
{
|
2006-01-09 19:17:37 +00:00
|
|
|
struct ImBuf *ibuf = NULL;
|
2015-06-03 16:07:27 +10:00
|
|
|
Mem_IStream *membuf = NULL;
|
2015-04-06 10:40:12 -03:00
|
|
|
MultiPartInputFile *file = NULL;
|
2012-06-13 17:27:49 +00: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
|
|
|
if (imb_is_a_openexr(mem) == 0) return(NULL);
|
2012-06-13 17:27:49 +00: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
|
|
|
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_FLOAT);
|
|
|
|
|
|
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
|
|
|
try
|
|
|
|
|
{
|
2014-02-05 22:36:15 +11:00
|
|
|
bool is_multi;
|
2015-06-03 16:07:27 +10:00
|
|
|
|
2015-07-11 23:52:18 +10:00
|
|
|
membuf = new Mem_IStream((unsigned char *)mem, size);
|
2015-04-06 10:40:12 -03:00
|
|
|
file = new MultiPartInputFile(*membuf);
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
Box2i dw = file->header(0).dataWindow();
|
2012-06-14 12:05:38 +00:00
|
|
|
const int width = dw.max.x - dw.min.x + 1;
|
|
|
|
|
const int height = dw.max.y - dw.min.y + 1;
|
2012-06-13 17:27:49 +00:00
|
|
|
|
|
|
|
|
//printf("OpenEXR-load: image data window %d %d %d %d\n",
|
2006-01-11 10:41:04 +00:00
|
|
|
// dw.min.x, dw.min.y, dw.max.x, dw.max.y);
|
2006-01-09 19:17:37 +00:00
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
if (0) // debug
|
2015-04-06 10:40:12 -03:00
|
|
|
exr_print_filecontents(*file);
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
is_multi = imb_exr_is_multi(*file);
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* do not make an ibuf when */
|
2012-04-28 06:31:57 +00:00
|
|
|
if (is_multi && !(flags & IB_test) && !(flags & IB_multilayer)) {
|
2006-12-20 17:57:56 +00:00
|
|
|
printf("Error: can't process EXR multilayer file\n");
|
|
|
|
|
}
|
|
|
|
|
else {
|
2015-04-06 10:40:12 -03:00
|
|
|
const int is_alpha = exr_has_alpha(*file);
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2012-06-14 12:05:38 +00:00
|
|
|
ibuf = IMB_allocImBuf(width, height, is_alpha ? 32 : 24, 0);
|
2013-03-13 07:16:53 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (hasXDensity(file->header(0))) {
|
|
|
|
|
ibuf->ppm[0] = xDensity(file->header(0)) * 39.3700787f;
|
|
|
|
|
ibuf->ppm[1] = ibuf->ppm[0] * (double)file->header(0).pixelAspectRatio();
|
2013-03-13 07:16:53 +00:00
|
|
|
}
|
|
|
|
|
|
2015-07-13 13:58:17 +02:00
|
|
|
ibuf->ftype = IMB_FTYPE_OPENEXR;
|
2010-01-09 00:16:35 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (!(flags & IB_test)) {
|
2015-05-26 12:02:14 +02:00
|
|
|
|
|
|
|
|
if (flags & IB_metadata) {
|
|
|
|
|
const Header & header = file->header(0);
|
|
|
|
|
Header::ConstIterator iter;
|
|
|
|
|
|
|
|
|
|
for (iter = header.begin(); iter != header.end(); iter++) {
|
|
|
|
|
const StringAttribute *attrib = file->header(0).findTypedAttribute <StringAttribute> (iter.name());
|
|
|
|
|
|
|
|
|
|
/* not all attributes are string attributes so we might get some NULLs here */
|
|
|
|
|
if (attrib) {
|
|
|
|
|
IMB_metadata_add_field(ibuf, iter.name(), attrib->value().c_str());
|
|
|
|
|
ibuf->flags |= IB_metadata;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (is_multi && ((flags & IB_thumbnail) == 0)) { /* only enters with IB_multilayer flag set */
|
2006-12-20 17:57:56 +00:00
|
|
|
/* constructs channels for reading, allocates memory in channels */
|
2015-06-03 16:23:32 +10:00
|
|
|
ExrHandle *handle = imb_exr_begin_read_mem(*membuf, *file, width, height);
|
2012-03-24 07:52:14 +00:00
|
|
|
if (handle) {
|
2006-12-20 17:57:56 +00:00
|
|
|
IMB_exr_read_channels(handle);
|
2012-06-13 17:27:49 +00:00
|
|
|
ibuf->userdata = handle; /* potential danger, the caller has to check for this! */
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2015-04-06 10:40:12 -03:00
|
|
|
const bool has_rgb = exr_has_rgb(*file);
|
|
|
|
|
const bool has_luma = exr_has_luma(*file);
|
2006-12-20 17:57:56 +00:00
|
|
|
FrameBuffer frameBuffer;
|
|
|
|
|
float *first;
|
|
|
|
|
int xstride = sizeof(float) * 4;
|
2012-06-13 17:27:49 +00:00
|
|
|
int ystride = -xstride * width;
|
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
imb_addrectfloatImBuf(ibuf);
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* inverse correct first pixel for datawindow coordinates (- dw.min.y because of y flip) */
|
2012-06-13 17:27:49 +00:00
|
|
|
first = ibuf->rect_float - 4 * (dw.min.x - dw.min.y * width);
|
2006-12-20 17:57:56 +00:00
|
|
|
/* but, since we read y-flipped (negative y stride) we move to last scanline */
|
2012-06-13 17:27:49 +00:00
|
|
|
first += 4 * (height - 1) * width;
|
|
|
|
|
|
2014-06-09 16:41:28 +06:00
|
|
|
if (has_rgb) {
|
2015-04-06 10:40:12 -03:00
|
|
|
frameBuffer.insert(exr_rgba_channelname(*file, "R"),
|
2014-06-09 16:41:28 +06:00
|
|
|
Slice(Imf::FLOAT, (char *) first, xstride, ystride));
|
2015-04-06 10:40:12 -03:00
|
|
|
frameBuffer.insert(exr_rgba_channelname(*file, "G"),
|
2014-06-09 16:41:28 +06:00
|
|
|
Slice(Imf::FLOAT, (char *) (first + 1), xstride, ystride));
|
2015-04-06 10:40:12 -03:00
|
|
|
frameBuffer.insert(exr_rgba_channelname(*file, "B"),
|
2014-06-09 16:41:28 +06:00
|
|
|
Slice(Imf::FLOAT, (char *) (first + 2), xstride, ystride));
|
|
|
|
|
}
|
|
|
|
|
else if (has_luma) {
|
2015-04-06 10:40:12 -03:00
|
|
|
frameBuffer.insert(exr_rgba_channelname(*file, "Y"),
|
2014-06-09 16:41:28 +06:00
|
|
|
Slice(Imf::FLOAT, (char *) first, xstride, ystride));
|
2015-04-06 10:40:12 -03:00
|
|
|
frameBuffer.insert(exr_rgba_channelname(*file, "BY"),
|
2014-06-09 16:41:28 +06:00
|
|
|
Slice(Imf::FLOAT, (char *) (first + 1), xstride, ystride, 1, 1, 0.5f));
|
2015-04-06 10:40:12 -03:00
|
|
|
frameBuffer.insert(exr_rgba_channelname(*file, "RY"),
|
2014-06-09 16:41:28 +06:00
|
|
|
Slice(Imf::FLOAT, (char *) (first + 2), xstride, ystride, 1, 1, 0.5f));
|
|
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2012-11-12 07:33:01 +00:00
|
|
|
/* 1.0 is fill value, this still needs to be assigned even when (is_alpha == 0) */
|
2015-04-06 10:40:12 -03:00
|
|
|
frameBuffer.insert(exr_rgba_channelname(*file, "A"),
|
2012-06-14 12:05:38 +00:00
|
|
|
Slice(Imf::FLOAT, (char *) (first + 3), xstride, ystride, 1, 1, 1.0f));
|
2006-12-20 17:57:56 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (exr_has_zbuffer(*file)) {
|
2006-12-20 17:57:56 +00:00
|
|
|
float *firstz;
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
addzbuffloatImBuf(ibuf);
|
2012-06-13 17:27:49 +00:00
|
|
|
firstz = ibuf->zbuf_float - (dw.min.x - dw.min.y * width);
|
|
|
|
|
firstz += (height - 1) * width;
|
|
|
|
|
frameBuffer.insert("Z", Slice(Imf::FLOAT, (char *)firstz, sizeof(float), -width * sizeof(float)));
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
InputPart in (*file, 0);
|
|
|
|
|
in.setFrameBuffer(frameBuffer);
|
|
|
|
|
in.readPixels(dw.min.y, dw.max.y);
|
2010-07-12 13:35:00 +00:00
|
|
|
|
|
|
|
|
// XXX, ImBuf has no nice way to deal with this.
|
|
|
|
|
// ideally IM_rect would be used when the caller wants a rect BUT
|
|
|
|
|
// at the moment all functions use IM_rect.
|
|
|
|
|
// Disabling this is ok because all functions should check if a rect exists and create one on demand.
|
|
|
|
|
//
|
|
|
|
|
// Disabling this because the sequencer frees immediate.
|
|
|
|
|
//
|
2012-03-24 07:52:14 +00:00
|
|
|
// if (flag & IM_rect)
|
2010-07-12 13:35:00 +00:00
|
|
|
// IMB_rect_from_float(ibuf);
|
2012-06-13 17:27:49 +00:00
|
|
|
|
2014-06-09 16:41:28 +06:00
|
|
|
if (!has_rgb && has_luma) {
|
|
|
|
|
size_t a;
|
2015-04-06 10:40:12 -03:00
|
|
|
if (exr_has_chroma(*file)) {
|
2014-06-09 16:41:28 +06:00
|
|
|
for (a = 0; a < (size_t) ibuf->x * ibuf->y; ++a) {
|
|
|
|
|
float *color = ibuf->rect_float + a * 4;
|
|
|
|
|
ycc_to_rgb(color[0] * 255.0f, color[1] * 255.0f, color[2] * 255.0f,
|
|
|
|
|
&color[0], &color[1], &color[2],
|
|
|
|
|
BLI_YCC_ITU_BT709);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (a = 0; a < (size_t) ibuf->x * ibuf->y; ++a) {
|
|
|
|
|
float *color = ibuf->rect_float + a * 4;
|
|
|
|
|
color[1] = color[2] = color[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-29 11:59:29 +02:00
|
|
|
/* file is no longer needed */
|
|
|
|
|
delete membuf;
|
|
|
|
|
delete file;
|
2006-01-10 21:41:37 +00: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
|
|
|
}
|
2015-07-29 11:59:29 +02:00
|
|
|
else {
|
|
|
|
|
delete membuf;
|
|
|
|
|
delete file;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-31 13:52:13 +00:00
|
|
|
if (flags & IB_alphamode_detect)
|
|
|
|
|
ibuf->flags |= IB_alphamode_premul;
|
2006-01-09 19:17:37 +00: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
|
|
|
return(ibuf);
|
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
catch (const std::exception& exc)
|
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
|
|
|
{
|
|
|
|
|
std::cerr << exc.what() << std::endl;
|
|
|
|
|
if (ibuf) IMB_freeImBuf(ibuf);
|
2007-03-27 10:13:57 +00:00
|
|
|
delete file;
|
2015-06-03 16:07:27 +10:00
|
|
|
delete membuf;
|
2012-06-13 17:27:49 +00: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
|
|
|
return (0);
|
|
|
|
|
}
|
2012-06-13 17:27:49 +00: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
|
|
|
}
|
2006-01-09 10:55:41 +00:00
|
|
|
|
2012-04-02 11:04:24 +00:00
|
|
|
void imb_initopenexr(void)
|
|
|
|
|
{
|
|
|
|
|
int num_threads = BLI_system_thread_count();
|
|
|
|
|
|
|
|
|
|
setGlobalThreadCount(num_threads);
|
|
|
|
|
}
|
2006-01-09 10:55:41 +00: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
|
|
|
} // export "C"
|