Commit Graph

1792 Commits

Author SHA1 Message Date
Campbell Barton
e86fbcd4f0 Merge branch 'blender-v4.0-release' 2023-10-13 10:31:44 +11:00
Campbell Barton
fb58aa5900 Cleanup: typos, duplicate words 2023-10-13 10:21:06 +11:00
Omar Emara
444241fbcf Fix: GPU Compositor rotation transposes the image
The image is transposed when rotated in the GPU compositor. This was a
typo in the rotation bounding box equation, which is fixed in this
patch.
2023-10-12 15:22:22 +03:00
Omar Emara
405ec79a0a Fix #112883: GPU compositor crops viewed image
The GPU compositor crops the viewed images to the render resolution.
While the original size and content of the input to the viewer should be
retained as is.

This patch fixes that by specializing compositors that can use composite
outputs to be able to view images of any arbitrary size. This is still
missing the translation offset of the viewer, but this shall be tackled
separately.
2023-10-12 14:03:12 +03:00
Omar Emara
e592763940 Realtime Compositor: Immediately realize transformations
This patch immediately realizes the scale and rotation components of
transformations at the point of transform nodes. The translate component is
still delayed and only realized when really needed to avoid clipping.

Transformed results are always realized in an expanded domain that avoids
clipping due to rotation or scaling. The size of the transformed domain is
clipped to the GPU texture size limit for now until we have support for huge
textures, that limit is typically 16k.

A potential optimization is to join all consecutive transform and realize
operations into a single realize operation.

Fixes #112332.

Pull Request: https://projects.blender.org/blender/blender/pulls/112332
2023-10-12 11:04:50 +02:00
Omar Emara
203559757a Compositor: Allow variable size Kuwahara
This patch changes the size property of the Kuwahara into a node socket
to allow variable size Kuwahara.

Pull Request: https://projects.blender.org/blender/blender/pulls/112946
2023-10-10 10:10:18 +02:00
Jesse Yurkovich
d47ceb53f8 Cleanup: Replace usage of old BLI_array macros with C++ types
This replaces the older dynamic c arrays with blender::Vector as
appropriate. Many files required minimal changes and the before/after
are quite similar.

There's 3 remaining usages of the old machinery but those will require
more involved changes and design.

See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/110981
2023-10-06 03:02:17 +02:00
Omar Emara
17bdf18397 Realtime Compositor: Implement Keying Screen node
This patch implements the Keying Screen node for the Realtime
Compositor. Draw data was introduced to the Movie Clip ID to allow
caching of the keying screen.

Pull Request: https://projects.blender.org/blender/blender/pulls/113055
2023-10-04 07:35:07 +02:00
Omar Emara
75c947a467 Compositor: Use RBF Interpolation in Keying Screen node
This patch changes the interpolation algorithm utilized by the Keying
Screen node to a Gaussian Radial Basis Function Interpolation. This is
proposed because the current Voronoi triangulation based interpolation
has the following properties:

- Not temporally stable since the triangulation can abruptly change as
  tracking markers change position.
- Not smooth in the mathematical sense, which is also readily visible in
  the artists sense.
- Computationally expensive due to the triangulation and naive
  rasterization algorithm.

On the other hand, the RBF interpolation method is temporally stable and
continuous, smooth and infinitely differentiable, and relatively simple
to compute assuming low number of markers, which is typically the case
for keying screen objects.

This breaks backward compatibility, but the keying screen is only used
as a secondary input for keying in typical compositor setups, so one
should expect minimal difference in outputs.

Pull Request: https://projects.blender.org/blender/blender/pulls/112480
2023-10-04 07:07:04 +02:00
Jeroen Bakker
7d05a4a69f Cleanup: Make format 2023-10-03 07:23:46 +02:00
Campbell Barton
8b940ab0c2 Merge branch 'blender-v4.0-release' 2023-10-03 11:19:40 +11:00
Campbell Barton
779239f5e1 Cleanup: spelling in comments 2023-10-03 11:16:55 +11:00
Brecht Van Lommel
de6f96df3a Merge branch 'blender-v4.0-release' into main 2023-10-02 19:54:22 +02:00
Brecht Van Lommel
94e2973f0b Build: support OpenColorIO 2.3
For Linux distributions or others that upgrade before we do.

Ref #113157

Pull Request: https://projects.blender.org/blender/blender/pulls/113163
2023-10-02 19:31:19 +02:00
Omar Emara
f217380128 Realtime Compositor: Use Int2 images in JFA algorithm
This patch changes the image type used in the Jump Flooding Algorithm to
be Int2 instead of Float4. That's because we used to store the distance
along with the texel location, which we no longer do, so we are left
with the 2D texel location only which can be stored in an Int2 image.

We no longer store the distance because it is not necessarily needed, it
introduces a sqrt in each of the JFA passes, and it is less precise due
to storage in 16F images. Developers should compute the distance in the
user shader instead.

This is a non-functional change, but results in less memory usage,
higher performance, and higher precision.

Pull Request: https://projects.blender.org/blender/blender/pulls/112941
2023-09-27 18:34:14 +02:00
Clément Foucault
bea13af81a Fix Realtime Compositor: Fix shader compilation on Metal 2023-09-25 22:00:06 +02:00
Omar Emara
6b53fd5cf6 Realtime Compositor: Allow more result types
Previously, the Result class was reserved for inputs and outputs of
operations, so its allowed types were naturally those exposed to the
user. However, we now use the Result class internally for intermediate
results, so it now makes sense to expend the allowed types.

The types are now divided into two categories, those that are user
facing and need to be handled in implicit operations and those that
are internal and can be exempt from such handling. Internal types are
reserved for texture results, as the single value mechanism is only
useful for user facing results.

The patch merely adjusts the switch cases across the code base, adding
one new internal type as an example.

Pull Request: https://projects.blender.org/blender/blender/pulls/112414
2023-09-25 15:12:52 +02:00
Omar Emara
869d0aeaa1 Fix: Cached distortion grids are not reset
The patch that introduced distortion grids forgot to reset them in the
static cache manager.
2023-09-25 14:13:42 +03:00
Campbell Barton
e38ff7c06d Cleanup: use C++ comments for disabled code 2023-09-25 17:06:04 +10:00
Omar Emara
acb88528a5 Realtime Compositor: Implement Inpaint node
This patch implements the Inpaint node for the Realtime Compositor. The
inpainting region is filled by sampling the color of the nearest boundary pixel
if it is not further than the user supplied distance. Additionally, a lateral
blur is applied in the tangential path to the inpainting boundary to smooth out
the inpainted region.

The implementation is not identical to the existing CPU implementation due to
technical infeasibility. In particular, the CPU implementation uses a Manhattan
distance transform, while the GPU implementation uses an Euclidean one, which is
a consequence of the use of the Jump Flooding algorithm. Furthermore, the CPU
uses a serial convolution starting from the boundary outwards, while the GPU
uses a lateral Gaussian blur in the direction tangent to the boundary.

Pull Request: https://projects.blender.org/blender/blender/pulls/111792
2023-09-25 08:45:46 +02:00
Omar Emara
5008938a1c Realtime Compositor: Implement Double Edge Mask node
This patch implements the Double Edge Mask node for the Realtime
Compositor. The implementation is primarily based on the 1+JFA Jump
Flooding algorithm, which was also introduced in this commit.

Pull Request: https://projects.blender.org/blender/blender/pulls/112223
2023-09-25 08:35:42 +02:00
Campbell Barton
5fbcb4c27e Cleanup: remove spaces from commented arguments
Also use local enums for `MA_BM_*` in versioning code.
2023-09-22 12:21:18 +10:00
Campbell Barton
31aa6fa073 Cleanup: various non-functional C++ changes 2023-09-22 10:52:40 +10:00
Habib Gahbiche
e621b7a621 Compositor: Kuwahara filter: consider alpha channel.
This makes the results more consistent with GPU implementation.

Pull Request: https://projects.blender.org/blender/blender/pulls/112199
2023-09-16 15:50:26 +02:00
Campbell Barton
4fc5d287ac Cleanup: doxygen parameters, blank comment lines 2023-09-08 16:53:30 +10:00
Campbell Barton
5ab2f61d44 Cleanup: remove use of 'auto' 2023-09-08 16:53:27 +10:00
Jacques Lucke
b5c89822ac RNA: return PointerRNA from rna create functions
There are a couple of functions that create rna pointers. For example
`RNA_main_pointer_create` and `RNA_pointer_create`. Currently, those
take an output parameter `r_ptr` as last argument. This patch changes
it so that the functions actually return a` PointerRNA` instead of using
the output parameters.

This has a few benefits:
* Output parameters should only be used when there is an actual benefit.
  Otherwise, one should default to returning the value.
* It's simpler to use the API in the large majority of cases (note that this
  patch reduces the number of lines of code).
* It allows the `PointerRNA` to be const on the call-site, if that is desired.

No performance regression has been measured in production files.
If one of these functions happened to be called in a hot loop where
there is a regression, the solution should be to use an inline function
there which allows the compiler to optimize it even better.

Pull Request: https://projects.blender.org/blender/blender/pulls/111976
2023-09-06 00:48:50 +02:00
Campbell Barton
0c26c84704 Cleanup: spelling in comments 2023-09-05 11:04:27 +10:00
Campbell Barton
3082037743 Cleanup: spelling in comments 2023-09-03 16:15:01 +10:00
Hans Goudey
fa34992def Cleanup: Remove unnecessary includes from C++ data structure headers
The hash tables and vector blenlib headers were pulling many more
headers than they actually need, including the C base math header,
our C string API header, and the StringRef header. All of this
potentially slows down compilation and polutes autocomplete
with unrelated information.

Also remove the `ListBase` constructor for `Vector`. It wasn't used
much, and making it easy to use `ListBase` isn't worth it for the
same reasons mentioned above.

It turns out a lot of files depended on indirect includes of
`BLI_string.h` and `BLI_listbase.h`, so those are fixed here.

Pull Request: https://projects.blender.org/blender/blender/pulls/111801
2023-09-01 21:37:11 +02:00
Lukas Tönne
e071288ab2 Nodes: Panels integration with blend files and UI
Part 3/3 of #109135, #110272

Switch to new node group interfaces and deprecate old DNA and API.
This completes support for panels in node drawing and in node group
interface declarations in particular.

The new node group interface DNA and RNA code has been added in parts
1 and 2 (#110885, #110952) but has not be enabled yet. This commit
completes the integration by
* enabling the new RNA API
* using the new API in UI
* read/write new interfaces from blend files
* add versioning for backward compatibility
* add forward-compatible writing code to reconstruct old interfaces

All places accessing node group interface declarations should now be
using the new API. A runtime cache has been added that allows simple
linear access to socket inputs and outputs even when a panel hierarchy
is used.

Old DNA has been deprecated and should only be accessed for versioning
(inputs/outputs renamed to inputs_legacy/outputs_legacy to catch
errors). Versioning code ensures both backward and forward
compatibility of existing files.

The API for old interfaces is removed. The new API is very similar but
is defined on the `ntree.interface` instead of the `ntree` directly.
Breaking change notifications and detailed instructions for migrating
will be added.

A python test has been added for the node group API functions. This
includes new functionality such as creating panels and moving items
between different levels.

This patch does not yet contain panel representations in the modifier
UI. This has been tested in a separate branch and will be added with a
later PR (#108565).

Pull Request: https://projects.blender.org/blender/blender/pulls/111348
2023-08-30 12:37:21 +02:00
Campbell Barton
3de8900ed6 Cleanup: spelling in comments 2023-08-25 09:40:42 +10:00
Campbell Barton
a56200c1ed Cleanup: sort cmake file lists 2023-08-24 11:38:41 +10:00
Campbell Barton
0148293520 License headers: add SPDX licenses for '*.glsl' files
When GLSL sources were first included in Blender they were treated as
data (like blend files) and had no license header.
Since then GLSL has been used for more sophisticated features
(EEVEE & real-time compositing)
where it makes sense to include licensing information.

Add SPDX copyright headers to *.glsl files, matching headers used for
C/C++, also include GLSL files in the license checking script.

As leading C-comments are now stripped,
added binary size of comments is no longer a concern.

Ref !111247
2023-08-24 10:57:03 +10:00
Campbell Barton
20b4a77872 datatoc: exclude the initial C-style comment from GLSL/MSL/Cuda files
Add optional argument `STRIP_LEADING_C_COMMENTS` to CMake macros:
data_to_c_simple & data_to_c.

Strip leading C-style comments that don't bloat binary size.
Comments are replaced with blank lines so line numbers in error messages
match. Reduces Blender's binary size by ~70kb.
2023-08-19 17:57:12 +10:00
Campbell Barton
63c1a26069 Cleanup: move GLSL comments to the file start
This has the benefit that leading comments may be stripped,
reducing the binary size (not yet supported).
2023-08-19 17:56:48 +10:00
Campbell Barton
add2a656da Cleanup: spelling, use C-style in GLSL 2023-08-19 17:13:05 +10:00
Omar Emara
726ba534fc Realtime Compositor: Support realization of transformations
This patch adds support for the realization of transformations of
operation inputs in the Realtime Compositor. Input socket declarations
can now include a preference to what sort of realization needs to
happen.

All inputs specify realization on the operation domain by default
because that is needed for the correct operation of most operations.

Nodes may choose not to be realized on the operation domain, like the
MapUV, Plane Deform, and Bokeh Blur nodes; that's because their inputs
are treated as transform-less image objects.

Nodes may chose to realize their rotation or scale, like operations that
are not rotation or scale invariant and thus need images of identity
transformations. No nodes are declared as such so far, as this is still
being considered by developers and test builds be published for testing.

This patch coincidentally also fixes #102252 by declaring the Bokeh input
of the Bokeh Blur node to need realization of rotation. Which is the only
functional change of the patch.

Fixes #102252.

Pull Request: https://projects.blender.org/blender/blender/pulls/111179
2023-08-18 10:00:16 +02:00
Campbell Barton
bc1ffdce5b Cleanup: spelling in comments 2023-08-18 08:56:12 +10:00
Omar Emara
9ef2310e5f Realtime Compositor: Implement Anisotropic Kuwahara
This patch implements the Anisotropic Kuwahara filter for the Realtime
compositor and replaces the existing CPU implementation with a new one to be
compatible with the GPU implementation. The implementation is based on three
papers on Anisotropic Kuwahara filtering, presented and detailed in the code.

The new implementation exposes two extra parameters that control the sharpness
and directionality of the output, giving more artistic freedom.

While the implementation is different from the existing CPU implementation, it
is a higher quality one that is also faster and conforms better to the methods
described in the papers.

Examples can be seen in the pull request description.

Pull Request: https://projects.blender.org/blender/blender/pulls/110786
2023-08-17 16:58:36 +02:00
Aras Pranckevicius
2f060706a4 Cleanup: fewer BLI_color.hh et al includes
Include counts of some headers while making full blender build:
- BLI_color.hh 1771 -> 1718
- BLI_math_color.h 1828 -> 1783
- BLI_math_vector.hh 496 -> 405
- BLI_index_mask.hh 1341 -> 1267
- BLI_task.hh 958 -> 903
- BLI_generic_virtual_array.hh 509 -> 435
- IMB_colormanagement.h 437 -> 130
- GPU_texture.h 806 -> 780
- FN_multi_function.hh 331 -> 257

Note: DNA_node_tree_interface_types.h needs color include only
for the currently unused (but soon to be used) socket_color function.
Future step is to figure out how to include
DNA_node_tree_interface_types.h less.

Pull Request: #111113
2023-08-16 14:48:53 +03:00
Aras Pranckevicius
acbd952abf Cleanup: fewer iostreams related includes from BLI/BKE headers
Including <iostream> or similar headers is quite expensive, since it
also pulls in things like <locale> and so on. In many BLI headers,
iostreams are only used to implement some sort of "debug print",
or an operator<< for ostream.

Change some of the commonly used places to instead include <iosfwd>,
which is the standard way of forward-declaring iostreams related
classes, and move the actual debug-print / operator<< implementations
into .cc files.

This is not done for templated classes though (it would be possible
to provide explicit operator<< instantiations somewhere in the
source file, but that would lead to hard-to-figure-out linker error
whenever someone would add a different template type). There, where
possible, I changed from full <iostream> include to only the needed
<ostream> part.

For Span<T>, I just removed print_as_lines since it's not used by
anything. It could be moved into a .cc file using a similar approach
as above if needed.

Doing full blender build changes include counts this way:
- <iostream> 1986 -> 978
- <sstream> 2880 -> 925

It does not affect the total build time much though, mostly because
towards the end of it there's just several CPU cores finishing
compiling OpenVDB related source files.

Pull Request: https://projects.blender.org/blender/blender/pulls/111046
2023-08-16 09:51:37 +02:00
Campbell Barton
e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00
Campbell Barton
ddf9e4be1b Fix missing headers, caused by recent cleanups with the compositor 2023-08-11 14:57:56 +10:00
Jacques Lucke
cc4d5c432c RNA: move headers to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/111022
2023-08-10 22:40:27 +02:00
Aras Pranckevicius
d973355b3a Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).

However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.

This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.

Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
  to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).

Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.

Pull Request #110944
2023-08-10 14:51:40 +03:00
Campbell Barton
faaac97239 Cleanup: format 2023-08-09 10:46:10 +10:00
Hoshinova
b880485492 Nodes: add Floored Modulo mode to Math nodes
Both the `Math` node and the `Vector Math` currently only explicitly
support modulo using truncated division which is oftentimes not the
type of modulo desired as it behaves differently for negative numbers
and positive numbers.

Floored Modulo can be created by either using the `Wrap` operation or
a combination of multiple `Math` nodes. However both methods obfuscate
the actual intend of the artist and the math operation that is actually
used.

This patch adds modulo using floored division to the scalar `Math` node,
explicitly stating the intended math operation and renames the already
existing `"Modulo"` operation to `"Truncated Modulo"` to avoid confusion.
Only the ui name is changed, so this should not break compatibility.

Pull Request: https://projects.blender.org/blender/blender/pulls/110728
2023-08-08 12:13:00 +02:00
Habib Gahbiche
2f907a0b53 Cleanup: Compositor: Remove outdated TODO
Done in #108858 but comment was not removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/110856
2023-08-07 18:29:59 +02:00
Jeroen Bakker
8de4b5a5ed Vulkan: Shader Compilation Errors
Fixing several shader compilation errors when using the vulkan backend.

* `eevee_lightprobe_irradiance_load_comp`: local variables used same name as push constants.
* `compositor_summed_area_table_compute_complete_y_prologues`: loop with texture_size call

Pull Request: https://projects.blender.org/blender/blender/pulls/110891
2023-08-07 14:49:08 +02:00