Commit Graph

17 Commits

Author SHA1 Message Date
Omar Emara
db490e90fe Fix #127392: File Output doesn't write empty inputs
The File Output node doesn't write invalid and single value layers,
which can cause differences in EXR structures when rendering animations.

To fix this, we write a dummy image that has the same dimensions as the
other layers in the file, filled with the value of the single value
input.

Pull Request: https://projects.blender.org/blender/blender/pulls/128454
2024-10-02 10:28:55 +02:00
Campbell Barton
381898b6dc Refactor: move BLI_path_util header to C++, rename to BLI_path_utils
Move to a C++ header to allow C++ features to be used there,
use the "utils" suffix as it's preferred for new files.

Ref !128147
2024-09-26 21:13:39 +10:00
Campbell Barton
2ef76b89e4 Cleanup: remove duplicate code-comments 2024-08-23 10:19:53 +10:00
Omar Emara
9c44349204 Fix #124023: File output always saves PNG in sRGB
The File Output node doesn't provide an option to save byte formats like
PNG in a space that is not sRGB. This is problematic for data images
like normal maps, which need to be saved as non-color.

This patch adds a Color Space option to the File Output node to allows
users to override the assumed color space. This also adds a new global
Save As Render option that is used if Use Node Format is enabled.

Pull Request: https://projects.blender.org/blender/blender/pulls/124238
2024-08-02 13:52:22 +02:00
Omar Emara
970ec097e3 Cleanup: Fix missing declaration warning 2024-07-15 11:42:35 +03:00
Omar Emara
308b53746b Fix #101263: Vector pass wrongly saved in File Output
The vector pass and potentially other vectors that store 4 values are
stored wrongly, in particular, the last channel is ignored. To fix this
we identify if a vector pass is 4D and store the information in the
result meta data, then use this information to either save a 3D or a 4D
pass in the File Output node.

This is a CPU implementation of the same mechanism in the GPU compositor
implemented in 57a6832b17. The CPU implementation is a bit more complex
because the CPU compositors stores 4D vectors in color images internally
which can lead to information loss in case of implicit conversion when
the File Output has vector sockets. So what we do is force all vector
inputs to the File Output operation to be color, then save that as 3D or
4D depending on the meta data as well as the original UI socket type.

Pull Request: https://projects.blender.org/blender/blender/pulls/124580
2024-07-12 12:53:16 +02:00
Omar Emara
d14ad05078 Fix #124208: Cryptomatte are compressed in File Output
The Cryptomatte layers in the compositor are saved compressed and saved
in half precision in the File Output node. That's because the EXR writer
makes decision about compression and half float based on channel names.
And Cryptomatte are currently saved using RGBA channel names like other
color images.

To fix this, we follow the Cycles convention of using lowercase rgba for
Cryptomatte images, allowing them to be saved without compression and
always in full precision since they are otherwise useless.

Fixes #124208, #87988.

Pull Request: https://projects.blender.org/blender/blender/pulls/124508
2024-07-11 12:47:58 +02:00
Omar Emara
1e359f4173 Fix #112742: File output node ignores colorspace overrides
The File Output node ignores color space overrides for EXR images. To
fix this, we save the images using save_as_render set to true. We don't
need to provide this as an option similar to other image types because
even when save_as_render is set to true, it will not have an effect
unless the user chooses to override the color space explicitly, since it
is not affected by view transforms and the like.

Pull Request: https://projects.blender.org/blender/blender/pulls/122791
2024-06-07 17:38:18 +02:00
Omar Emara
79da892126 Fix #122587: File Output node can only save one size
The File Output node forces all inputs to have the same size, which
should only be the case for multilayer files. This is a regression in
931c188ce5. To fix this, we allow inputs to have any size, except for
multilayer files, which are realized on the automatic operation domain
of the operation.

Pull Request: https://projects.blender.org/blender/blender/pulls/122824
2024-06-07 17:34:14 +02:00
Campbell Barton
019d3ef939 Cleanup: spelling in comments 2024-04-24 10:48:45 +10:00
Omar Emara
dd321a47a6 Fix #120715: File Output node writes empty outputs
The File Output node writes single elements as full images in 4.1, while
such values were skipped in 4.0. This included invalid outputs, for
instance, when the Render Layers node does not have a result for the
selected view layer. Which would then just write an image with an
arbitrary color.

To fix this, we detect single element values and skip writing file
outputs for them.

Pull Request: https://projects.blender.org/blender/blender/pulls/120749
2024-04-19 12:38:31 +02:00
Omar Emara
ac7309f95e Compositor: Add Float2 data type
This patch adds the Float2 data type to the MemoryBuffer class.

Needed by #119414.

Pull Request: https://projects.blender.org/blender/blender/pulls/119738
2024-03-22 08:51:24 +01:00
Aras Pranckevicius
f5f7024040 Cleanup: Remove now-unused "tiled" compositor implementation
New ("fullframe") CPU compositor backend is being used now, and all the code
related to "tiled" CPU compositor is just never used anymore. The new backend
is faster, uses less memory, better matches GPU compositor, etc.

TL;DR: 20 thousand lines of code gone.

This commit:
- Removes various bits and pieces related to "tiled" compositor (execution
  groups, one-pixel-at-a-time node processing, read/write buffer operations
  related to node execution groups).
- "GPU" (OpenCL) execution device, that was only used by several nodes of
  the tiled compositor.
  - With that, remove CLEW external library too, since nothing within Blender
    uses OpenCL directly anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/118819
2024-02-28 16:59:16 +01:00
Omar Emara
f590b36e62 Merge branch 'blender-v4.1-release' 2024-02-16 10:55:29 +02:00
Omar Emara
1cae3d60e6 Fix #118344: Crash when File Output node has no input
The File Output node crashes if it has no image input. That's because we
would be attempting to save a zero sized image. So ensure that the node
has a non zero canvas before saving anything.
2024-02-16 10:51:36 +02:00
Bastien Montagne
5aaadebbe4 Cleanup: Make BKE_scene.h a full Cpp header. 2024-02-10 19:16:25 +01:00
Omar Emara
931c188ce5 Compositor: Refactor File Output node
This patches refactors the compositor File Output mechanism and
implements the file output node for the Realtime Compositor. The
refactor was done for the following reasons:

1. The existing file output mechanism relied on a global EXR image
   resource where the result of each compositor execution for each
   view was accumulated and stored in the global resource, until the
   last view is executed, when the EXR is finally saved. Aside from
   relying on global resources, this can cause effective memory leaks
   since the compositor can be interrupted before the EXR is written and
   closed.
2. We need common code to share between all compositors since we now
   have multiple compositor implementations.
3. We needed to take the opportunity to fix some of the issues with the
   existing implementation, like lossy compression of data passes,
   and inability to save single values passes.

The refactor first introduced a new structure called the Compositor
Render Context. This context stores compositor information related to
the render pipeline and is persistent across all compositor executions
of all views. Its extended lifetime relative to a single compositor
execution lends itself well to store data that is accumulated across
views. The context currently has a map of File Output objects. Those
objects wrap a Render Result structure and can be used to construct
multi-view images which can then be saved after all views are executed
using the existing BKE_image_render_write function.

Minor adjustments were made to the BKE and RE modules to allow saving
using the BKE_image_render_write function. Namely, the function now
allows the use of a source image format for saving as well as the
ability to not save the render result as a render by introducing two new
default arguments. Further, for multi-layer EXR saving, the existent of
a single unnamed render layer will omit the layer name from the EXR
channel full name, and only the pass, view, and channel ID will remain.
Finally, the Render Result to Image Buffer conversion now take he number
of channels into account, instead of always assuming color channels.

The patch implements the File Output node in the Realtime Compositor
using the aforementioned mechanisms, replaces the implementation of the
CPU compositor using the same Realtime Compositor implementation, and
setup the necessary logic in the render pipeline code.

Pull Request: https://projects.blender.org/blender/blender/pulls/113982
2023-12-13 11:08:03 +01:00