Commit Graph

2465 Commits

Author SHA1 Message Date
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
Benjamin Beilharz
570f44a059 Compositor: Extension modes for corner pin mode
This commit introduces the extension modes to the corner pin node and
further streamlines the node properties by wrapping all props in the node
storage. Therefore, the interpolation mode has been removed from the
custom properties of the node and moved into the node storage.

Right now, the extension modes only work for non-anisotropic filtering.

Pull Request: https://projects.blender.org/blender/blender/pulls/141570
2025-08-05 11:12:54 +02:00
Tenkai Raiko
de9b24abad Fix: Map UV node does not work with single values
The Map UV node does not work when the UV input is a single value, where
it is expected that the output will also be single value. This was
simply not implemented for GPU, so this patch does that.

Pull Request: https://projects.blender.org/blender/blender/pulls/143096
2025-08-05 08:09:25 +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
Christoph Neuhauser
f03392a09a Fix #141436: Dilate node Feather mode has artifacts
The Dilate node Feather mode has artifacts on Intel Windows GPUs. This
is due to a wrong shader image format. So this patch fixes that by using
the correct single channel format.

Pull Request: https://projects.blender.org/blender/blender/pulls/143748
2025-08-01 10:52:33 +02:00
Jacques Lucke
890ab23e0d Refactor: Nodes: return pointer instead of reference from in/output_by_identifier
This makes it possible to use these methods in cases where it's not guaranteed
that the identifier exists on a node.
2025-07-31 21:58:58 +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
8cb7aafae2 Refactor: Use generic name for compositor context IO methods
This patch renames some IO methods in the compositor context to be more
generic. This is in preparation for more generic use of the compositor.

Pull Request: https://projects.blender.org/blender/blender/pulls/143193
2025-07-25 14:40:17 +02:00
Mohamed Hassan
c1f52b8e91 Compositor: Improve Fog Glow glare realism
This patch improves the realism of the Fog Glow mode of the Glare node
based on the Photopic model described in:

  Physically-Based Glare Effects for Digital Images" by G. Spencer, P.
  Shirley, K. Zimmerman, and D. P. Greenberg.

This is a breaking change that can't be versioned, but it is worth it
for the superior realism of the new model.

Pull Request: https://projects.blender.org/blender/blender/pulls/140646
2025-07-25 10:09:32 +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
Omar Emara
0a152ddddf Compositor: Add Djsoint and Conjoint Over operations
This patch adds the Disjoint and Conjoint Over operations to the Alpha
Over node.

Pull Request: https://projects.blender.org/blender/blender/pulls/141439
2025-07-09 06:59:55 +02:00
Omar Emara
0fbf7010d9 Merge branch 'blender-v4.5-release' 2025-06-30 19:58:46 +03:00
Tenkai Raiko
8efcc0475d Fix: Dilate node clamps negative values on GPU
The Dilate node clamps negative values on GPU but works fine on CPU.
This is because the minimum value was used as FLT_MIN, but it should
actually be -FLT_MAX.

Pull Request: https://projects.blender.org/blender/blender/pulls/141144
2025-06-30 18:35:10 +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
Habib Gahbiche
8e966cceaa Compositor: Support rotation for split node
The split is now defined by a line that can have an arbitrary angle.

This PR implements the node only, the gizmo is implemented in #140356

Pull Request: https://projects.blender.org/blender/blender/pulls/140208
2025-06-24 17:18:15 +02: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
bc7412860a Compositor: Support all interpolation types for Map UV node
This patch adds support for Bilinear and Bicubic interpolation for the
Map UV node.

Pull Request: https://projects.blender.org/blender/blender/pulls/140351
2025-06-19 16:18:13 +02:00
Omar Emara
9e0e76f8ab Compositor: Remove Dot output from Normal node
This patch removes the Dot output from the Normal node. This previously
computed negative the dot product of the normalized inputs. We are
removing it because we now have a Vector Math node that can compute the
dot product, and because it output is confusing, considering it computes
the negative of the product and it implicitly normalized the input.

The node was moved to the input category, and might be later extended to
allow normal picking from the scene or normal passes.

Fixed #132770.

Pull Request: https://projects.blender.org/blender/blender/pulls/140599
2025-06-19 16:12:45 +02:00
Mohamed Hassan
0a4b92678c Compositor: Improve Glare quality option
This patch enhances the quality setting of the Glare node. Previously,
Medium and Low quality were implemented using a single tap interpolation
downsampling filter, which means small highlights that only span a small
number of pixels could be missed during downsampling, and that might
change across frames, causing flickering.

To fix this, we use a higher quality downsampling filter that averages
the entire 2x2 or 4x4 pixel blocks for the Medium and Low quality
settings respectively.

The upsampling pass also needs to be improved to avoid offsets, but this
will be implemented separately.

Pull Request: https://projects.blender.org/blender/blender/pulls/140237
2025-06-16 10:38:40 +02:00
Benjamin Beilharz
8b67050575 Compositor: Add interpolation options to displace node
This commit introduces interpolation methods (Nearest, Bilinear,
Bicubic) for the Displace node in the compositor:

- Exposes a dropdown selector for interpolation selection.
- Introduces different methods for Anisotropic and other interpolation
  methods.

Reference: #119592.

Pull Request: https://projects.blender.org/blender/blender/pulls/139802
2025-06-12 14:53:15 +02:00
Omar Emara
9bcb536c95 Fix #138009: Extend Bounds doesn't work with Fast Gaussian
The Extend Bounds input has no effect when the Fast Gaussian filter is
used. Similarly, it has no effect if the Bokeh Blur node is using
variable size. This is a known limitation and was just not implemented.

So to fix this, we implement a general solution that works globally
across the node by pre-padding the inputs of the blur. This uses more
memory but also speeds up the base case when Extend Bounds is disabled,
while also reducing the binary size due to fewer blur specializations.

The variable size Bokeh Blur test was updated since it Extend Bounds was
silently ignored.

Pull Request: https://projects.blender.org/blender/blender/pulls/140192
2025-06-11 11:41:00 +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
Mohamed Hassan
3883a88d4e Compositor: Maintain alpha in Lens Distortion node
The alpha channel value was previously hard codded to one in the lens
distortion node. This patch solves that by integrating the alpha as well
in the radial distortion mode and taking the average alpha in the
horizontal case.

This breaks backward compatibility, but is what users what in most
cases, so it is acceptable.

Fixes #134658.

Pull Request: https://projects.blender.org/blender/blender/pulls/137994
2025-06-10 07:42:35 +02:00
Omar Emara
6bf52d11f1 Fix #139327: Movie distortion result is cropped
The Movie distortion node crops its data if the movie size differs from
the input size. That's because boundary extensions do not take
calibration size into account. To fix this, we use the same coordinates
range as the distortion grid computation, which computes the distortion
in the space of the calibration size.

Pull Request: https://projects.blender.org/blender/blender/pulls/139822
2025-06-04 12:24:33 +02:00
Clément Foucault
e69762b8dd GPU: Add compilation constants
Compilation constants are constants defined in the create info.
They cannot be changed after the shader is created.
It is a replacement to macros with added type safety.

Reuse most of the logic from Specialization constants.

Pull Request: https://projects.blender.org/blender/blender/pulls/139703
2025-06-03 17:34:04 +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