Commit Graph

1721 Commits

Author SHA1 Message Date
Brecht Van Lommel
3d86417777 Fix build error without unity build 2023-07-12 16:18:26 +02:00
Jacques Lucke
3f33e0c6cd Cleanup: clang format in disabled code segments
This formats code that is disabled using `#if 0`. Formatting was achieved
by temporarily changing `#if 0` to `#if 1 /*something*/`, then formatting,
and then changing it back to `#if 0`.
2023-07-12 14:18:59 +02:00
Ray molenkamp
07fe6c5a57 Cleanup: CMake: Modernize bf_blenkernel dependencies
Pretty straightforward

- Remove any blenkernel paths from INC
- Add a dependency though LIB

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/109939
2023-07-11 19:28:01 +02:00
Ray Molenkamp
04235d0e55 Cleanup: CMake: Modernize bf_blenlib dependencies
Pretty straightforward

- Remove any blenlib paths from INC
- Add a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109934
2023-07-10 22:04:18 +02:00
Ray Molenkamp
57ad866d81 Cleanup: CMake: Modernize bf_guardedalloc dependencies
Pretty straightforward

- Removes any guardedalloc paths from INC
- Adds a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109925
2023-07-10 18:44:19 +02:00
Sergey Sharybin
d579ac2b3f Refactor: Use ImBuf to store passes in RenderResult
Doing so avoids having duplicated logic for working with pixel
data which is being passed throughout the render pipeline.

Notable changes:

- ImBug can now store GPU texture.
  This is not very finished part of the API, which will be
  worked further to support tiling for very-high-res images.

- Implicit sharing is removed from the image buffer, as it is
  no longer needed.

There should be no functional changes on user level with this
change.

Ref #108618

Pull Request: https://projects.blender.org/blender/blender/pulls/109788
2023-07-10 16:33:32 +02:00
Ray Molenkamp
7cebb61486 Cleanup: CMake: Modernize bf_dna dependencies
There's quite a few libraries that depend on dna_type_offsets.h
but had gotten to it by just adding the folder that contains it to
their includes INC section without declaring a dependency to
bf_dna in the LIB section.

which occasionally lead to the lib building before bf_dna and the
header being missing, while this generally gets fixed in CMake by
adding bf_dna to the LIB section of the lib, however until last
week all libraries in the LIB section were linked as INTERFACE so
adding it in there did not resolve the build issue.

To make things still build, we sprinkled add_dependencies wherever
we needed it to force a build order.

This diff :

Declares public include folders for the bf_dna target so there's
no more fudging the INC section required to get to them.

Removes all dna related paths from the INC section for all
libraries.

Adds an alias target bf:dna to signify it has been updated to
modern cmake

Declares a dependency on bf::dna for all libraries that require it

Removes (almost) all calls to add_dependencies for bf_dna

Future work:

Because of the manual dependency management that was done, there is
now some "clutter" with libs depending on bf_dna that realistically
don't. Example bf_intern_opencolorio itself has no dependency on
bf_dna at all, doesn't need it, doesn't use it. However the
dna include folder had been added to it in the past since bf_blenlib
uses dna headers in some of its public headers and
bf_intern_opencolorio does use those blenlib headers.

Given bf_blenlib now correctly declares the dependency on bf_dna
as public bf_intern_opencolorio will get the dna header directory
automatically from CMake, hence some cleanup could be done for
bf_intern_opencolorio

Because 99% of the changes in this diff have been automated, this diff
does not seek to address these issues as there is no easy way to
determine why a certain dependency is in place. A developer will have
to make a pass a this at some later point in time. As I'd rather not
mix automated and manual labour.

There are a few libraries that could not be automatically processed
(ie bf_blendthumb) that also will need this manual look-over.

Pull Request: https://projects.blender.org/blender/blender/pulls/109835
2023-07-10 15:07:37 +02:00
Ray Molenkamp
f0ee4c3ffe Cleanup: Cmake: use alias target for bf_intern_atomic
This introduces an alias target `bf::intern::atomic` for
`bf_intern_atomic`. This has the following benefits:

- Any target name with `::` in it will be recognized as an actual
target by cmake, rather than a library name it may not know about.
and will be validated by cmake to exist. Which means if you make
a typo in the LIB section, CMake will error out telling you it
doesn't know about this specific target rather than passing it on
to the build system, where you'll either get build or linker errors
because of said typo.

- Given there is quite a cleanup still to do in the build system,
it won't always be obvious which targets have been updated to
modern targets and which still need to be done. Having a namespaced
target name is a good indicator there.

Pull Request: https://projects.blender.org/blender/blender/pulls/109784
2023-07-07 15:37:02 +02:00
Campbell Barton
6a79639ef7 Cleanup: use function style casts, remove void function argument
Also remove redundant parenthesis.
2023-07-06 10:40:25 +10:00
Brecht Van Lommel
4c6653274c Fix full frame compositor crash when Image node can't load image
Ref #109168
2023-07-05 20:51:28 +02:00
Ray Molenkamp
c591eb1b40 Fix #109596: Xcode project generation fails
Remove dead code that is causing problems with dependencies in Xcode.

Pull Request: https://projects.blender.org/blender/blender/pulls/109751
2023-07-05 18:46:55 +02:00
Sergey Sharybin
e1b60fdb91 Remove Z Buffer from ImBuf
It was only used by OpenEXR and Iris images, and saving the Z Buffer
in those formats was disabled by default. This option comes from the
times prior to the addition of the Multilayer EXR.

It also worth noting that it was not possible to save Iris with Depth
pass from Blender as internally it is called IRIZ format and it was
not exposed. But even after exposing this format option something still
was missing as saving and loading ITIZ did not show up the Depth pass.

The reason of removal is to make it a more clear match of the ImBuf
with a render pass, and use it instead of a custom type in the render
result and render pass API. This will simplify the API and also avoid
stealing buffers and making shallow copies when showing the render
result.

For the cases when Depth is needed a Multilayer EXR is to be used,
as most likely more than just the Depth will be needed.

On a user level this change:

- Removes the "Z Buffer" option from the interface.

- It preserves existing sockets in compositor nodes, but it will
  output black image. Also changing the image data-block will
  remove the socket unless a Multilayer EXR with Depth pass image
  is selected.

- Removes "Depth" socket of the Viewer and Composite nodes.

Ref #108618

Pull Request: https://projects.blender.org/blender/blender/pulls/109687
2023-07-04 17:03:02 +02:00
Sergey Sharybin
5907ab0364 Fix redefinition SSE2NEON_PRECISE_SQRT on Apple Silicon
After some recent changes BLI_math_base got (indirectly) included
from DNA file, causing defines conflict in Cycles: Cycles wants the
default fast behavior of square root, and BLI color wants it to be
more preciese.

Proposed solution is to move the SSE block away from the math_base
closer to code which uses it. The initial intent was to make those
functions reusable, but for a long long time the color utilities
are the only users of those functions.

This change does not prevent the error from re-occurring in the
future if some code includes sse2neon and BLI color utilities, but
it makes such conflict situation much less likely to happen, for
now.

The downside of this change is that the code now need to include
BLI_simd.h explicitly to access BLI_HAVE_SSE2 instead of relying
on it being included indirectly with math headers. The mitigation
for this is to change semantic of the BLI_HAVE_SSE2: now it is
defined to 1 if SSE2 is supported and to 0 otherwise. This makes
it so the code needs to check if using `#if BLI_HAVE_SSE2` and
if the BLI_simd.h is not included it will generate warning when
using GCC or Clang.

This change in semantic is is something the current patches would
need to ensure is handled correctly.

Pull Request: https://projects.blender.org/blender/blender/pulls/109664
2023-07-03 19:18:30 +02:00
Ray molenkamp
2dac20e35f CMake/Cleanup: Use bf_intern_atomic target
Use the bf_intern_atomic target rather than adding a relative path
to it in the INC section.

Pull Request: https://projects.blender.org/blender/blender/pulls/109424
2023-06-28 19:12:55 +02:00
Campbell Barton
d1e6c8f5a6 Cleanup: spelling in comments 2023-06-28 12:27:48 +10:00
Campbell Barton
85029da289 Cleanup: compiler warnings 2023-06-25 11:39:25 +10:00
Habib Gahbiche
c8f434e685 Compositor: improve edge detection of Kuwahara filter
Compute edges of image once based on luminance instead of all 3 channels.

This also gives a modest performance improvement of 8%. Measured on intel i9 CPU using a 1920 x 3199 image.

Pull Request: https://projects.blender.org/blender/blender/pulls/108858
2023-06-24 21:39:07 +02:00
Omar Emara
c9e6399fe1 Realtime Compositor: Implement Keying node
This patch implements the Keying node for the realtime compositor. To
ease the implementation, some morphological operators were moved into
algorithms and a mechanism to steal data between results was added to
the Result class.

Pull Request: https://projects.blender.org/blender/blender/pulls/108393
2023-06-24 13:02:33 +02:00
Campbell Barton
ec428c3f7f CMake: sort file lists, add missing header 2023-06-24 19:05:09 +10:00
Brecht Van Lommel
711fb3e386 Realtime Compositor: cache render compositor for repeated executions
This is cached in Render, and gets cleared along with render pass GPU
textures when there is no editor open using it, or a new final render is
started.

The context and texture pool are cached. But the evaluator is re-created
every time as this only runs on compositing node changes, which require
recreating it anyway (unlike the viewport where e.g. camera navigation
does not need a new evaluator).

Pull Request: https://projects.blender.org/blender/blender/pulls/108909
2023-06-23 20:13:21 +02:00
Brecht Van Lommel
7a3a4b58e6 Fix realtime compositor not correctly handling multiple scene render layers
Pull Request: https://projects.blender.org/blender/blender/pulls/108909
2023-06-23 20:00:28 +02:00
Omar Emara
c2361381cd Realtime Compositor: Add node previews for shader operations
This patch adds support for node previews for shader operations, making
node previews fully supported.

The patch was started as an effort to refactor the compositor compiler
to split the shader operators when node previews increase past hardware
limits. However, I realized that the better approach would be to remove
those limits altogether by using texture arrays instead of individual
textures for operation results, then use texture views to slice that
array. This is not implemented in this patch and will require some
prerequisites, namely adding target conversion to GPU texture views as
well as support texture arrays in the DRW texture pool.

Pull Request: https://projects.blender.org/blender/blender/pulls/109250
2023-06-23 18:46:18 +02:00
Sergey Sharybin
d8cc8fcf7f Refactor: Move color space information to ImBuf buffers
Before this change the ImBuf struct had dedicated fields for the
buffer data. Now the color space is stored inside of the struct
which wraps around the buffer information.

This only changes the field placement, without changing the way
it is handled. In the future one might imagine that operations
like stealing buffer data should null-ify the buffer colorspace
pointer. Such changes would need to have more accurate thinking
before implementation.

Should be no functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/109291
2023-06-23 15:55:42 +02:00
Omar Emara
d6cd3db13b Fix: Wrong reference count for shader operation
The reference count computation for shader operation outputs is wrong,
because it considers internal links as references to the result, which
is not the case.

This patch fixes that by only consider external links.
2023-06-22 13:57:31 +03:00
Jeroen Bakker
48867f9798 Cleanup: make format 2023-06-22 08:22:21 +02:00
Omar Emara
75b519eb89 Fix: Sun Beams shader does not work on Metal
Metal does not support the length function on integer vectors, so
explicitly cast to a float one.
2023-06-21 19:48:33 +03:00
Omar Emara
b450101000 Realtime Compositor: Add support for node previews
This patch adds support for node previews in the realtime compositor.
Only node operations have previews for now. Shader nodes likes the
MixRGB node does not have previews implemented yet due to required
sizable changes in the node compiler.

Depends on: #108900.

Pull Request: https://projects.blender.org/blender/blender/pulls/108904
2023-06-21 05:41:49 +02:00
Omar Emara
740baefb16 Nodes: Add bNodeInstanceKey to DerivedNodeTree
This patch adds support for bNodeInstanceKey to DerivedNodeTree. The
keys are computed and cached in the DContext at construction time, and
various utilities are added to return the instance keys of contexts,
nodes, as well as find the active context in the tree.

Pull Request: https://projects.blender.org/blender/blender/pulls/108900
2023-06-21 05:03:56 +02:00
Campbell Barton
65f99397ec License headers: use SPDX-FileCopyrightText in all sources 2023-06-15 13:35:34 +10:00
Habib Gahbiche
ab4286f940 Compositor: speedup Kuwahara classic variation
Compute luminance only once per region and per pixel by means of vectorization.

Measured time improvements on intel i9 CPU on a 1920 x 3199 image:
- from 14.7s to 3.9s for full-frame compositor
- from 50.1s to 15.3s for tiled compositor

Pull Request: https://projects.blender.org/blender/blender/pulls/108859
2023-06-13 22:22:01 +02:00
William Leeson
d75be31b18 Fix build failing due to missing dna offsets for realtime compositor
Add dependency like other modules.

Pull Request: https://projects.blender.org/blender/blender/pulls/108890
2023-06-12 14:47:46 +02:00
Jeroen Bakker
b8ce3f69b1 Cleanup: Fix Compilation Warning
On Mac there is a compilation warning when compiling without support
for open image denoising.

Pull Request: https://projects.blender.org/blender/blender/pulls/108882
2023-06-12 12:12:25 +02:00
Jeroen Bakker
b1b74eb335 Cleanup: make format 2023-06-09 16:28:00 +02:00
Brecht Van Lommel
5136e2a9f8 Compositor: add passes for non-viewport realtime compositor
Pull Request: https://projects.blender.org/blender/blender/pulls/108808
2023-06-09 16:21:42 +02:00
Omar Emara
5400fe941e Realtime Compositor: Support Viewer nodes
This patch adds support for Viewer and File Output nodes to the realtime
compositor. The experimental render GPU compositor was also extended to
support viewers. While support for File Output nodes was added, it
remains unimplemented.

This is just an experimental implementation, the logic for viewers will
probably be changed once #108656 is agreed upon. Furthermore, the recalc
NODE_DO_OUTPUT_RECALC flags need to be taken into account to avoid
superfluous computations.

Pull Request: https://projects.blender.org/blender/blender/pulls/108804
2023-06-09 15:53:08 +02:00
Brecht Van Lommel
2efb3fc91a Fix build error with non-unity build 2023-06-09 14:44:08 +02:00
Sergey Sharybin
c70a1595ef Fix uninitialized alpha channel in classic Kuwahara filter
Was only happening for the tiled compositor implementation.

This is likely to be the source of flackey tests on the
buildbot.

Also, the reference image was empty because of this, so
it needs to be re-generated.

Pull Request: https://projects.blender.org/blender/blender/pulls/108800
2023-06-09 12:15:56 +02:00
Campbell Barton
2f1899a7fa Cleanup: spelling in comments 2023-06-09 11:40:50 +10:00
Habib Gahbiche
f3cb157452 Compositor: add new node: Kuwahara filter
The filter is used to reduce noise while preserving edges. It can be used to create a cartoon effect from photorealistic images.

It offers two variations:
1) Classic aka isotropic kuwahara filter: simple and faster computation. Algorithm splits an area around a single pixel in four parts and computes the mean of the region with the lowest standard deviation.
2) Anisotropic Kuwahara filter: improves the classical approach by considering the direction of structures of regions

This patch implements both approaches above as multi-threaded operations for the full-frame and tiled compositor.

Co-authored-by: Sergey Sharybin <sergey@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/107015
2023-06-08 16:14:45 +02:00
Omar Emara
9ddc8504fa Realtime Compositor: Implement Sun Beams node
This patch implements the Sun Beams node for the realtime compositor.
The implementation is not identical to the existing CPU implementation,
but is very close. The new implementation is a higher quality one and
resolves some of the artefacts in the existing implementation. This is
achieved by doing a simple line integration toward the source pixel,
while having a number of integration steps that is invariant of the
angle to the source.

Pull Request: https://projects.blender.org/blender/blender/pulls/108718
2023-06-08 15:36:35 +02:00
Campbell Barton
7a1e2c4d0c Cleanup: spelling in code 2023-06-08 10:43:55 +10:00
Omar Emara
f06929766b Realtime Compositor: Implement Movie Distortion node
This patch implements the Movie Distortion node for the realtime
compositor. The distorted coordinates are computed and cached for a
particular tracking camera distortion parameters. So for expensive
distortion models, the first run will take some time to compute, but
subsequent runs will be fast.

An alternative implementation would be to implement each of the
distortion modes in the shader, but that was decided against for a few
reasons:

1. We want to hide the implementation details of the distortion models,
   since it is provided through an external library (Libmv).
2. Some distortion models are expensive to solve accurately, and can be
   quite slow to solve each time the shader runs.
3. The typical usage of the node does not involve interactive editing of
   the distortion parameters, rather, the parameters are computed during
   camera calibration, so caching seems most fitting in that case.

Pull Request: https://projects.blender.org/blender/blender/pulls/108230
2023-06-07 14:45:46 +02:00
Brecht Van Lommel
65fc10bd33 Compositor: first steps to use realtime compositor for renders
* Enable "Experimental Compositors" in preferences, then choose
  Realtime GPU execution mode in node editor sidebar.
* Only supports combined pass input and Render Result combined output.
* No viewer nodes, no file output nodes, and no node previews yet.

Pull Request: https://projects.blender.org/blender/blender/pulls/108629
2023-06-07 14:17:48 +02:00
Brecht Van Lommel
db43a8fb57 Refactor: realtime compositer context changes for render compositing
* Provide render data, node tree and color management directly instead
  of going through scene, as these may be modified by the render pipeline.
  Also better for cached texture hits this way.
* Change legacy pass type to pass name.
* Skip file output node when not doing final render.
* Gracefully handle incomplete render results.

Pull Request: https://projects.blender.org/blender/blender/pulls/108629
2023-06-07 14:17:37 +02:00
Philipp Oeser
cbefcacdf3 Merge branch 'blender-v3.6-release' 2023-06-06 13:51:49 +02:00
Philipp Oeser
32a349d3a3 Fix #108492 : Compo Track Position node wrong Y for Relative Start/Frame
This seems to be a simple copy/paste error from e0c5ff87b7

Thx @Chris-Thomas spotting this!

Pull Request: https://projects.blender.org/blender/blender/pulls/108504
2023-06-06 13:50:34 +02:00
Campbell Barton
e27bcb6e3e Cleanup: remove redundant struct qualifier 2023-06-04 19:27:38 +10:00
Sergey Sharybin
c1bc70b711 Cleanup: Add a copyright notice to files and use SPDX format
A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.

This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.

Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.

Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:

    https://reuse.software/faq/
2023-05-31 16:19:06 +02:00
Campbell Barton
823685db76 Cleanup: consistent doxygen comment blocks
Also remove doxygen block for comments in a functions body.
2023-05-27 15:10:58 +10:00
Campbell Barton
129f6b7b84 Cleanup: spelling in comments, replace slang/informal terms 2023-05-24 20:27:13 +10:00