Commit Graph

2143 Commits

Author SHA1 Message Date
Campbell Barton
0fc27c8d81 Cleanup: spelling in comments 2024-09-20 13:14:57 +10:00
Campbell Barton
b70925a8cc Cleanup: prefer ASCII characters
Use ASCII quotes, punctuation so strings are easily editable.
2024-09-17 17:28:01 +10:00
Campbell Barton
e00fed43e6 Cleanup: redundant struct declarations 2024-09-11 16:25:25 +10:00
Campbell Barton
e34d9eeac7 Cleanup: use C-style comments, double quote Python text 2024-09-03 21:22:34 +10:00
Campbell Barton
d19c13eb82 Cleanup: spelling & punctuation in comments 2024-09-03 12:59:37 +10:00
Omar Emara
bb87690549 Fix #126984: CPU/GPU difference in jitter Lens Distort
The Lens Distort node is different between CPU and GPU when jitter is
enabled. That's because GPU incorrectly assumed that jitter with no
dispersion would have no effect. So we fix this by adjusting the
identity condition.

Further more, the green channel was not jittered for the GPU, that's
because the jitter was only seeded by the integration steps and was thus
constant for all channels. And since the green channel is the result of
addition of two opposite accumulations, the green channel was left
unaltered. To fix this, we include the start channel of the integration
in the seed to the jitter to make sure different channels get different
jitter.

Pull Request: https://projects.blender.org/blender/blender/pulls/126993
2024-08-30 18:44:29 +02:00
Omar Emara
96416f5401 Refactor: Abstract away the ShaderOperation class
This patch abstracts away the ShaderOperation class into an asbtract
PixelOperation class, which the ShaderOperation now implemenets. This
makes way for a new subclass that uses FN multi-functions for evaluation
for the new CPU compositor.

Reference #125968.
2024-08-27 14:42:11 +03:00
Omar Emara
b61e618886 Cleanup: Remove unused function 2024-08-26 14:44:36 +03:00
Omar Emara
9c3eb49f8b Cleanup: Compositor: Generalize naming of shader operations
This patch generalizes the naming of shader operations into "Pixel
Operations" to prepare for CPU-side support.
2024-08-26 14:38:10 +03:00
Campbell Barton
2ef76b89e4 Cleanup: remove duplicate code-comments 2024-08-23 10:19:53 +10:00
Omar Emara
997ab86906 Compositor: Add Composite node for new CPU compositor
This patch implements the Composite node for the new CPU compositor.
This is essentially equivalent to the Viewer node commit.
2024-08-22 14:48:52 +03:00
Omar Emara
9b903d4c6f Compositor: Implement type conversion in new CPU compositor
This patch implements implicit conversion operations for the new CPU
compositor.
2024-08-22 11:15:57 +03:00
Iliya Katueshenock
1b67be14c6 Cleanup: BKE: Nodes: Functions renaming
Use snake style naming for all the kernel nodes functions.
Omit kernel prefix in the names since of the using namespace.
Use full forms of the terms
('iter' -> 'iterator', 'ntree' -> 'node_tree', 'rem' -> 'remove', ...).

Pull Request: https://projects.blender.org/blender/blender/pulls/126416
2024-08-19 20:27:37 +02:00
Omar Emara
5930e0404a Compositor: Support Image node in new CPU compositor
This patch supports the Image node in the new CPU compositor.
2024-08-19 18:38:50 +03:00
Omar Emara
ba61fc9326 Compositor: Allow delayed typing for results
This patch allows result to have their types set after construction but
before allocation.
2024-08-19 11:07:12 +03:00
Omar Emara
5e88a1466c Compositor: Support Viewer node in new CPU compositor
This patch supports the viewer node in the new CPU compositor. To do
that, the context viewer output mechanism was refactored to allow CPU
storage by utilizing the result class as opposed to a GPU texture.
2024-08-16 16:40:43 +03:00
Omar Emara
75cc1e4a15 Compositor: Add utility for 2D parallel for 2024-08-16 16:03:16 +03:00
Omar Emara
a54cf472c3 Compositor: Add utils for accessing pixel data 2024-08-16 15:55:29 +03:00
Campbell Barton
b5e0b59736 Cleanup: remove space around identifiers in C-style comments 2024-08-15 20:46:00 +10:00
Omar Emara
59a4fdfc81 Cleanup: Fix warning about non void function 2024-08-13 16:36:05 +03:00
Omar Emara
edc4d0d84a Compositor: Support CPU storage in result class
This patch adds support for CPU side buffers for the result class. A new
storage type member was added to identify the type of buffer storage,
and allocation will either allocate a GPU texture or a CPU buffer based
on the context's GPU usage.
2024-08-13 16:13:22 +03:00
Omar Emara
58c10d191e Cleanup: Default initialize Result class members 2024-08-13 11:56:12 +03:00
Omar Emara
10f64edb3a Compositor: Allow non-pooled result allocation
This patch allows the result to be allocated using new textures as
opposed to using pooled texture. This is useful to allow the result
class to be used for persistent data like cached resources which can't
be pooled since it spans multiple evaluations.
2024-08-13 11:33:37 +03:00
Omar Emara
f40cf759c7 Compositor: Add experimental option for new CPU compositor
This patch introduces a new experimental option for the new CPU
compositor under development. This is to make development easier such
that it happens directly in main, but the compositor is not expected to
work and will probably crash.

Pull Request: https://projects.blender.org/blender/blender/pulls/125960
2024-08-08 15:40:06 +02:00
Omar Emara
885db0986c Refactor: Remove concept of temporary result
Temporary results are essentially results with a default reference count
of 1, so we default to 1 for all results and set the initial reference
count differently as need.
2024-08-06 19:37:18 +03:00
Omar Emara
69ae62a94e Refactor: Store reference to context in Result
This patch stores a reference to the entire context in the Result class,
as opposed to just the texture pool. This is in preparation for adding
CPU side texture to the result, such that allocations can automatically
allocate CPU or GPU textures based on context.
2024-08-05 18:38:32 +03:00
Sergey Sharybin
89ededeec4 Cleanup: Code style 2024-08-02 14:41:33 +02:00
Omar Emara
9c44349204 Fix #124023: File output always saves PNG in sRGB
The File Output node doesn't provide an option to save byte formats like
PNG in a space that is not sRGB. This is problematic for data images
like normal maps, which need to be saved as non-color.

This patch adds a Color Space option to the File Output node to allows
users to override the assumed color space. This also adds a new global
Save As Render option that is used if Use Node Format is enabled.

Pull Request: https://projects.blender.org/blender/blender/pulls/124238
2024-08-02 13:52:22 +02:00
Bill-Spitzak
2042669e23 Refactor: Reformulate math in domain realization
Directly calculate the transformation matrix by multiplying and
inverting the Domain matrices. This removes a double-invert and
decomposition of the matrices so it should be more accurate, and I think
makes the math a lot easier to figure out.

This also moves the "bias" for Nearest to be done in the input space
rather than output. This should make it select the same pixels from the
input even if the image is rotated 180 degrees.

Co-authored-by: Bill Spitzak <bills@sidefx.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/125543
2024-08-02 13:26:46 +02:00
Bill Spitzak
984feb48fc Cleanup: Remove unused integer wrap_pixel method 2024-08-01 14:22:30 +03:00
Bill Spitzak
1479c9cde6 Cleanup: Use compositor read() for read_elem_bilinear()
This patch reuses the read method for the read_elem_bilinear method to
deduplicate code and also get the same fixes that were committed in
ef1d22aea5.
2024-08-01 14:20:50 +03:00
Bill Spitzak
ef1d22aea5 Fix #124842: Translation leaves empty pixels at edges
The Translate node leaves empty pixels at the boundary of the image.
This caused by incorrect clipping when sampling the pixels. To fix this,
we adjust COM_MemoryBuffer::read to read using Extend or Repeat using
BLI interpolation, then multiply that by a clipping rectangle. The
read_elem_sampled function is now defined in terms of the read method.

This also coincidentally fixes off by half a pixel error in nearest
neighbour interpolation.
2024-08-01 14:06:50 +03:00
Jesse Yurkovich
67186ae8ac Fix: Error in builds without OCIO
The methods on the `OCIOColorSpaceConversionShader` expect
`shader_creator_` to be valid so, in case of a build without OCIO
support, ensure we have a valid GPUShaderCreator available.

In this case we use the "stub" implementation.

Pull Request: https://projects.blender.org/blender/blender/pulls/125631
2024-07-30 02:20:27 +02:00
Hans Goudey
570ac3ebaa Fix: Build error in lite build without OCIO 2024-07-29 14:16:01 -04:00
Jesse Yurkovich
69154a5e3b Fix #125402: Guard against missing OCIO data for realtime compositor
The newly added viewport compositor was missing a try-catch guard around
the OCIO `getProcessor` call. All prior call sites were protected except
this one.  Unhandled exceptions can occur if the user tries to use a
colorspace config that is not present in their OCIO configuration.

The surrounding code paths need some work in order to not crash at a
later point, which would also impact builds with no OCIO support at all.
In the case of no OCIO support at all, a warning label is placed on the
node as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/125526
2024-07-29 18:37:23 +02:00
Omar Emara
406a2d3ff0 Fix #125380: Viewport compositor slows complex scenes
The viewport compositor slows down complex scenes even if it has very
simple setups. That's because it internally computes previews which
involves a fair bit of CPU computation, however, those previews are
actually never written to the original tree, so previewers weren't
really visible so it is effectively redundantly computations.

To fix this, we double down on disabling previews for the viewport
compositor and avoid any redundant computations in that case.
2024-07-26 19:08:58 +03:00
Bill Spitzak
0d70481d15 Refactor: Optimize compositor realization shader
This patch optimizes the compositor realization shader by moving the
centring offset to the host code as opposed to the shader.
2024-07-25 18:58:29 +03:00
Bill Spitzak
b3e62d3052 Fix #124133: Compositor transforms are off by 0.5 pixels
The GPU compositor transforms are off by half a pixel in some cases.
That's because the realization shader was to perform transforms, and it
includes logic to move images by half a pixel if the domain and image
had different even/odd sizes. To fix this, we only move by half a pixel
if we are doing realization, while transforms are left as is.
2024-07-25 17:23:25 +03:00
Bill Spitzak
b76603b6bf Fix: Scale node is off by half a pixel
The Scale node was off by half a pixel because pixels were not evaluated
at their center. To fix this, we scale the pixels at their center.
2024-07-25 12:06:32 +03:00
Jesse Yurkovich
b112549296 Cleanup: Formatting 2024-07-24 22:27:29 +02:00
Bill Spitzak
f701a71b0e Fix: Compositor Rotate node is off by 0.5 pixel
The Rotate node was off by 0.5 pixels because pixels were not evaluated
at their center. Furthermore, the center of rotation was also off by
half a pixel. To fix this, we ensure rotation happen around the exact
center as well as rotate the pixels at their center.
2024-07-24 22:28:35 +03:00
Bill Spitzak
ab51d879c3 Fix #124339: Compositor artifacts with 0.5 translation
The compositor translate node produces artifacts when its fractional
part is 0.5. That's because GPUs do round-to-even for nearest neighbour
sampling in case samples were at pixel boundaries.

To fix this, we bias translations by a small value to break the
rounding and ensure predictable rounding direction.
2024-07-24 19:22:00 +03:00
Jesse Yurkovich
ec4fc2d34a CMake: Modernize the optional TBB dependency
This continues the cmake modernization effort and introduces support for
allowing our optional dependencies to integrate properly. TBB is added
here as it's proven troublesome to maintain correctly.

Currently the only Blender project which uses the TBB headers directly
is `blenlib`.  However, all downstream projects which require blenlib as
their dependency, and wish to properly make use of its threading
facilities, needed to define various TBB items in their CMake files. Not
only is this unnecessary and arcane, but several projects didn't do this
and ended up not using threading as well as producing ODR violations
along the way[1].

This PR makes TBB a modern dependency and exposes it PUBLIC'ly from
`blenlib`.  All downstream projects which depend on blenlib will now
receive everything they require from TBB automatically. This includes
the `WITH_TBB` define, the headers, and the library itself.

[1] blender/blender@05241f47f5

Pull Request: https://projects.blender.org/blender/blender/pulls/124916
2024-07-19 23:30:56 +02:00
Omar Emara
0e7f80b262 Refactor: Remove redundant Cryptomatte frame update
Cryptomatte layer initialization required the active scene to update the
image user frame, but the image user is already updated through other
mechanisms and is thus redundant to do at draw time, so we remove the
frame update call as well as the scene argument from the call chain. The
frame number of the image user is ignored at compositing time in any
case since it is set to the compositing scene frame.

This is needed for #124738.
2024-07-17 10:12:48 +03:00
Bastien Montagne
c607ead4b7 Refactor: Makesrna: move generated code further in C++.
This commit moves generated `RNA_blender.h`, `RNA_prototype.h` and
`RNA_blender_cpp.h` headers to become C++ header files.

It also removes the now useless `RNA_EXTERN_C` defines, and just
directly use the `extern` keyword. We do not need anymore `extern "C"`
declarations here.

Pull Request: https://projects.blender.org/blender/blender/pulls/124469
2024-07-15 16:39:45 +02:00
Omar Emara
970ec097e3 Cleanup: Fix missing declaration warning 2024-07-15 11:42:35 +03:00
Lukas Stockner
021bce8b48 Compositor: Add White Point mode to the Color Balance node
This adds a new mode to the Color Balance node, which applies a white point
transformation similar to the one applied in the view transform.

Unlike the view transform, the compositor node allows specifying both the
source and the destination white point for more flexibility. Both default
to the D65 white point, so just leaving the destination alone achieves the
same behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/124110
2024-07-14 23:22:58 +02:00
Campbell Barton
8fdb190278 Cleanup: typos in comments (duplicate words) 2024-07-14 18:55:43 +10:00
Omar Emara
308b53746b Fix #101263: Vector pass wrongly saved in File Output
The vector pass and potentially other vectors that store 4 values are
stored wrongly, in particular, the last channel is ignored. To fix this
we identify if a vector pass is 4D and store the information in the
result meta data, then use this information to either save a 3D or a 4D
pass in the File Output node.

This is a CPU implementation of the same mechanism in the GPU compositor
implemented in 57a6832b17. The CPU implementation is a bit more complex
because the CPU compositors stores 4D vectors in color images internally
which can lead to information loss in case of implicit conversion when
the File Output has vector sockets. So what we do is force all vector
inputs to the File Output operation to be color, then save that as 3D or
4D depending on the meta data as well as the original UI socket type.

Pull Request: https://projects.blender.org/blender/blender/pulls/124580
2024-07-12 12:53:16 +02:00
Jesse Yurkovich
6ace3eb065 Merge branch 'blender-v4.2-release' 2024-07-11 08:44:58 -07:00