799 Commits

Author SHA1 Message Date
Aras Pranckevicius
facb17b0e3 Cleanup: BLI ENUM_OPERATORS cleanup/robustness
BLI code for enums that are meant to be used as "bit flags" defined
an ENUM_OPERATORS macro in BLI_utildefines.h. This cleans up things
related to said macro:

- Move it out into a separate BLI_enum_flags.hh header, instead of
  "random bag of things" that is the current place,
- Update it to no longer need manual indication of highest individual
  bit value. This originally was added in a31a87f89 (2020 Oct), in
  order to silence some UBSan warnings that were coming
  from GPU related structures (looking at current GPU code, I don't
  think this is happening anymore). However, that caused actual
  user-visible bugs due to incorrectly specified max. enum bit value,
  and today 14% of all usages have incorrect highest individual
  bit value spelled out.
    - I have reviewed all usages of operator ~ and none of them are
      used for directly producing a DNA-serialized value; all the
      usages are for masking out other bits for which the new ~
      behavior that just flips all bits is fine.
- Make the macro define flag_is_set() function to ease check of bits
  that are set in C++ enum class cases; update existing cases to use
  that instead of three other ways that were used.

Pull Request: https://projects.blender.org/blender/blender/pulls/148230
2025-10-17 12:57:50 +02:00
Omar Emara
97e3fb0e03 Compositor: Add internal support for 2D vectors
This patch adds proper internal support for 2D vectors in GPU materials,
while previously it used a 3D vector with the Z component ignored as a
workaround. This has no user-facing consequences.

The type conversion file was split into an additional code generation
file for easier refactoring.

Pull Request: https://projects.blender.org/blender/blender/pulls/147983
2025-10-13 17:35:23 +02:00
Omar Emara
5517941a60 Compositor: Support implicit conversion across 2D vectors
This patch adds the necessary functions needed to support implicit
conversion in GPU execution across 2D vectors in the compositor.

Pull Request: https://projects.blender.org/blender/blender/pulls/147975
2025-10-13 15:12:56 +02:00
Omar Emara
f2f84ef60a Fix #136783: Scaling sometimes causes images to shift
Scaling images in the compositor sometimes causes images to shift, this
is because the realization domain was computed using the center of the
original image before scaling. To fix this, we make sure the
transformation is actually centered.

This is rarely apparent and thus no tests need to be updated and this
should not be backported for safety.

Pull Request: https://projects.blender.org/blender/blender/pulls/147805
2025-10-10 14:22:31 +02:00
Omar Emara
41dac157b6 Fix #147786: Crash when connecting menu to float input
Compositor crashes when connecting a menu output to a float input, this
is because no implicit conversion is supported between the two, and no
handling was done in this case. To fix this, we fallback to a default
value for unsupported implicit conversions.

Pull Request: https://projects.blender.org/blender/blender/pulls/147801
2025-10-10 13:52:15 +02:00
Hans Goudey
a68d39e9d9 Cleanup: Formatting
Run `make format` after the library update in the previous commit.
2025-10-02 12:55:42 -04:00
Omar Emara
d75b8e5b6e Compositor: Make a distinction between inputs and passes
This patch makes a distinction between passes accessed through nodes
like the Render Layers node, and inputs accessed through nodes like the
Group Input node. Previously, the Group Input node returned the passes
of the active scene and view layer accordingly to the name, while now,
it only returns the Image (Combined) pass and the result will be zeros.

Pull Request: https://projects.blender.org/blender/blender/pulls/146831
2025-09-30 11:35:02 +02:00
Clément Foucault
fb3904ce45 GPU: Shader Codegen: Split different graph includes
This allows to reduce the number of includes for each
tree graph (surface, volume, displacement) and
reduce the code size significantly for most vertex
shaders, speeding up compile time.

Rel #145347

Pull Request: https://projects.blender.org/blender/blender/pulls/146419
2025-09-22 10:24:10 +02:00
Clément Foucault
680fec144c Cleanup: GPU: Remove prefix 'e' from enum types
_No response_

Pull Request: https://projects.blender.org/blender/blender/pulls/146034
2025-09-15 15:11:02 +02:00
Clément Foucault
f729e639f4 GPU: Simplify Codegen dependency injection
Dependencies were previously merged manually
inside the generated_sources by EEVEE.
This caused issues with double includes.

Instead, we now only gather the name of the
nodetree dependencies and add them to the
dependencies of the `GeneratedSource`.

This also make the compositor use the `GeneratedSource`
mechanism.

Pull Request: https://projects.blender.org/blender/blender/pulls/146106
2025-09-12 16:07:55 +02:00
Omar Emara
329ba2f69e Fix #145667: Nearest interpolation is ignored in Vulkan
Blender compositor ignores nearest interpolation in Vulkan backend.
That's because anisotropic interpolation is used based on same left over
sampler state. To fix this, we clear anisotropic sampling in the
realization shader.

Pull Request: https://projects.blender.org/blender/blender/pulls/145905
2025-09-08 12:02:53 +02:00
Brecht Van Lommel
2eaa8dc7d5 Compositor: Add Convert to Display node
This applies an OpenColorIO display, view and look transform on a color
in the scene_linear colorspace.

In general, OpenColorIO configurations do not contain a colorspace for
every view + display, especially if they are modern configs using the
display colorspace and shared view mechanisms. Nor do they include looks.
So the Convert Colorspace node is not sufficient.

Additionally, we would like to avoid making the colorspace list too long
in the default config, as we are adding many new views and transforms.

Exposure, gamma curves and white point functionality are not included
in this node, as there are native ways of doing that in the compositor.
These settings are marked non-editable in the Python API.

Pull Request: https://projects.blender.org/blender/blender/pulls/145069
2025-09-01 16:28:07 +02:00
Omar Emara
5cabc57af0 Compositor: Optimize nodes with Boolean and Menu inputs
This patch optimizes nodes with Boolean and Menu inputs for GPU
execution. This is done by using constant links instead of uniforms for
those inputs. This will cause shader recompilation, but is okay since
those inputs rarely change.

Pull Request: https://projects.blender.org/blender/blender/pulls/145329
2025-08-28 16:00:58 +02:00
Omar Emara
fdf95b53fa Compositor: Add Convolve node
This patch adds a simple Convolve node to the compositor.

Pull Request: https://projects.blender.org/blender/blender/pulls/144619
2025-08-28 15:58:39 +02:00
Jacques Lucke
c90a137a27 Nodes: wrap int in MenuValue type for menu sockets
Previously, we always just used `int` when dealing with menu values on the C++
side. It's currently the only type where we have the same base type (`int`) for
two different socket types (integer and menu sockets). This has some downsides:
* It requires special cases in some places.
* There is no function from static base type to socket type (which is useful for
  some utilities like `SocketValueVariant`).
* It implicitly allows operations on menu values that shouldn't be allowed such
  as arithmetic operations and conversions to and from other types.

This patch adds a new `MenuValue` type that is used for menu sockets in Geometry
Nodes and the (CPU) Compositor, clarifying the distinction between integer and
menu values.

Pull Request: https://projects.blender.org/blender/blender/pulls/144476
2025-08-13 15:43:37 +02:00
Omar Emara
d2d77a38a1 Compositor: Allow menu sockets for pixel nodes
This patch extends the support for menu sockets in the compositor to
also include pixel nodes. Menu sockets are not yet used in any node, so
this has no apparent effect.

Pull Request: https://projects.blender.org/blender/blender/pulls/144436
2025-08-12 15:36:48 +02:00
Omar Emara
8d1e26865d Compositor: Support strings sockets
This patch adds support for String sockets in the compositor. The
sockets are not yet used anywhere, but are added to aid development.

Pull Request: https://projects.blender.org/blender/blender/pulls/144327
2025-08-12 08:54:13 +02:00
Clément Foucault
9fbf7e9ec2 GPU: Remove wrapper type for gpu::UniformBuf
This is the first step into merging `DRW_gpu_wrapper.hh` into
the GPU module.

This is very similar to #119825.

Pull Request: https://projects.blender.org/blender/blender/pulls/144328
2025-08-11 09:46:45 +02:00
Clément Foucault
1388a70914 GPU: Remove wrapper type for gpu::Shader
This is the first step into merging DRW_gpu_wrapper.hh into
the GPU module.

This is very similar to #119825.

Pull Request: https://projects.blender.org/blender/blender/pulls/144229
2025-08-11 09:34:28 +02:00
Omar Emara
c3688f7bb7 Fix #136939: Translation is ignored in some nodes
The compositor ignores translation in certain nodes like Corner Pin.
Users find this unexpected as adjusting the translation of the input has
no effect on the output. The only alternative logical thing to do if
translation exists is to clip the image, which this patch do.

This affects the following nodes:

- File Output.
- Map UV (Image input).
- Corner Pin.
- Plane Track Deform.
- Bokeh Blur (Bokeh Kernel input).

Pull Request: https://projects.blender.org/blender/blender/pulls/144049
2025-08-06 13:46:34 +02:00
Omar Emara
cf32baff18 Fix #143892: Crash inside node group in viewport compositor
The viewport compositor crashes if the user enters a group node if no
viewer node exists. This is because the code still allowed group output
nodes to be added as compositor outputs in none root contexts, which is
forbidden since e34e6373b6. To fix this, we refactor the code to
disallow such cases.

Pull Request: https://projects.blender.org/blender/blender/pulls/143933
2025-08-04 13:39:02 +02:00
Benjamin Beilharz
fa2062ee96 Refactor: Renames the zero extension mode to clip
This commit renames the `ExtensionMode`'s `Zero` case to `Clip`.

Pull Request: https://projects.blender.org/blender/blender/pulls/143354
2025-07-28 10:45:12 +02:00
Omar Emara
ed8c072933 Refactor: Add default implementation for render_data
This patch adds a default implementation for the render_data method of
the compositor context. It defaults to the scene render_data.

Pull Request: https://projects.blender.org/blender/blender/pulls/143205
2025-07-28 07:55:46 +02:00
Omar Emara
2582630702 Refactor: Use Bounds for compositing region
This patch uses the new C++ Bounds structure for the composition region
returned by the compositor context.

Pull Request: https://projects.blender.org/blender/blender/pulls/143199
2025-07-25 15:40:45 +02:00
Omar Emara
b92b47f628 Refactor: Reduce compositor context pure virtual methods
The compositor context has a number of pure virtual methods that could
be optional or removed altogether, so this patch refactors that by
reducing unnecessary pure virtual methods.

Pull Request: https://projects.blender.org/blender/blender/pulls/143091
2025-07-25 07:50:52 +02:00
Omar Emara
e34e6373b6 Compositor: Replace Composite node with Group Output node
This patch replaces the Composite node with the Group Output node as the
primary compositor output. The old node was removed and versioned. This
was done for consistency with Geometry Nodes and in preparation for more
generic use of the compositor in VSE modifiers, layered compositing, NPR
multi-stage compositing, and more.

The Group Output node relies on the node tree interface, so we now have
a default interface of a single input and a single output. For now, only
the first input is considered while the rest are ignored, just like the
Geometry Nodes design. Furthermore, the input is required to be of type
color. Warnings and errors are issues if any of those are not met, also
similar to Geometry Nodes.

This introduces a new limitation: Composite outputs can no longer exist
in node groups, since they obviously then act as their respective group
outputs.

A refactor for the compositor scheduler is needed to simplify the logic
after this change, but this will be done in a separate patch.

Pull Request: https://projects.blender.org/blender/blender/pulls/142232
2025-07-24 13:41:56 +02:00
Omar Emara
b73d085e88 Fix: Crash when group node has no Group Output node
The compositor crashes when a group node has an output that is connected
to the compositor output, but the group internally has no Group Output
node. That's because the derived node tree structure would return a null
origin socket for this case, but the null socket is not handled by the
code. To fix this, we assume the input socket in such cases.

Pull Request: https://projects.blender.org/blender/blender/pulls/142944
2025-07-23 11:38:33 +02:00
Clément Foucault
32d64d35bb Refactor: GPU: Texture: Replace eGPUTextureFormat by TextureFormat
This offers better semantic and safety of the API.

Part of #130632

Pull Request: https://projects.blender.org/blender/blender/pulls/142818
2025-07-22 14:58:54 +02:00
Clément Foucault
f0254c2dcf Refactor: GPU: Remove unnecessary C wrappers for textures
This is the first step into merging `DRW_gpu_wrapper.hh` into
the GPU module.

This is very similar to #119825.

Pull Request: https://projects.blender.org/blender/blender/pulls/142732
2025-07-22 09:48:10 +02:00
Campbell Barton
c7ac5240d8 Core: use UTF8 string formatting for BKE_image (missed last commit) 2025-07-22 16:50:59 +10:00
Campbell Barton
4d4f518d80 Core: use UTF8 string formatting for BKE_image
Also use UTF8 string functions elsewhere for RenderSlot::name &
RenderView::name.
2025-07-22 16:41:13 +10:00
Omar Emara
a565e96f6c Compositor: Support Menu socket and Menu Switch node
This patch adds support for menu socket in the compositor as well as
the Menu Switch node from Geometry Nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/141792
2025-07-18 11:08:30 +02:00
Campbell Barton
ec8751f826 Cleanup: white-space around C-style comment blocks
Also use C++ style comments for disabling code.
2025-07-13 21:58:53 +10:00
Omar Emara
c53a839631 Compositor: Support host allocation for GPU compositing
This patch allows allocating results on the host even if the context
uses GPU. It also adds support for uploading the host result into a GPU
allocated result. This is done to allow using results for storing data
that gets computed on the CPU be end up on the GPU, like some of the
cached resources used by the compositor. Those resources are refactored
accordingly in this patch as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/141745
2025-07-11 07:55:11 +02:00
Omar Emara
fad9223a36 Merge branch 'blender-v4.5-release' 2025-07-09 11:44:54 +03:00
Omar Emara
23d06e9c9a Fix #141568: Implicit convert for single values return zeros
Implicit conversion for single values always return zero in GPU device.
That's because the conversion data was only stored on the CPU and not
uploaded to the GPU, so we ensure it gets uploaded to GPU.

Pull Request: https://projects.blender.org/blender/blender/pulls/141658
2025-07-09 10:43:03 +02:00
Habib Gahbiche
7f668be362 Nodes: rename "Hide" to "Collapse"
Design task: https://projects.blender.org/blender/blender/issues/139158

Renaming includes:
- UI description
- Python operator description
- Code (Enums, function names and variables)

Unchanged:
- Python API
  - `bpy.ops.node.hide_toggle()`
  - `node.hide`
- Python operators / scripts

The reasoning is that improved naming is not enough reason to break
backward compatibility for Python API.

Pull Request: https://projects.blender.org/blender/blender/pulls/141038
2025-06-30 15:28:19 +02:00
Benjamin Beilharz
ac82b70b87 Compositor: Add extension mode to Translate node
This patch introduces a new Extension Mode option to the Translate node,
replacing the current repeat option and adding an extra Extend mode when
the nearest boundary pixel is sampled. The option allows choosing from
Zero, Repeat, and Extend for each of the axis independently.

A new generic sample method was added to the Result class for sampling
with arbitrary interpolation and extension modes.

Pull Request: https://projects.blender.org/blender/blender/pulls/140607
2025-06-30 09:01:34 +02:00
Omar Emara
3b1d252431 Compositor: Support structure type
This patch adds support for the experimental structure types currently
used bu Geometry Nodes. Pixel nodes were declared as function nodes,
which gives dynamic structures for all their sockets. Other nodes now
explicitly declared their inputs as dynamic if not single value, while
the compositor_expects_single_value marker was removed in favor of the
StructureType::Single type.

Pull Request: https://projects.blender.org/blender/blender/pulls/140910
2025-06-25 11:54:48 +02:00
Omar Emara
27e716a165 Fix: Crash when using coordinates in the compositor
The compositor crashes when using any image coordinates in GPU mode.
That's because the realization operation didn't support Float2 images so
far. To fix this, we handle Float2 images for realization.
2025-06-25 09:43:05 +03:00
Omar Emara
383c8860a2 Compositor: Remove Texture node
This patch removes the Texture node from the compositor, which was based
on the legacy Internal Textures system in Blender. The main motivation
for removing this node is as follows:

- Procedural texturing nodes that previously existed in shading and
  geometry nodes are now supported in the compositor, which cover 95% of
  what is previously possible using and even adds new possibilities like
  Gabor, Bricks, and various improvements to existing texture types.
- The old texture system did not support GPU evaluation, so it was
  always computed and cached on the CPU, which causes bad performance
  especially for interactive use in the viewport compositor. While the
  new nodes are fully GPU accelerated and do not require any caching.
- The Texture node didn't support Texture nodes, so it was not fully
  supported and we so far had a warning about that.
- The general direction in Blender is to remove the old texture system,
  and the compositor was one of the last main users of it. 5.0 is thus
  the ideal time to remove such use.
- The Texture node was always and still is a source of bugs, since it
  relies on proper tagging for cache invalidation and updates, which is
  so far not perfect. It also suffers from UI/UX issues, since it needs
  to be adjusted from the properties panel, which can break if there are
  other texture nodes in the context.

This is a breaking change and no versioning was attempted since:

1. It is impossible to get the same results as before due to the use of
different random number generators, so any versioning would just give us
the general look.
2. The Texture node supports a lot of possible configurations. For
instance, each general texture can have many options for the basis type,
and each basis type might have multiple options. So versioning all of
that will take a lot of time, code, and effort.

Pull Request: https://projects.blender.org/blender/blender/pulls/140545
2025-06-24 11:54:39 +02:00
Omar Emara
4f32795ed5 Fix: Compositor assert on wrong result type
Since image coordinates now uses Float2 types, implicit input operations
should use the same type, which was missed in a recent refactor.
2025-06-24 10:26:16 +03:00
Omar Emara
0e304c813c Refactor: Use Float2 images internally if possible
Previously, Float2 images were internally stored as either Float3 or
Float4 images due to limitations in the implementation, which no longer
exists. So this patch refactors the compositor code to store Float2
images in actual Float2 containers, which gives better performance and
memory savings.

Some algorithms were adjusted to operate on Float2 instead of Float3 as
was previously the case.

Pull Request: https://projects.blender.org/blender/blender/pulls/140855
2025-06-23 14:34:37 +02:00
Benjamin Beilharz
3cdd38da67 Compositor: Expose EWA sampling in interpolation enum
- Adds Anisotropic (EWA) sampling to the compositor's interpolation
  enum.
- Any compositor nodes using EWA sampling are refactored and depend
  now on the interpolation enum.
- More refactoring in the RNA properties and DNA nodes to unify usage.

Pull Request: https://projects.blender.org/blender/blender/pulls/139833
2025-06-10 08:36:29 +02:00
Hans Goudey
77b14f2dcb Cleanup: Grammar: Fallback vs. fall back
The former is a noun or adjective, the latter is a verb.
2025-06-02 17:13:56 -04:00
Omar Emara
43110fc7a3 Compositor: Take virtual sockets into consideration
This patch takes virtual sockets into consideration in the compositor
code base. This mostly involves ignoring them as if they were
unavailable.

This is needed for use with nodes that use Extend sockets.

Pull Request: https://projects.blender.org/blender/blender/pulls/139582
2025-05-29 13:32:30 +02:00
Hans Goudey
c725bf324d Cleanup: Use functional style cast for node socket type enum 2025-05-28 15:47:26 -04:00
Omar Emara
a4502f82c1 Compositor: Add Image Coordinates node
This patch adds a new Image Coordinates node for the compositor. The
Texture Coordinates and Pixel Coordinates outputs were removed from the
Image Info node and were added to the new node instead. Additionally, a
new Normalized Coordinates output was added.

The Pixel Coordinates output now no longer includes half pixel offsets.

Pull Request: https://projects.blender.org/blender/blender/pulls/138935
2025-05-26 08:25:06 +02:00
Miguel Pozo
e6638d6e5e Refactor: GPU: GPUMaterial & GPUPass compilation
Cleanup and simplification of GPUMaterial and GPUPass compilation.
See #133674 for details/goals.

- Remove the `draw_manage_shader` thread.
  Deferred compilation is now handled by the gpu::ShaderCompiler
  through the batch compilation API.
  Batch management is handled by the `GPUPassCache`.
- Simplify `GPUMaterial` status tracking so it just queries the
  `GPUPass` status.
- Split the `GPUPass` and the `GPUCodegen` code.
- Replaced the (broken) `GPU_material_recalc_flag_get` with the new
  `GPU_pass_compilation_timestamp`.
- Add the `GPU_pass_cache_wait_for_all` and
  `GPU_shader_batch_wait_for_all`, and remove the busy waits from
   EEVEE.
- Remove many unused functions, properties, includes...

Pull Request: https://projects.blender.org/blender/blender/pulls/135637
2025-05-22 17:53:22 +02:00
Omar Emara
f790547fe9 Compositor: Use realize size for relative to pixel conversion
The Relative To Pixel node considers the original resolution of the
image with no transformation, while it is more useful for it to consider
the realized size instead, because that's what later processing nodes
will be using.
2025-05-21 10:31:09 +03:00