Commit Graph

26 Commits

Author SHA1 Message Date
Omar Emara
17db65dfd0 Compositor: Remove Gamma from Blur and Defocus nodes
This patch removes the Gamma option from the Defocus and Blur nodes. The
reasoning is as follows.

- The option was originally added when the compositor wasn't working on
  a strictly linear workflow. So this is rarely needed now.
- It is easy to insert a Gamma node around Blur nodes to perform any
  gamma correction if really needed.
- Since we are moving options to inputs, it doesn't seem worth it to
  provide this option as an input in the process.

Pull Request: https://projects.blender.org/blender/blender/pulls/138673
2025-05-12 13:18:46 +02:00
Omar Emara
781dea8442 Cleanup: Compositor: Use default case for blur types
Use a default case for blur type switch case, that's because adding all
types is not necessary, and I am trying to differentiate between switch
cases that need full type enumeration and those that do not.
2025-03-18 16:15:27 +02:00
Omar Emara
0a57002469 Cleanup: Compositor: Remove redundant SMAA types
This patch removes code that handles types other than Float and Color,
that's because SMAA is practically only used for those types only.
2025-03-18 15:51:51 +02:00
Omar Emara
ebaa12af6c Refactor: Compositor: Use data sharing for SMAA
Use data sharing instead of copying in the SMAA algorithm. This reduces
redundant copies and code duplication.
2025-03-18 12:38:48 +02:00
Omar Emara
b37afc86d1 Refactor: Compositor: Replace proxy results with data sharing
This patch refactors the result class to replace proxy results with the
possibility of doing data sharing through a shared heap allocated data
reference count. This is more robust and simpler since proxy results no
longer need to be handled as a special case in a lot of the results
code. Additionally, it allows stronger const correctness since inputs to
operations can now be const.

This is somewhat similar to implicit sharing used in other parts of
Blender, so we can look into using that in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/135778
2025-03-12 16:42:26 +01:00
Hans Goudey
9cade06f5f Refactor: Nodes: Use Map instead of GHash for compositor previews
Replace `bNodeInstanceHash` with a `Map`. Move it to the node tree
runtime data. Simplify some code by removing the tag from the hash
value and collecting unused previews directly. Then just remove a
bunch of code that's now unused.

Note that texture node previews haven't been working for a while
anyway, and the experimental shader node previews seem to use
a different system (this one is a remnant of Blender Internal).

Pull Request: https://projects.blender.org/blender/blender/pulls/135310
2025-03-03 14:04:20 +01:00
Omar Emara
16d59b00a7 Refactor: Compositor: Use int32_t as result type
This patches uses an explicit int32_t fixed width integer instead of int
for result types. For consistency with other node systems.
2025-02-25 09:25:48 +02:00
Omar Emara
5e8f96277d Compositor: Reduce vector type components to 3
Previously, the vector type in the compositor had 4-components to
accommodated float4 types, while the last component was ignored for the
rest of the vector types. But now that we have a dedicated type for
float4 in #134486. We can reduce that vector type to 3-components.

Pull Request: https://projects.blender.org/blender/blender/pulls/134570
2025-02-20 13:23:54 +01:00
Omar Emara
a5ecde48ae Compositor: Add Float4 type
The compositor previously overloaded the vector type to represent
multiple dimensions that are always stored in a 4D float vector. This
patch introduce a dedicated type for float4, leaving the vector type to
always represent a 3D vector, which will be done in a later commit.

This is not exposed to the user as a separate socket type with a
different color, it is only an internal type that uses the same vector
socket shape and color.

Since the vector socket represents both 4D and 3D vectors, code
generally assumes that such sockets represents 3D vectors, and the
developer is expected to set it to a 4D vector if needed in the node
operation constructor, or use the newly added skip_type_conversion flag
for nodes that do not care about types, like the File Output node.
Though this should be redundant once we add a dimension property for
vector sockets.

Pull Request: https://projects.blender.org/blender/blender/pulls/134486
2025-02-20 10:38:40 +01:00
Omar Emara
89e0472e49 Compositor: Use gpu::TexturePool instead of DRW pool
This patch removes the compositor texture pool implementation which
relies on the DRW texture pool, and replaces it with the new texture
pool implementation from the GPU module.

Since the GPU module texture pool does not rely on the global DST, we
can use it for both the viewport compositor engine and the GPU
compositor, so the virtual texture pool implementation is removed and
the GPU texture pool is used directly.

The viewport compositor engine does not need to reset the pool because
that is done by the draw manager. But the GPU compositor needs to reset
the pool every evaluation. The pool is deleted directly after rendering
using the render pipeline or through RE_FreeUnusedGPUResources for the
interactive compositor.

Pull Request: https://projects.blender.org/blender/blender/pulls/134437
2025-02-12 15:59:45 +01:00
Omar Emara
d006924ebc Fix: Blur is two times slower in 4.4
The symmetric separate blur operation in the compositor is two times
slower in 4.4 compared to 4.3. On Linux, this only happens when Blender
is compiled with GCC, because Clang inlines a small function that GCC
doesn't.

To fix this, we specialize an if statement using templates to help GCC
inline the function. This results in a 3.5 times faster execution.

Pull Request: https://projects.blender.org/blender/blender/pulls/134336
2025-02-10 12:58:02 +01:00
Brecht Van Lommel
1eb1755e1f Cleanup: Various clang-tidy warnings in compositor
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:17 +01:00
Omar Emara
109478d599 Compositor: Delay transformations until realization
This patch delays applying transformations until realization happens on
some other domain.

Currently, transformations are applied immediately at the point of
transform nodes, this is problematic for a few reasons:

- If that result was then realized on some other domain, interpolation
  will have happened two times, at the transform nodes and at the node
  that required realization, causing less than ideal precision issues.
- It is not possible to repeat or extend a rotated result because its
  empty areas will be zero filled, leaving gaps in its extension. So
  this patch is a prerequisite for #132371 if we want full support for
  repetition.
- Doing inverse transformations will introduce interpolation artifacts
  which might be undesirable. Inverse transformations might be used to
  do pixelation for instance, so this change will be undesirable in this
  case. But we decided that this is not a use case that we want to
  support, and we added explicit pixel size control to the pixelate node
  as an alternative.

So this has four implications, two that might be considered bad:

- Transformations will now be higher quality and more precise.
- Repetition and other boundary extension methods will now be possible.
- Downsampling then upsampling will no longer produce pixelated results.
- Realization might happen multiple times with identical results in some
  cases.

The last point not a big issue, since domain realization is not a big
bottleneck in the compositor, and the plan is to move realization into
pixel operations, so it will even be more efficient than it is now.

Pull Request: https://projects.blender.org/blender/blender/pulls/133158
2025-01-24 13:59:55 +01:00
Omar Emara
e545b6e764 Cleanup: Pass interpolation directly to transform algorithm
The transform algorithm currently takes realization options, but it only
uses the interpolation from it. So pass interpolation directly for
clarity.
2025-01-15 15:45:51 +02:00
Omar Emara
7e5af160bd Cleanup: Rename wrap to repeat in realization options
The wrap member in realization options is no longer used to indicate
wrapping since 8f8ae302ba. So rename it to repeat since the only user is
now repeating in the realization algorithm.
2025-01-15 15:22:36 +02:00
Omar Emara
8f8ae302ba Refactor: Compositor: Moved wrapped translation to its own code
This patch moves wrapped translation from a special case of the general
transform algorithm to the Translate node. Since the Translate node is
the only user of this special case, it doesn't make sense to complicate
a generate algorithm with it. This will make future refactors of this
code easier.

Pull Request: https://projects.blender.org/blender/blender/pulls/132793
2025-01-08 12:42:13 +01:00
Omar Emara
b3623feab2 Compositor: Support node integer sockets
This patch adds support for using integer sockets in compositor nodes.
This involves updating the Result class, node tree compiler, implicit
conversion operation, multi-function procedure operation, shader
operation, and some operations that supports multiple types.

Shader operation internally treats integers as floats, doing conversion
to and from int when reading and writing. That's because the GPUMaterial
compiler doesn't support integers. This is also the same workaround used
by the shader system. Though the GPU module are eyeing adding support
for integers, so we will update the code once they do that.

Domain realization is not yet supported for integer types, but this is
an internal limitation so far, as we do not plan to add nodes that
outputs integers soon. We are not yet sure how realization should happen
with regards to interpolation and we do not have base functions to
sample integer images, that's why I decided to delay its implementation
when it is actually needed.

Pull Request: https://projects.blender.org/blender/blender/pulls/132599
2025-01-06 10:09:26 +01:00
Omar Emara
159038ce7c Cleanup: Compositor: Deduplicate single value setters 2025-01-02 10:20:17 +02:00
Omar Emara
f90572c688 Cleanup: Compositor: Remove typed single value getters 2025-01-01 18:20:58 +02:00
Omar Emara
0a6b43c827 Compositor: Make transformed realized domains symmetric
This patch changes how transformations are realized by adjusting the
computed size of the new domain after transformation. Previously, this
was computed with the lower left corner of the domain as the origin of
transformation, while now, the center of the domain is used as the
origin. Consequently, domains shrinks/grows around their center, which
results in a more stable output as transforms are animated.

A consequence of this change is that we can no longer scale odd sized
domains to even sized domains or vice versa, since it grows/shrinks by
the same amount on both sides. Supporting this case requires further
investigation and will probably require passing down information to the
realization functions themselves.
2024-12-19 12:48:44 +02:00
Aras Pranckevicius
496a3749d7 Cleanup: rename namespace realtime_compositor->compositor
Pull Request: https://projects.blender.org/blender/blender/pulls/132008
2024-12-17 11:39:04 +01:00
Aras Pranckevicius
a401089a9d Cleanup: move compositor files out of realtime_compositor folder
By now it is just a "compositor", so move the files one folder up.
Things that were under realtime_compositor/intern move into
already existing intern folder.

Pull Request: https://projects.blender.org/blender/blender/pulls/132004
2024-12-17 10:34:24 +01:00
Aras Pranckevicius
aa88b996e4 Cleanup: remove old CPU compositor code
40 thousand lines of now-unused code, poof gone. Blender
executable (Windows, Release config) becomes 670 kilobyte smaller.

Pull Request: https://projects.blender.org/blender/blender/pulls/131819
2024-12-13 10:59:54 +01:00
Omar Emara
c4f9484c18 Cleanup: Unused variable warnings 2024-02-06 17:07:51 +02:00
Omar Emara
291735971c Compositor: Port GPU Inpaint node to CPU
This patch ports the newly redesigned GPU Inpaint node to the CPU. The
code is mostly identical to the GPU code with the necessary adjustments
to make it work with CPU.

See #114849 for more information.

Pull Request: https://projects.blender.org/blender/blender/pulls/117716
2024-02-06 12:18:50 +01:00
Omar Emara
049b0e6539 Compositor: Rewrite and optimize Double Edge Mask node
This patch rewrites and optimizes the Double Edge Mask node to be orders
of magnitude faster. For a 1k complex mask, it is 650x faster, while for
a 1k simple mask, it is only 50x faster.

This improvement is attributed to the use of a new Jump Flooding
algorithm as well as multi-threading, matching the GPU implementation.

The result of the new implementation differs in that the boundaries of
the masks are now identified as the last pixels inside the mask.

Pull Request: https://projects.blender.org/blender/blender/pulls/117545
2024-01-30 19:49:32 +01:00