Commit Graph

1971 Commits

Author SHA1 Message Date
Sebastian Parborg 6290ead143 Merge branch 'blender-v4.1-release' 2024-03-04 16:53:54 +01:00
Sebastian Parborg a8cc2e4d96 Fix: Add missing iostream include
Without this include compilation would sometimes fail
2024-03-04 16:50:47 +01:00
Habib Gahbiche 38b27a9ea9 Cleanup: Compositor: silence warning 'size' is deprecated
Decouple Node data from Operation. This avoids usage of deprecated members, e.g. through copying NodeKuwaharaData.

Pull Request: https://projects.blender.org/blender/blender/pulls/118971
2024-03-02 13:11:16 +01:00
Omar Emara bcb0d6ef9f Fix: Crash when using compositor debugger
Blender crashes when using the compositor debugger. That's because it
assumes the names of the operation classes will be demangled and will
proceed to slice them causing crashes. The standard makes no guarantees
about the form of the returned type_info::name, and it is implementation
defined.

While it is possible to demangle those names and return something that
is more human readable, it doesn't seem worth it as this is only used by
developers who should have no problem identifying mangled names. So we
just display the name as is.

Pull Request: https://projects.blender.org/blender/blender/pulls/118904
2024-03-01 08:45:39 +01:00
Omar Emara 1bff17cc99 Compositor: Unify plane anti-aliasing between CPU and GPU
This patch unifies the anti-aliasing of plane deforms between the CPU
and GPU compositors. The CPU used a multi-sample approach, where the
mask was computed 8 times with a jitter, then averaged to get smooth
edges. The GPU relied on the anisotropic filtering with zero boundaries
to smooth the edges.

Furthermore, the CPU implementation ignored the anti-aliasing for the
deformed image and also relied anisotropic filtering like the GPU, so
its outputs were different.

To unify both implementation, we use the existing SMAA anti-aliasing
algorithm instead, and use the anti-aliased mask for the image output as
well. This affects both the Corner Pin and Plane Deform nodes.

A consequence of this change for the Plane Deform node is that motion
blur will appear to have less samples, that's because it was sampled
8-times more in the previous implementation. But users can just increase
the samples in the node to account for that.

Pull Request: https://projects.blender.org/blender/blender/pulls/118853
2024-02-29 12:30:16 +01:00
Omar Emara 56f8c1c0f6 Compositor: Unify variable size blur between CPU and GPU
This patch unifies the variable size blur between the CPU and GPU
compositor. The difference is due to how weights are computed and used.
The CPU computed a nested array of weights for every possible size, that
is, from size 1 to the base size. Then, it assumed the kernel was
separable and reconstructed a 2D kernel by selecting two 1D weights
array and multiplying them for every pixel of the blur window.

The GPU on the other hand computes a single quadrant of the 2D weights
kernel and sampled it directly in the blur window. We favor the GPU
implementation since it makes no assumptions about the separability of
the weights kernel and since the CPU has no performance advantage even
with the assumption in place.

Pull Request: https://projects.blender.org/blender/blender/pulls/118834
2024-02-29 11:08:49 +01:00
Omar Emara aa17aca9ec Compositor: Use original variable size in Blur node
Currently, the CPU compositor smoothes its input size in variable size
mode. It is unclear why this is the case, but it seems the logic is that
sharp transitions in the size input are undesirable. Alternatively, this
is similar to the morphological blurring step in the Defocus node. But
it does not use standard weights and it is not morphological in nature
at all.

This patch removes the smoothing step and uses the original size
provided by the user. Looking at resources online, it seems users almost
always expect the size inputs to be used directly, so there is no reason
for force smooth their inputs.

Pull Request: https://projects.blender.org/blender/blender/pulls/118757
2024-02-29 10:57:18 +01:00
Habib Gahbiche 262d6fb14f Cleanup: Silence warning 'function overrides a member function but is not marked 'override''
Pull Request: https://projects.blender.org/blender/blender/pulls/118870
2024-02-28 22:37:33 +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 219d06689d Fix: Shader compile error on Metal
Shader compile error on Metal due to mixing between float and integer
types. Fix by manual casting.
2024-02-27 11:48:29 +02:00
Omar Emara b93d5d9c33 Merge branch 'blender-v4.1-release' 2024-02-27 11:43:09 +02:00
Omar Emara d88cdb3cf1 Fix: Crash when the input of Kuwahara is translated
Blender would crash if the input of the Classic Kuwahara node is
translated. This is due to an out of bound access due to the miss-use of
IndexRange, where it was assumed to have a start-end constructor, while
it was in fact a start-size one. Fix this by computing the size from the
area and supplying it to the constructor.
2024-02-27 11:37:35 +02:00
Omar Emara a7d4174f8b Compositor: Unify Keying node between CPU and GPU
This patch unifies the Keying node between the CPU and GPU. The
difference was due to imprecision when computing pixel saturation in the
CPU code. This typically happens when the pixel is gray-scale, and
should have a zero saturation, but it came out negative due to
imprecision. To fix this, reorder the mix expression so that the minimum
and maximum values are differenced first.

Ideally, the code shouldn't have such abrupt conditionals and should be
more robust to tiny imprecisions, but that would break the behavior and
should be evaluated separately.

Pull Request: https://projects.blender.org/blender/blender/pulls/118625
2024-02-27 10:09:16 +01:00
Omar Emara 3295123fca Fix: Variable sized blur truncates filter kernel
The GPU compositor Blur node truncates the filter kernel if the blur
radius is lower than the base radius. That's because it evaluated the
filter kernel only up to the desired radius. To fix this, we evaluate
at the entire kernel for all radii using a texture sampler for the
weights.
2024-02-27 11:03:15 +02:00
Omar Emara 43f45f3986 Merge branch 'blender-v4.1-release' 2024-02-26 16:29:28 +02:00
Omar Emara a2ca050087 Fix #118711: Crash in compositor with many nodes
The Viewport Compositors crashes when there are many nodes that are not
connected to the compositor or viewer outputs.

That's because those sockets were wrongly added to the shader operation,
even though they will not be used, which surpasses the limit for the
maximum image units per shader.
2024-02-26 16:24:38 +02:00
Campbell Barton d4aedd89d0 Cleanup: spelling in comments 2024-02-22 22:40:46 +11:00
Omar Emara 44778bdf41 Compositor: Unify Denoise node between CPU and GPU
The CPU compositor always adds a filter for normal and albedo even if
they don't contain any data, that is, when they are not connected to
anything, by inflating a buffer with the editor value, which is not even
accesible to the user. In anycase, such a solid color will not help do
anything in the denoise operation.

This patch aligns the implementation by only adding the abeldo and
normal filter if they contain actual data, speeding up the operation in
the process.

Pull Request: https://projects.blender.org/blender/blender/pulls/118553
2024-02-21 13:23:04 +01:00
Omar Emara c409f2f7c6 Compositor: Unify Blur operation across CPU and GPU
This patch unifies the implementation of the separable Blur operation
across CPU and GPU. The difference is due to the fact that the CPU code
ignores pixels that are across the image boundary and adjusts the
weights accordingly, while the GPU code assumes extended boundaries.

Like the rest of the Blur nodes the CPU implementation is adjusted to
assume extended boundaries until an option to change the boundary
condition is added. The alpha version of this operation will be handled
in a separate patch.

Pull Request: https://projects.blender.org/blender/blender/pulls/118517
2024-02-21 07:31:14 +01:00
Omar Emara 69920a0680 Compositor: Use original hue in Hue Correct node
Currently, the Hue Correct node uses the adjusted hue when adjusting the
saturation and value of the input, so if the user adjusted the reds to
become blue, in order to change the saturation of the same area, one
would need to adjust the blues, which would overlap with the existing
blues.

This is contrary to how other compositing software like GIMP and Natron
do it, and it is less intuitive. So this patch changes the node to use
the original hue to the saturation and value curves as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/118487
2024-02-21 07:19:13 +01:00
Omar Emara 81867f938c Fix: GPU Hue Correct node is slightly off
The GPU Hue Correct node is slightly off due to incorrect interpolation
of curve maps. We fix this by introducing proper half-pixel offsets to
the curve map coordinates much like we do for other curve map evaluation
shaders.
2024-02-20 09:47:17 +02:00
Brecht Van Lommel 0f2064bc3b Revert changes from main commits that were merged into blender-v4.1-release
The last good commit was 4bf6a2e564.
2024-02-19 15:59:59 +01:00
Iliya Katueshenock 9e12a675b5 Cleanup: Merge BKE_node.h into BKE_node.hh
Trivial change, just move all the code from `BKE_node.h` to `BKE_node.hh` header top.
No mixing code from different headers or namespace changes. Part of #117773

Pull Request: https://projects.blender.org/blender/blender/pulls/118407
2024-02-19 15:26:10 +01:00
Omar Emara 9ab72eae38 Compositor: Unify Texture node between CPU and GPU
The CPU and GPU implementations of the compositor Texture node sample
the texture at different locations, producing differences. This is
primarly an issue with half pixel offsets to evaluate the texture at the
center of the pixels.

The CPU compositor only adds the offsets if interpolation is disabled,
regardless if the texture is of type image or not. Further the offset
was wrong, since it was not a half pixel offset, but a full pixel one.

The offsets should always be added, since it won't make a difference in
the non interpolated case, and it should always be added especially if
interpolation is enabled. A comment in the old code mentions something
about artifacts, but it is possible that this is a consequence of the
wrong offset that was used.

This patch always adds a half pixel offset, following the GPU code.

Pull Request: https://projects.blender.org/blender/blender/pulls/118377
2024-02-16 16:21:48 +01:00
Omar Emara 0906201a4c Compositor: Fallback to a black color for invalid outputs
Currently, some compositor operations produce en empty output buffer by
specifying a COM_AREA_NONE canvas to indicate an invalid output, for
instance, when the Mask operation references an invalid mask. The
intention is that this buffer would signal that a fallback value should
fill the canvas of consumer operations.

The aforementioned behavior is currently implemented in a rather hacky
way, where it is implemented using the Translate operation as part of
canvas conversion in COM_convert_canvas, where the operation would clear
the entire buffer with zeros since out of bounds checking would always
take the out of bound case due to the empty buffer.

This behavior is problematic because we can't control the fallback
value, which would ideally be an opaque black color. Moreover, since
implicit type conversion happen before canvas conversion by design,
value typed buffers would eventually become transparent, which is rather
unexpected to the end user since float/value outputs can't have
transparency.

This is not a good design or implementation, but a redesign will be too
complex for now. So to fix this, we workaround it by handling the empty
buffer case explicitly in the Translate operation and fill the output
using a fallback black color, which works for both value and color typed
buffers, since this would also be the output of the value to color
implicit conversion.

Pull Request: https://projects.blender.org/blender/blender/pulls/118340
2024-02-16 15:32:59 +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
Omar Emara e7ffe74920 Realtime Compositor: Support canceling evaluation
This patch adds support for canceling compositor evaluations for the
realtime compositor. Only the canceling of the Denoise operation is
supported for now. That's because inter-operation canceling is not
feasible since all work will have been submitted to the GPU driver
before the user is able to cancel. So some kind of blocking operations
would need to used to actually allow canceling, which is not something
we are going to investigate as part of this patch.

Pull Request: https://projects.blender.org/blender/blender/pulls/117725
2024-02-16 08:32:03 +01:00
Jacques Lucke d803b6acca Cleanup: simplify usage of Map 2024-02-15 22:51:18 +01:00
Omar Emara 49faea5f36 Fix #111345: Compositor uses entire viewport in camera view
The compositor assumes the entire viewport as its compositing space even
in camera view. The current design decision was to limit the compositing
space by the camera region only if the camera passepartout is opaque,
that is, areas outside of the camera are not visible.

This patch changes that behavior to always limit the compositing space
by the camera region. The downside is that areas outside of the camera
will be left uncomposited.

This is useful to match viewport compositing to final render compositing
in terms of maintaining the same space, but not necessarily the same
resolution. However, this still has the limitation that space will be
different when the camera region intersects the viewport, since we only
composite their intersection in that case.

Pull Request: https://projects.blender.org/blender/blender/pulls/118241
2024-02-15 15:46:34 +01:00
Campbell Barton 5c87dfd269 Cleanup: use BLI_time_ prefix for time functions
Also use the term "now" instead of "check" for clarity.
2024-02-15 13:15:56 +11:00
Hans Goudey 61e61ce0e1 Cleanup: Use Span instead of Vector const reference
Span is preferrable since it's agnostic of the source container,
makes it clearer that there is no ownership, is 8 bytes smaller,
and can be passed by value.
2024-02-14 17:23:01 -05:00
Omar Emara 357d6fcae1 Cleanup: Format 2024-02-14 16:50:20 +02:00
Brecht Van Lommel aefd930317 Fix: Build error when not using unity build 2024-02-14 15:13:12 +01:00
Sergey Sharybin a8a05ebba1 Compositor: Switch CPU compositor to Full-Frame
The tiled compositor code is mainly still around, which is only
expected to be a short-lived period. Eventually it will also be
removed.

The OpenCL, Group Buffers, and Chunk size options are already removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/118010
2024-02-14 14:23:49 +01:00
Sergey Sharybin 2cec7e3aa5 Fix levels node regression in tiled compositor
Caused by previous change for full-frame compositor.

The determine_canvas() is still used by the tiled compositor,
so restore it to the state which makes both compositors to work.

Pull Request: https://projects.blender.org/blender/blender/pulls/118254
2024-02-14 12:02:59 +01:00
Sergey Sharybin a1047e0689 Compositor: Make CPU Level node output single value
This aligns the node behavior to GPU compositor.

The implementation is a bit of a stretch of the full-frame
constant-foldable operations, but this is as good as it can
get in a short time.

The alternative could be to somehow inject a SetValue
operation, but since it expects ahead-of-time known value it
is not as straight forward.

Pull Request: https://projects.blender.org/blender/blender/pulls/118248
2024-02-14 10:54:59 +01:00
Omar Emara 8b46fdeab8 Fix: Translate node crashes for single inputs
The Translate node crashed for single inputs in the Full Frame
compositor, that's because it always assumed image inputs. So fix this
by handling the single value case.
2024-02-13 17:45:28 +02:00
Campbell Barton e6cb2ca380 Cleanup: unused includes in source/blender/compositor
Remove 5 inclues.
2024-02-13 19:21:03 +11:00
Omar Emara 98c0802ab0 Merge branch 'blender-v4.1-release' 2024-02-12 17:01:33 +02:00
Omar Emara 50d7f5a30f Fix #118096: Compositor Displace node produce NaN pixels
The GPU compositor Displace node produces NaN pixels if connected to the
Image node. That's because the Displace node access the MIP levels of
the texture produces by the Image node, but those levels were never
initialized, so fix this by completing the levels.
2024-02-12 16:58:23 +02:00
Bastien Montagne 5aaadebbe4 Cleanup: Make `BKE_scene.h` a full Cpp header. 2024-02-10 19:16:25 +01:00
Bastien Montagne 29fe777445 Cleanup: Make `BKE_report.h` a full Cpp header. 2024-02-10 18:34:29 +01:00
Bastien Montagne 54618dbae3 Cleanup: Make `BKE_global.h` a Cpp header. 2024-02-10 18:25:14 +01:00
Campbell Barton 3dbbc013de Cleanup: spelling in comments 2024-02-10 22:35:35 +11:00
Thomas Dinges eaeaf8322c BLI: Bump SSE check from 4.1 to 4.2
This will be the new minimum for Blender 4.2, so check for the SSE4.2 flag and update the function name.

Pull Request: https://projects.blender.org/blender/blender/pulls/118058
2024-02-09 20:28:46 +01:00
Bastien Montagne 45e7827898 Clenup: Move BLT headers to Cpp.
Noisy but fairly straight forward.
2024-02-09 18:59:42 +01:00
Omar Emara 9743d6992c Compositor: Unify Variable Size Bokeh Blur node
This patch adjusts the Variable Size Bokeh Blur node such that it
matches between CPU and GPU. The GPU implementation is mostly followed
for the reasons stated below.

The first difference is a bug in the CPU implementation, where the upper
limit of the blur window is not considered, but the lower limit is.

The second difference is due to CPU ignoring outside pixels instead of
clamping them to border, which is done until an option is added to the
node to control the boundary condition.

The third difference is due to CPU ignoring the bounding box input.

The fourth difference is that CPU doesn't allow zero maximum blur
radius, which is a valid option.

The fifth difference is that the threshold option, which is only used
for the Defocus node, was considered in a greater than manner, while it
should be greater than or equal. Since the default threshold of one
should allow a blur size of one.

The GPU implementation now considers the maximum size of its input,
following the CPU implementation.

Pull Request: https://projects.blender.org/blender/blender/pulls/117947
2024-02-09 11:52:41 +01:00
Sergey Sharybin aa051f788d Cleanup: New line at the end of file
Pull Request: https://projects.blender.org/blender/blender/pulls/118032
2024-02-09 11:08:16 +01:00
Omar Emara e20b2d2fb9 Merge branch 'blender-v4.1-release' 2024-02-09 11:37:43 +02:00