Commit Graph

4303 Commits

Author SHA1 Message Date
Omar Emara
07e051d7cd Realtime Compositor: Implement zero cost external images
This patch implements a new mechanism for compositor results to wrap
external images, such as those cached in the static cache manager.
Thereby enabling zero cost use of those resources, which previously
needed a copy at each evaluation.

Pull Request: https://projects.blender.org/blender/blender/pulls/115574
2023-11-30 09:10:41 +01:00
Campbell Barton
3b5031f1cb Cleanup: use 'r_' prefix for output arguments, order last
Also clarify some naming.
2023-11-30 10:42:18 +11:00
Lukas Tönne
5bc82b5b7c Geometry Nodes: Remove experimental volume nodes
The new grid socket (#115270) will make these nodes obsolete and
provide more elegant ways of implementing the features. Removing
these nodes now to clean up and make future changes simpler.

Pull Request: https://projects.blender.org/blender/blender/pulls/115567
2023-11-29 16:02:06 +01:00
Jacques Lucke
7c1a0e57ca Cleanup: remove unused code 2023-11-29 14:35:04 +01:00
Jacques Lucke
7a7b7196f9 Geometry Nodes: extract global data passed to a geometry nodes invocation to separate struct
This avoids some duplication between the modifier and operator evaluation
contexts and also makes it easier to make independent from a specific
evaluation context (so e.g. the simulation nodes code shouldn't care whether
it's used from a modifier or operator.

Pull Request: https://projects.blender.org/blender/blender/pulls/115512
2023-11-29 13:22:20 +01:00
Hans Goudey
7e3ba529ea Cleanup: Move four blenkernel headers to C++ 2023-11-28 16:05:12 -05:00
Hans Goudey
21a2390f4c BLI: Add utility to reverse index mask
This utility was already duplicated in two places and planned to be used
more. While we should usually avoid creating arrays the size of the
indexed array (rather than the size of the mask), sometimes it does seem
to be the best option, and we're helped by the fact that most memory
stays unintialized for a small mask (allocating but not writing to memory
pages at all generally isn't too expensive).

Pull Request: https://projects.blender.org/blender/blender/pulls/115491
2023-11-28 17:32:17 +01:00
Ray molenkamp
dbb2844ed9 Cleanup: CMake: Modernize bf_functions dependencies
Pretty straightforward

- Remove any bf_functions paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/115427
2023-11-28 01:14:15 +01:00
Hans Goudey
f1c0bce651 Cleanup: Use optional for original indices in extrude node
This is simpler than checking if spans are empty in separate lines.
2023-11-27 12:09:06 -05:00
Hans Goudey
c31718649d Geometry Nodes: Rewrite parts of extrude mesh node
The node is still a bit non-standard in that it resizes an existing
mesh rather than creating a new one, but this commit makes the extrude
node a bit more similar to other mesh operations and makes other
miscellaneous improvements, including:
- Less use of intermediate states (compared to initial or final)
- Topology map building is no longer reimplemented for the node
- Attribute interpolation happens in a more familiar way
- Some topology maps can be skipped if a domain is empty
- More use of `IndexMask` instead of an array of indices
- Logarithmic cost index mask lookup is avoided
- Build index maps instead of implementing attribute propagation
  separately for every type

Overall these changes might improve performance in a few cases, and
they reduce Blender's binary size by 58 KB. Edge indices are different
in some cases of the edge mode, so the test files are updated.
2023-11-27 10:57:06 -05:00
Lukas Tönne
227a4eae77 Make ImplicitSharingPtr constructor from data pointer explicit
The ImplicitSharingPtr has an implicit constructor for raw pointers.
This has unintended effects when comparing an ImplicitSharingPtr to a
raw pointer: The raw pointer is implicitly converted to the shared
pointer (without change in refcount) and when going out of scope will
decrement user count, eventually freeing the data.

Conversion from raw pointer to shared pointer should not happen
implicitly. The constructor is made explicit now. This requires a little
more boilerplate when constructing a sharing pointer. A special
constructor for the nullptr is added so comparison with nullptr can
still happen without writing out a constructor.

Pull Request: https://projects.blender.org/blender/blender/pulls/115476
2023-11-27 15:53:29 +01:00
Jacques Lucke
d34618e6b4 Geometry Nodes: muting zone input and output nodes is not allowed 2023-11-27 10:23:40 +01:00
Habib Gahbiche
46131a6813 Cleanup: silence warning inconsistent-missing-override
Silence warning `'call' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]`

Pull Request: https://projects.blender.org/blender/blender/pulls/115440
2023-11-27 08:01:12 +01:00
Campbell Barton
1eff48a838 Cleanup: spelling in code 2023-11-27 10:55:39 +11:00
Campbell Barton
27c660707d Cleanup: spelling in comments, variables 2023-11-27 09:54:36 +11:00
Ray Molenkamp
1b6cd937ff Cleanup: CMake: Modernize bf_imbuf dependencies
Pretty straightforward

- Remove any bf_imbuf paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/115425
2023-11-25 23:37:24 +01:00
Ray Molenkamp
6b70c04724 Cleanup: CMake: Modernize bf_depsgraph dependencies
Pretty straightforward

- Remove any bf_depsgraph paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/115422
2023-11-25 22:51:59 +01:00
Ray Molenkamp
b683bcc46c Cleanup: CMake: Modernize bf_intern_clog dependencies
Pretty straightforward

- Remove any bf_intern_clog paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/115323
2023-11-24 17:12:24 +01:00
Jacques Lucke
cbe0cf0bb0 Geometry Nodes: add two inputs in Index Switch by default
Having this node with only a single input is not useful.
2023-11-24 09:57:38 +01:00
Jacques Lucke
8eaf89cc41 Geometry Nodes: set soft min/max in Index Switch node 2023-11-24 09:54:12 +01:00
Hans Goudey
9a28852494 Cleanup: Generalize some attribute propagation functions
Add a function that copies selected values to groups of values in the
result array. Add a runtime-typed version and a version for affecting
all attributes. Also make the "gather_group_to_group" follow the
same pattern.
2023-11-22 15:48:42 -05:00
Clément Foucault
44fa9f37eb GPUMaterial: Add volume shader flags
This allows for some optimization when we know
some effects are not present. Also this is needed
to detect the case when world contains absorption
in order to disable distant lighting.

Related #114062
2023-11-22 21:18:19 +01:00
Hans Goudey
8d5aa6eed4 Geometry Nodes: Index switch node
Add an "Index Switch" node which is meant as a simpler version of
the "Menu Switch" from #113445 that doesn't allow naming items
or displaying them in a dropdown, but still allows choosing between
an arbitrary number of items, unlike the regular "Switch" node.
Even when the Menu Switch is included (which should be in the
same release as this), it may still be helpful to have explicit mapping
of indices, and a fair amount of the internals can be shared anyway.

Pull Request: https://projects.blender.org/blender/blender/pulls/115250
2023-11-22 16:11:32 +01:00
Jacques Lucke
e50a601a95 Fix: crash when getting node tree logger
It's expected that something is emplaced into `tree_logger_`
by this function in all cases, even if it's just null.
2023-11-22 14:48:51 +01:00
Hans Goudey
49087a84d0 Geometry Nodes: Use rotation socket for the object info node
See 600a133521 and #92967.
2023-11-22 08:25:32 -05:00
Omar Emara
48d7d60c96 Realtime Compositor: Rewrite inpaint node
This patch rewrites the Inpaint node in the Realtime Compositor. The old
method suffered from discontinuities and singularities in the inpainting
regions. Furthermore, it ignored semi-transparent areas.

The new method is inspired by a two pass method described by the paper:

  Rosner, Jakub, et al. "Fast GPU-based image warping and inpainting for
  frame interpolation." International Conferences on Computer Graphics,
  Vision and Mathematics. 2010.

In particular, we first fill the inpainting region using jump flooding,
then we apply a variable size blur pass whose size is proportional to
the distance to the inpainting boundary. The smoothed region is then
mixed with the input using its alpha.

The new method is much closer to the Bertalmio-style diffusion-based
inpainting methods, and thus can more accurately close holes than
existing methods.

The aforementioned method requires variable size blur, which is quite
expensive for this use case, so a new implementation was added that
approximates the method using a separable implementation, which provides
a visually pleasing result assuming a sufficiently smooth radius field,
which is true for our case since the field is an SDF.

Fixes: #114422

Pull Request: https://projects.blender.org/blender/blender/pulls/114849
2023-11-22 13:23:02 +01:00
Iliya Katueshenock
274b2dbe5e Geometry Nodes: Parallel Edges to Face Groups
This loop might be 7x faster (not whole node).
All other code is already parallel, not sure why this was disabled.
Potentially, this was missed after some cleanup.

Pull Request: https://projects.blender.org/blender/blender/pulls/115246
2023-11-21 23:40:14 +01:00
Iliya Katueshenock
33442e0992 Geometry Nodes: Edges to Face Groups speedup
Remove unnecessary N^2\n complexity. Disjoint set will join all
elements in list, even without fully-related joins. Usually cost is
small (10%~ for this specific function), but some certain files might
be 10000x slower. But that is very corner case.

Pull Request: https://projects.blender.org/blender/blender/pulls/115245
2023-11-21 23:36:41 +01:00
Iliya Katueshenock
b70d387f2a Fix: Geometry Nodes: wrong field inferencing in Shortest Edge Paths node
Pull Request: https://projects.blender.org/blender/blender/pulls/115139
2023-11-21 14:52:43 +01:00
Hans Goudey
6ba9ee88c8 Geometry Nodes: Node tools: Support warnings
Warnings created during evaluation of the node group are passed as
warnings to the operator. This is done using the existing logging
system, which we could also use to get socket inspection working
in the future.

See #101778

Pull Request: https://projects.blender.org/blender/blender/pulls/115237
2023-11-21 14:27:21 +01:00
Jacques Lucke
96b3afe065 Cleanup: rename node group to group node context
`GroupNodeComputeContext` is the more correct name because it's
specifically about a group node that invokes another node tree.
The old name makes it sound like it should be used because a node group
is invoked but does not tell anything about what invoked it.
For example, the current context in a node group can also be a
`ModifierComputeContext` if that's what invoked it.
2023-11-21 14:12:23 +01:00
Hans Goudey
ef3897f6a4 Fix #115202: Set Selection node crash in object mode
The geomery output wasn't set.
2023-11-20 18:17:54 -05:00
Hans Goudey
f2bcd73bd2 Mesh: Move sculpt mask to a generic attribute
Store paint masks as generic float attributes, with the name
`".sculpt_mask"`. This is similar to 060a534141, which made
the same change for face sets. The benefits are general
consistency, nicer code, and more support in newer areas
that deal with attributes like geometry nodes.

The RNA API is replaced with one created in Python. The new
API only presents a single layer as an attribute class, so it
should be simpler to use in general:
- Before: `object.data.vertex_paint_masks[0].data[0].value`
- After: `object.data.vertex_paint_mask.data[0].value`

Pull Request: https://projects.blender.org/blender/blender/pulls/115119
2023-11-20 17:42:01 +01:00
Jacques Lucke
a976cf4876 Cleanup: reduce boilerplate for equality operators for structs
Pull Request: https://projects.blender.org/blender/blender/pulls/115088
2023-11-20 09:39:13 +01:00
Hans Goudey
41f9f2753a Refactor: Mesh: Include wrapper positions in bounds result
Avoid the need to call the separate `BKE_mesh_wrapper_minmax` function
that dealt with the edit mesh wrapper. This makes the API inconsistent,
since other mesh functions don't implicitly deal with the wrapper.
But the bounds are a bit of a special case anyway in regard
to the GPU subdivision wrapper already, and this is much more
convenient in the rest of the refactors for #96968.
2023-11-19 18:36:19 -05:00
Hans Goudey
62b4555d01 Cleanup: Return Bounds type directly in mesh to volume code 2023-11-19 16:57:13 -05:00
Iliya Katueshenock
31abb2b3af Geometry Nodes: Edge Paths to Selection node speedup
Parallelize vertex and edge selection loops.
In a test file, the node runtime changed from 5.08 to 0.83 ms.

Pull Request: https://projects.blender.org/blender/blender/pulls/115131
2023-11-19 15:32:01 +01:00
Lukas Tönne
c845233d1c Nodes: Move ValueOrField struct into blenkernel
This struct is currently defined in the `functions` module but not actually used there. It's only used by the geometry nodes module, with an indirect dependency from blenkernel via simulation zone baking. This scope is problematic when adding grids as socket data, which should not be part of the functions module.

The `ValueOrField` struct is now moved to blenkernel, so it can be more easily extended to other kinds of data that might be passed around by geometry nodes sockets in future. No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/115087
2023-11-18 13:11:39 +01:00
Hoshinova
0b11c591ec Nodes: Merge Musgrave node into Noise node
This path merges the Musgrave and Noise Texture nodes into a single
combined Noise Texture node. The reasoning is that both nodes
intrinsically do the same thing, which is the layering of Perlin noise
derivatives to produce fractal noise. So the patch de-duplicates code
and unifies the use of fractal noise for the end use.

Since the Noise node had a Distortion input and a Color output, while
the Musgrave node did not, those are now available to the Musgrave types
as new functionalities.

The Dimension input of the Musgrave node is analogous to the Roughness
input of the Noise node, so both inputs were unified to follow the same
behavior of the Roughness input, which is arguable more intuitive to
control. Similarly, the Detail input was slightly different across both
nodes, since the Noise node evaluated one extra layer of noise. This was
also unified to follow the behavior of the Noise node.

The patch, coincidentally fixes an unreported bug causing repeated
output for certain noise types and another floating precision bug
#112180.

The versioning code implemented with this patch ensures backward
compatibility for both the Musgrave and Noise Texture nodes. When
opening older Blender files in Blender 4.1 the output of both nodes are
guaranteed to always be exactly identical to that of Blender files
created before the nodes were merged in all cases.

Forward compatibility with Blender 4.0 is implemented by #114236.
Forward compatibility with Blender 3.6 LTS is implemented by #115015.

Pull Request: #111187
2023-11-18 09:40:44 +01:00
Iliya Katueshenock
8149678d5e Geometry Nodes: use dynamic declaration for some nodes
This changes a bunch of nodes that have a data type drop-down to using a dynamic
node declaration that changes based on the selected data type instead of always having
all sockets. This greatly simplifies the code and is less weird than having suffixes on
socket identifiers.

Backward compatibility and forward compatibility remain due to #113497 and #113984.

One user-visible change is that changing the data type in these nodes does not break
the link anymore.

It may be necessary to bring back some functionality from link-drag-search afterwards.

Pull Request: https://projects.blender.org/blender/blender/pulls/113553
2023-11-17 16:23:34 +01:00
Iliya Katueshenock
6e2fc77e7f Fix #114993: wrong entry in Split to Instances domain dropdown
Pull Request: https://projects.blender.org/blender/blender/pulls/115005
2023-11-16 18:29:34 +01:00
Hans Goudey
3d57bc4397 Cleanup: Move several blenkernel headers to C++
Mostly focus on areas where we're already using C++ features,
where combining C and C++ APIs is getting in the way.

Pull Request: https://projects.blender.org/blender/blender/pulls/114972
2023-11-16 11:41:55 +01:00
Hans Goudey
600a133521 Geometry Nodes: Convert four nodes to use rotation socket
Convert the vector socket from four nodes to a rotation socket, adding
versioning to insert the conversion nodes and change the default values
where necessary.
- Distribute Points on Faces
- Instance on Points
- Rotate Instances
- Transform Geometry

Implicit conversions from vectors and floats, and to vectors have been
added, though using rotation sockets directly can be faster, since converting
to and from Euler rotations is slow. Conversion nodes are not inserted
by versioning if the implicit conversions can be used.

This change is not forward compatible with 3.6, and socket values
are lost when opening 4.1 files in 4.0. The correct socket types are
added back in old versions, though newly added conversion nodes
may have to be removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/111482
2023-11-15 18:56:00 +01:00
Harley Acheson
97d1233bad Cleanup: Make format
Formatting changes resulting from running Make Format
2023-11-15 09:38:01 -08:00
Hans Goudey
3fcd9c9425 Geometry Nodes: Support node tools in object mode
Extend node tools to display tool assets in object mode as well
as edit and sculpt modes. For consistency with existing Blender
design, selection cannot be set and is just "true" in object mode
because it can't be visualized. The visibility of tools can be
customized per object type in object mode as well.

See #101778

Pull Request: https://projects.blender.org/blender/blender/pulls/114819
2023-11-15 17:01:18 +01:00
Hans Goudey
9785f2631e Mesh: Add flag to store presence of overlapping topology
For improving performance in the triangulate node (#112264), it's
helpful to know whether the mesh has edges or faces that overlap
each other. If that is known to be false, the node can skip edge de-
duplication.This might apply to the future "Replace Faces" node too.

This information is stored as a flag on the mesh and set in various
places that create "clean" new meshes. It isn't calculated lazily unlike
other other areas, because the point is to improve performance, and
the calculation probably isn't faster than the duplication check it's
meant to replace.

Pull Request: https://projects.blender.org/blender/blender/pulls/113205
2023-11-15 14:02:48 +01:00
Amine Bensalem
7010a2ee0e Geometry Nodes: Consistent name for points node geometry output
Fixed geometry node socket output name  for issue #113340 to "Points".

Pull Request: https://projects.blender.org/blender/blender/pulls/113353
2023-11-15 11:31:28 +01:00
Douglas Paul
90de0368cd Geometry Nodes: Add a Group ID input to the Fill Curve node
This adds a "Group ID" input to the Fill Curve node, per #102285.

The curve filling operation is performed separately for each group,
so curves associated with different Group IDs do not intersect.

This implementation also supports Grease Pencil 3 curves.

Co-authored-by: Hans Goudey <hans@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/114048
2023-11-14 11:23:19 +01:00
Hans Goudey
0c1bb82fc4 Cleanup: Remove unnecessary struct and typedef keywords from C++ headers 2023-11-14 09:51:41 +01:00
Hans Goudey
7b51d32dd9 Cleanup: Move BKE_modifier.h to C++ 2023-11-14 09:30:40 +01:00