2510 Commits

Author SHA1 Message Date
Clément Foucault
a003b27244 Refactor: Compositor: Use template instead of macros for compositor_parallel_reduction.glsl
Rel #143582

This also adds support for C++ compilation of this shader.
See https://developer.blender.org/docs/features/gpu/tools/cpp_shader_compilation/

Pull Request: https://projects.blender.org/blender/blender/pulls/144904
2025-10-17 18:38:07 +02:00
Clément Foucault
03d7ae9bf3 Compositor: Add support for shader C++ compilation
This is mostly stubs for now but they should be
ported overtime.

See the documentation for more info on this:
https://developer.blender.org/docs/features/gpu/tools/cpp_shader_compilation/

Splited from #144904

Pull Request: https://projects.blender.org/blender/blender/pulls/148261
2025-10-17 14:21:24 +02:00
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
Campbell Barton
c4b2c1c19e Cleanup: spelling (check_spelling_*), trailing spaces in comments 2025-10-12 12:12:46 +11:00
Omar Emara
42263644c1 Fix #147377: Glare Kernel is dependent on quality
The Kernel mode of the Glare node is dependent on the quality input of
the node. This patch makes it such that it is independent. This is down
by downsampling the kernel with the same amount the image was
downsampled.

Pull Request: https://projects.blender.org/blender/blender/pulls/147811
2025-10-10 16:52:15 +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
Omar Emara
f113af51ab Compositor: Rename Lift to Offset in Color Correction node
This patch renames the Lift parameters to Offset, which is more accurate
and inline with other software.

Pull Request: https://projects.blender.org/blender/blender/pulls/147543
2025-10-08 11:03:47 +02:00
Omar Emara
7d99ac26cc Fix #146886: Zero division in Distance Key node
Pull Request: https://projects.blender.org/blender/blender/pulls/147550
2025-10-07 17:22:36 +02:00
Omar Emara
a113121562 Compositor: Perform LGG Color Balance in linear space
This patch adjusts the LGG Color Balance mode to operate in linear space
as opposed to sRGB space, which is more inline with other software and
is more expected to the user.

Versioning was added using pre and post gamma correction, but it is
very slightly different in the blacks because the gamma node only does
power correction.

Pull Request: https://projects.blender.org/blender/blender/pulls/147533
2025-10-07 17:04:34 +02:00
Aras Pranckevicius
8a74f7c0b0 VSE: Execute modifiers in strip-local space (#145688)
Currently when a strip has a transform that does not fill the whole
render area, first the image of the strip is transformed, and then
any modifiers are applied on that. This is mostly in the new
Compositor modifier, where procedural textures, gradients, image
coordinates "stick to the screen" instead of following the transformed
strip.

This changes the behavior so that first the modifiers are applied
to the strip image, and then the strip is transformed. This is
potentially a visually breaking change:
- This can alter visual look of existing strip, especially if they are
  scaled. Previous behavior was first scale filtering, then modifier;
  now it is first modifier, then scale filtering.
- Most obvious change is Compositor modifier (which is new in 5.0).
- Compositor modifier can actually expand the input image (e.g. Blur
  node with "expand bounds" option set), and that works.
- Note that Masks continue to be applied in global/screen space. There
  can be small look differences with rotated/scaled strips that use
  masks, due to Mask application now needing to do filtered mask image
  lookups.
- If anyone needs previous behavior (modifier is applied on the
  "whole screen"), they can put transformed strip into a meta strip,
  and apply the modifier on the meta strip itself.

Compositor modifier examples with images in the PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/146181
2025-10-07 13:51:41 +02:00
Brecht Van Lommel
6e740f9a49 Color Management: Support build against OpenColorIO 2.5.0
But do not yet take advantage of any of its new features. For Linux
distributions that want to upgrade before we do.

Fix #147227

Pull Request: https://projects.blender.org/blender/blender/pulls/147232
2025-10-03 18:32:30 +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
fe213f80a4 GPU: Shader: Make info files generated
This is the first step of moving the create infos
back inside shader sources.

All info files are now treated as source files.
However, they are not considered in the include tree
yet. This will come in another following PR.

Each shader source file now generate a `.info` file
containing only the create info declarations.

This renames all info files so that they do not
conflict with their previous versions that were
copied (non-generated).

Pull Request: https://projects.blender.org/blender/blender/pulls/146676
2025-09-25 10:57:02 +02:00
Omar Emara
5462d90fa8 Compositor: Make Bokeh Blur size input in pixels
This patch makes the Size input of the Bokeh Blur node defined in
pixels as opposed to being relative to 0.01 the greater dimension of the
image.

Pull Request: https://projects.blender.org/blender/blender/pulls/146367
2025-09-24 14:45:54 +02:00
Omar Emara
92be913a2a Compositor: Remove XY scale from Displace node
This patch removes the XY scale inputs from the Displace node. The
inputs were redundant since they were just multiplied by the vector.
This simplifies the node and improves performance slightly.

Additionally, the Vector input was renamed to Displacement since it no
longer specifies a direction.

Pull Request: https://projects.blender.org/blender/blender/pulls/146356
2025-09-24 13:33:24 +02:00
Omar Emara
7ec89d1bfb Compositor: Reorder inputs accordingly to importance
This patch reorders the inputs of some of the compositor nodes
accordingly to their importance. The importance is already quantified
internally using the domain priority of the input, so we needn't make
any subjective judgement and just order by the priority.

This breaks forward and backward compatibility if input indices were
used as opposed to input identifiers due to the different order.
Handling compatibility is not impossible, but is difficult, and it was
already ignored in many past node changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/146311
2025-09-23 17:32:07 +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
Omar Emara
3b1faf7594 Compositor: Turn menu options to sockets for pixel nodes
This patch turns node Menu options into menu inputs for Pixel nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/145596
2025-09-15 12:47:06 +02:00
Clément Foucault
bb8e987904 GPU: Simplify matrix lib to reduce dead code
This greatly reduce shader compilation time on some systems.

Pull Request: https://projects.blender.org/blender/blender/pulls/146100
2025-09-15 12:07:26 +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
b10d767c4e Fix #134920: File Output writes frame for single render
The File Output node always appends the frame number even if the render
is not an animation. This patch makes it such that the frame number is
only written if the render is an animation. The user can use a frame
variable to manually append the frame number if needed.

The command line rendering interface already uses animation rendering in
all cases, so it should not be affected. However, rendering using the
render.render() operator with animation=False will see the behavior
change, however, setting animation=False and start_frame and end_frame
to the same frame number should be sufficient to restore the old
behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/141209
2025-09-12 09:01:31 +02:00
Omar Emara
f699b34689 Fix #146057: Crash when using Convolve node with GPU
The Convolve node crashes Blender if used with GPU device and its output
is used multiple times. This is due to a use after free error, because
the convolve node ignored the reference count of the output.

To fix this, we retain the reference count of the output by stealing the
data of the GPU-side buffer, instead of overwriting the output with it.

Pull Request: https://projects.blender.org/blender/blender/pulls/146074
2025-09-11 12:18:35 +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
Omar Emara
180accfbaa Fix #145439: Artifacts in Movie Distortion with half precision
The Movie Distortion node produces artifacts when used with half
precision context. This is because distortion grids require full
precision for high quality results, which this patch does.

Pull Request: https://projects.blender.org/blender/blender/pulls/145640
2025-09-03 10:46:33 +02:00
Campbell Barton
f3f50b2a4c Build: unbreak lite builds 2025-09-02 00:49:57 +00: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
Brecht Van Lommel
f7891ead7b Fix: Compositor Convert Color Space node fails on GPU with some colorspaces
Use GPU_shader_preprocess_source like we do for the viewport display shader.
Otherwise the ACES 2.0 view transform fails.

Pull Request: https://projects.blender.org/blender/blender/pulls/145069
2025-09-01 16:28:07 +02:00
Campbell Barton
9e72f27717 Cleanup: unused variable warnings 2025-08-29 14:40:48 +10: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
Omar Emara
149a47ba57 Compositor: Turn Menu options to inputs
This patch turns node Menu options into menu inputs. This patch only
covers node operations like Filter, Distort, and so on. Pixel nodes like
Color Balance, Matte, and so on will be done in a separate patch.

Pull Request: https://projects.blender.org/blender/blender/pulls/144495
2025-08-28 08:45:23 +02:00
Mohamed Hassan
b7742e6988 Compositor: Add Jitter input to Glare Sun beams
This patch introduces a new Jitter option for the Sun Beams mode of the
Glare node. If non-zero, is uses an approximation that is faster to
compute but makes the result more noisy.

Internally, this is computed by reducing the number of samples used to
integrate the results and introducing a random offset during
integration.

Pull Request: https://projects.blender.org/blender/blender/pulls/141789
2025-08-20 15:10:18 +02:00
Alberto12345678999
d803ee4c79 Nodes: Port shader Gamma node to Geometry Nodes
This patch unifies the Gamma node across editors:

- Compositor now uses the Shader Gamma node implementation.
- Geometry Nodes also uses the node as a new addition.
- UI-wise in the Compositor, only socket labels change to "Color".

Forward compatibility is broken for the compositor, and the python API
changed, since the node's ID name is now ShaderNodeGamma as opposed to
CompositorNodeGamma.

Pull Request: https://projects.blender.org/blender/blender/pulls/142414
2025-08-20 08:46:34 +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
Mohamed Hassan
ce7759bae6 Compositor: Removing Sun Beams node
This patch removes the Sun Beams node since it is now part of the
Glare node. It is versioned using a Glare node of Sun Beams type.

Pull Request: https://projects.blender.org/blender/blender/pulls/144110
2025-08-12 19:53:54 +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
7a97105b28 GPU: Remove wrapper type for gpu::StorageBuf
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/144329
2025-08-11 10:35:53 +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
Clément Foucault
628a10a9fb GPU: Shader Preprocess: Add basic support for struct methods
This adds the following features:
- `class` keyword support: checked by C++, mutated to struct for shader.
- `private` and `public` keywords: checked by C++, removed for shader.
- `static` methods.
- `const` and non-const methods.

What is not supported:
- Constructors
- Destructors
- operators
- Method definition outside of class definition
- member reference without `this` keyword.

This is implemented using a very simple lexer/parser allowing semantic traversal.

Pull Request: https://projects.blender.org/blender/blender/pulls/144025
2025-08-08 16:49:15 +02:00
Campbell Barton
cccc2c77c5 Cleanup: consistent for C-style comment blocks 2025-08-08 07:37:33 +10: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
Campbell Barton
e8501d2f54 Cleanup: grammar corrections, minor improvements to wording
Also back-tick quote some code references in comments
to differentiate them from English text.
2025-08-06 00:20:39 +00:00
Hans Goudey
1d34381abd Cleanup: Fix missing declaration warnings in compositor 2025-08-05 12:11:27 -04:00