Commit Graph

4665 Commits

Author SHA1 Message Date
Jacques Lucke
96db947f16 Geometry Nodes: show info in simulation node when it is baked
This adds the same overlay that already exists for the bake node to the simulation output node.
Without this, it's quite hard to see if the simulation zone is baked or not currently.

Pull Request: https://projects.blender.org/blender/blender/pulls/121497
2024-05-07 11:35:03 +02:00
Jacques Lucke
5f02eaae9f Geometry Nodes: use aligned sockets in bake node
This aligns the corresponding input and output sockets in the Bake node.
A similar change has been done for simulation and repeat zones before in #118335.

Pull Request: https://projects.blender.org/blender/blender/pulls/121496
2024-05-07 11:23:23 +02:00
Iliya Katueshenock
620c9a03c0 Fix: Geometry Nodes: Matrix type in Switch node
Missed static type in Switch node for fields.

Pull Request: https://projects.blender.org/blender/blender/pulls/121450
2024-05-07 00:30:21 +02:00
Jacques Lucke
69625494ad Cleanup: add missing includes 2024-05-06 19:52:45 +02:00
Iliya Katueshenock
968b98be56 Geometry Nodes: new Input Rotation node
This adds a new node input node for a constant rotation.
Similar nodes exist for vector, integer, boolean, etc. already.

Pull Request: https://projects.blender.org/blender/blender/pulls/120345
2024-05-06 19:04:30 +02:00
Iliya Katueshenock
8249c09f3a Geometry Nodes: add implicit input for Instance Transform
`instance_transform` is the basic transformation attribute of instances.
This will be used in separate patches.

Pull Request: https://projects.blender.org/blender/blender/pulls/120340
2024-05-06 17:22:24 +02:00
Jacques Lucke
dca2faec33 Geometry Nodes: fix typo in Invert Matrix node
Also changing the identifier because this node is only just out of
experimental and has not been released yet.
2024-05-06 16:19:15 +02:00
Campbell Barton
ab6e00bd7d Cleanup: sort cmake file lists 2024-05-06 09:20:57 +10:00
Jacques Lucke
18600e430c Geometry Nodes: show correct type in menu socket tooltips
Previously, menu sockets were sometimes shown as integers or strings
in socket tooltips. Now, they are always shown as "Menu" type. This also
changes how these values are logged. Previously, they were logged as
strings. Now, only the integer identifier is logged and the name is looked
up when drawing the tooltip.

Pull Request: https://projects.blender.org/blender/blender/pulls/121236
2024-05-05 09:30:02 +02:00
Iliya Katueshenock
4732e7cda5 Cleanup: incorrect assertion
This assertion was added in assumption that sizes of input argument are always correct.
But this is not such. More correct is to depend on assertions of span access methods.

The size of the multi-function parameters is only guaranteed to be large enough so that
every index in the mask can be accessed. It may be larger.

Pull Request: https://projects.blender.org/blender/blender/pulls/121393
2024-05-03 15:05:48 +02:00
Arye Ramaty
1db538683d Geometry Nodes: add selection and depth options to Realize Instances node
Previously, the Realize Instances node would always realize everything in the geometry.
Now it's possible to more selectively realize parts of the geometry:
* One can choose which top level instances should be realized.
* The realization depth can be controlled per top-level instance. For example, if there are
  5 top level instances, each of which contains 10 other instances, it's now possible to
  realize only one level so that one ends up with 50 instances.

Pull Request: https://projects.blender.org/blender/blender/pulls/116582
2024-05-03 12:47:59 +02:00
Iliya Katueshenock
29aecbf74c Fix #120841: parent nodes don't get logs from zones
Issue was in the fact that log should be propagated on source node and on parent node.
Instead of `group_node_id`, loggers need to have id of actual parent (zone node or node group) node.
This also fix issue with timings propagation on frame nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/120842
2024-05-03 11:59:35 +02:00
Campbell Barton
9918488bb1 Cleanup: use uppercase tags, following own style guide 2024-05-03 11:33:21 +10:00
Lukas Stockner
17f2cdd104 Cycles: Add thin film iridescence to Principled BSDF
This is an implementation of thin film iridescence in the Principled BSDF based on "A Practical Extension to Microfacet Theory for the Modeling of Varying Iridescence".

There are still several open topics that are left for future work:
- Currently, the thin film only affects dielectric Fresnel, not metallic. Properly specifying thin films on metals requires a proper conductive Fresnel term with complex IOR inputs, any attempt of trying to hack it into the F82 model we currently use for the Principled BSDF is fundamentally flawed. In the future, we'll add a node for proper conductive Fresnel, including thin films.
- The F0/F90 control is not very elegantly implemented right now. It fundamentally works, but enabling thin film while using a Specular Tint causes a jump in appearance since the models integrate it differently. Then again, thin film interference is a physical effect, so of course a non-physical tweak doesn't play nicely with it.
- The white point handling is currently quite crude. In short: The code computes XYZ values of the reflectance spectrum, but we'd need the XYZ values of the product of the reflectance spectrum and the neutral illuminant of the working color space. Currently, this is addressed by just dividing by the XYZ values of the illuminant, but it would be better to do a proper chromatic adaptation transform or to use the proper reference curves for the working space instead of the XYZ curves from the paper.

Pull Request: https://projects.blender.org/blender/blender/pulls/118477
2024-05-02 14:28:44 +02:00
Jacques Lucke
6cb9b7299d Fix: sample grid node uses wrong enum for data type
The used enum used the term "Value" instead of "Float".
Also the default value was wrong.
2024-05-01 23:29:56 +02:00
Iliya Katueshenock
831e91c357 Geometry Nodes: support working with raw matrix values
These nodes allow working with the raw values that make up a matrix.
This can be used to construct a 4x4 matrix directly, without using the
`Combine Transform` node. This allows building transforms with arbitrary
skew, or projection matrices.

Pull Request: https://projects.blender.org/blender/blender/pulls/121283
2024-05-01 21:31:08 +02:00
Iliya Katueshenock
5fa98aa0fd Cleanup: Camel case for node size enum items
Pull Request: https://projects.blender.org/blender/blender/pulls/121297
2024-05-01 15:27:34 +02:00
Habib Gahbiche
483c854612 Compositor: implement interpolation methods for Translate node
Compositor: Expose interpolation methods Nearest, Bilinear and Bicubic to the user for translate node

This is part of #119592.

Pull Request: https://projects.blender.org/blender/blender/pulls/119603
2024-05-01 14:44:01 +02:00
Omar Emara
382131fef2 Realtime Compositor: Implement Fast Gaussian blur
This patch implements the Fast Gaussian blur mode for the Realtime
Compositor. This is a faster but less accurate implementation of
Gaussian blur.

This is implemented as a recursive Gaussian blur algorithm based on the
general method outlined in the following paper:

 Hale, Dave. "Recursive gaussian filters." CWP-546 (2006).

In particular, based on the table in Section 5 Conclusion, for very low
radius blur, we use a direct separable Gaussian convolution. For medium
blur radius, we use the fourth order IIR Deriche filter based on the
following paper:

  Deriche, Rachid. Recursively implementating the Gaussian and its
  derivatives. Diss. INRIA, 1993.

For high radius blur, we use the fourth order IIR Van Vliet filter based
on the following paper:

  Van Vliet, Lucas J., Ian T. Young, and Piet W. Verbeek. "Recursive
  Gaussian derivative filters." Proceedings. Fourteenth International
  Conference on Pattern Recognition (Cat. No. 98EX170). Vol. 1. IEEE,
  1998.

That's because direct convolution is faster and more accurate for very
low radius, while the Deriche filter is more accurate for medium blur
radius, while Van Vliet is more accurate for high blur radius. The
criteria suggested by the paper is a sigma value threshold of 3 and 32
for the Deriche and Van Vliet filters respectively, which we apply on
the larger of the two dimensions.

Both the Deriche and Van Vliet filters are numerically unstable for high
blur radius. So we decompose the Van Vliet filter into a parallel bank
of smaller second order filters based on the method of partial fractions
discussed in the book:

  Oppenheim, Alan V. Discrete-time signal processing. Pearson Education
  India, 1999.

We leave the Deriche filter as is since it is only used for low radii
anyways.

Compared to the CPU implementation, this implementation is more
accurate, but less numerically stable, since CPU uses doubles, which is
not feasible for the GPU.

The only change of behavior between CPU and this implementation is that
this implementation uses the same radius, so Fast Gaussian will match
normal Gaussian, while the CPU implementation has a radius that is 1.5x
the size of normal Gaussian. A patch to change the CPU behavior #121211.

Pull Request: https://projects.blender.org/blender/blender/pulls/120431
2024-05-01 09:57:30 +02:00
Hans Goudey
462e7aeedd Geometry Nodes: Add Align Rotation to Vector node
A version of "Align Euler to Vector" with the rotation socket
instead of the vector Euler socket. Other than that, and a few
cleanups to use newer math functions, the node is the same.

The old node is just "Deprecated" for now. We could remove
it with versioning, but we can also wait to do that.

In a simple test this node is about 1.7 times faster than the old one.

Pull Request: https://projects.blender.org/blender/blender/pulls/118565
2024-04-30 15:52:11 +02:00
Aaron Carlisle
f5157b00a9 Compositor: Remove left over code from tile based compositor
The compositor used to have a feature that would calculate tiles for the viewer based on a custom order. Since the removal of the tile based compositor, this code is unused.

Pull Request: https://projects.blender.org/blender/blender/pulls/121176
2024-04-30 13:47:45 +02:00
Jacques Lucke
d550db1288 Cleanup: correct function name 2024-04-30 11:14:40 +02:00
Jacques Lucke
176c6ef329 Geometry Nodes: unify menu switch with other nodes with dynamic sockets
This changes the menu switch socket to use the socket-items system
(`NOD_socket_items.hh`) that is already used by the simulation zone, repeat
zone, bake node and index switch node. By using this system, the per-node
boilerplate can be removed significantly. This is especially important as we
plan to have dynamic socket amounts in more nodes in the future.

There are some user visible changes which make the node more consistent with
others:
* Move the menu items list into the properties panel as in 0c585a1b8a.
* Add an extend socket.
* Duplicating a menu item keeps the name of the old one.

There is also a (backward compatible) change in the Python API: It's now
possible to directly access `node.enum_items` and `node.active_index` instead of
having to use `node.enum_definition.enum_items`. This is consistent with the
other nodes. For backward compatibility, `node.enum_definition` still exists,
but simply returns the node itself.

Many API functions from `NodeEnumDefinition` like
`NodeEnumDefinition::remove_item` have been removed. Those are not used anymore
and are unnecessary boilerplate. If ever necessary, they can be implemented back
in terms of the socket-items system.

The socket-items system had to be extended a little bit to support the case for
the menu switch node where each socket item has a name but no type. Previously,
there was the case without name and type in the index switch node, and the case
with both in the bake node and zones. The system was trivial to extend to this
case.

Pull Request: https://projects.blender.org/blender/blender/pulls/121234
2024-04-30 10:19:32 +02:00
Jacques Lucke
8d13a9608b BLI: generalize task size hints for parallel_for
This integrates the functionality for `parallel_for_weighted` from 9a3ceb79de
into `parallel_for`. This reduces the number of entry points to the threading
API and also makes it easier to build higher level threading primitives. For
example, `IndexMask.foreach_*` may use `parallel_for` if a `GrainSize` is
provided, but can't use `parallel_for_weighted` easily without duplicating a
fair amount of code.

The default behavior of `parallel_for` does not change. However, now one can
optionally pass in `TaskSizeHints` as the last parameter. This can be used to
specify the size of individual tasks relative to each other and relative to the
grain size. This helps scheduling more equally sized tasks which generally
improves performance because threads are used more effectively.

One generally does not construct `TaskSizeHints` manually, but calls either
`threading::individual_task_sizes` or `threading::accumulated_task_sizes`. Both
allow specifying individual task sizes, but the latter should be used when the
combined size of consecutive tasks can be computed in O(1) time. This allows
splitting up the work more efficiently. It can often be used in conjunction with
`OffsetIndices`.

Pull Request: https://projects.blender.org/blender/blender/pulls/121127
2024-04-29 23:55:22 +02:00
Jacques Lucke
d588bfdb5e Geometry Nodes: improve naming and code deduplication
On this level it makes sense to have a single `add_item` function
because the operator does not take any parameters. It's also
mostly the same for different kinds of socket items except
for one line.
2024-04-29 22:45:16 +02:00
Jacques Lucke
6bd1d5de54 Fix: assert when removing element from empty array 2024-04-29 22:45:15 +02:00
Jacques Lucke
9c153a58c0 Fix: missing null check 2024-04-29 22:15:31 +02:00
Jacques Lucke
0c585a1b8a Geometry Nodes: move socket items ui and operators from Python to C++
This has some benefits:
* Nodes with dynamic socket amounts can remain more self-contained
  (2 fewer files to edit with this patch).
* It's easier to reuse existing C++ code, reducing redundancy.

One new thing I'm doing here is to define operators in node files. It seems
reasonable to register operators that belong to a node together with that
node. Without this, code spreads out further than necessary without any real benefit.

This patch affects the simulation zone, repeat zone, bake node and index switch node.

The UI is slightly affected too. Since we had the UI defined in Python before,
it wasn't possible to integrate it into the node properties panel. That is possible
now and looks better anyway. The previous UI was an artifact of technical limitations.

Pull Request: https://projects.blender.org/blender/blender/pulls/121178
2024-04-29 19:50:11 +02:00
Bartosz Kosiorek
d655e63044 UI: Add tooltips with description of compositing nodes
As already existed for shader and geometry nodes.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/121038
2024-04-29 14:48:43 +02:00
Hans Goudey
205683477f Fix #121209: Menu switch missing matrix socket 2024-04-29 08:36:25 -04:00
David Murmann
ee51f643b0 Cycles: Ray Portal BSDF
Transport rays that enter to another location in the scene, with
specified ray position and normal. This may be used to render portals
for visual effects, and other production rendering tricks.

This acts much like a Transparent BSDF. Render passes are passed
through, and this is affected by light path max transparent bounces.

Pull Request: https://projects.blender.org/blender/blender/pulls/114386
2024-04-29 12:37:51 +02:00
Alaska
f8c0050a25 Shaders: Add Roughness to Subsurface Scattering Node
Matching the Principled BSDF.

Pull Request: https://projects.blender.org/blender/blender/pulls/114499
2024-04-29 10:54:29 +02:00
Hans Goudey
65803f262f Node Tools: Basic support for data-block inputs
Currently support for data-block inputs is disabled because pointer
properties in operator properties aren't properly handled in Blender
(for more info, see 871c717c6e). This commit brings basic
support for them by storing strings (data-block names) in the operator
properties instead. The main downside of using strings compared other
theoretical solutions is that data-blocks from different library files
can have the same name. This solution won't work well for those cases.
However, it still brings a lot of utility to node tools for a relatively
simple code change.

I investigated two other solutions for this that didn't work out. Using
the recently added enum custom property support didn't work because
the data-block names would still have to be unique. Plus generating an
enum would require a bunch of boilerplate code. Extending the existing
button search code to handle integer session UID backed data-blocks was
much trickier than I expected. The code there is already quite spagetti-
like, and things got out of hand quickly. That's still valid future work
though. The implementation can be changed without breaking
compatibility of files.

Pull Request: https://projects.blender.org/blender/blender/pulls/121148
2024-04-29 03:47:33 +02:00
Jacques Lucke
ab1da26e75 Fix: incorrect error message in Object Info node in tool context 2024-04-28 00:38:01 +02:00
Campbell Barton
c0def6c93d Cleanup: spelling in comments 2024-04-27 11:58:02 +10:00
Hans Goudey
ce224fe401 Node Tools: Add mouse position node, wait for cursor option
Add a "Mouse Position" node that outputs the location of the mouse
cursor in region space and the overall size of the region, both in pixel
units. Both outputs are integers to help reflect their pixel units.
If there the mouse position is ever accessible in sub-pixels, they can
easily be changed to floats.

Also add a "Wait for Cursor" option similar to the one for some built-in
operators that delay's the operator's execution until there is a mouse
click in the viewport. That way the operator can be called from menus
even though it is interactive. This option is placed in the node editor
header. When there are more options, it will be part of an "Options"
popover panel similar to the existing "Modes" and "types" popovers.

Combined with the viewport transform node, and other nodes like Raycast,
these features can allow making tools that create geometry where you
click in the scene.

Pull Request: https://projects.blender.org/blender/blender/pulls/121043
2024-04-26 20:14:25 +02:00
Hans Goudey
83ed92d533 Geometry Nodes: Add Viewport Transform node
Add a node that outputs the transform of the viewport relative to the
self object's transform. This node can be used to build effects like
billboarding or aligning geometry to the current view. In combination
with the mouse position node in the future it will allow tools like
generating geometry at the mouse click position.

There are two output matrices. The first is the projection matrix
that takes positions in camera space and applies the final perspective
projection. The other is the "view" matrix which contains the location
and rotation of the camera. These are separate because though their
combination is useful, it isn't used like a typical rotation/transform matrix.

Pull Request: https://projects.blender.org/blender/blender/pulls/118680
2024-04-26 19:47:19 +02:00
Iliya Katueshenock
095d37c186 Fix #120592: File output node not showing up in search
Pull Request: https://projects.blender.org/blender/blender/pulls/121096
2024-04-25 21:53:16 +02:00
Jacques Lucke
de7ea7e60d Fix: don't allow zero bandwidth in sdf grid
Setting the bandwidth to zero caused a crash.
2024-04-25 12:13:11 +02:00
Hans Goudey
777473313e Fix: Correct perferred domain function for point index in curve node 2024-04-24 14:32:10 -04:00
Hans Goudey
b3ecfcd77d Node Tools: Avoid depsgraph evaluation when possible
Currently for node tools we create and evaluate a temporary depsgraph
with all the selected object data-blocks and all data-blocks referenced
by the node tree.

Needless to say, this can be very slow when those data-blocks contain
arbitrary procedural operations. Re-evaluating all the selected objects
is particularly because it will give a slowdown even in very basic uses
of node tools.

Originally I hoped that geometry nodes could be made to work with
original as well as evaluated data-blocks. But that would require far
too many tricky changes and arguably isn't right design-wise anyway.
Instead of that, this commit makes node tools dependency graph
evaluation more fine-grained in a few ways.

1. Remove the evaluation of selected objects. These are always visible
   in the viewport and part of the active depsgraph anyway. To protect
   against cyclic dependencies, we now compare `orig_id` instead of the
   object pointer itself.
2. Evaluate the node group and its dependencies in a separate depsgraph
   used only when necessary. This allows using the original node tree
   without any copies when it doesn't reference any data-blocks.
3. Evaluate IDs from node group inputs (from the redo panel) in the extra
   depsgraph as well, only when necessary.

Pull Request: https://projects.blender.org/blender/blender/pulls/120723
2024-04-24 17:08:25 +02:00
Brecht Van Lommel
15b9ae5436 Refactor: Use typed functions for blend file data reading
This makes the read and write API functions match more closely, and adds
asserts to check that the data size is as expected.

There are still a few places remaining that use BLO_read_data_address
and similar generic functions, these should eventually be replaced as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/120994
2024-04-24 17:01:22 +02:00
Ben-7
0136289cb6 CMake: Windows: clang-cl fixes
Support for building blender with clang on windows on x64 was added
years ago but given there are no active users support has crumbled a
bit.

This PR brings the build system back into working order but upstream
patches in openVDB are still required for a successful build see PR
#120317 for details.

Blender when build with clang the classroom scenes rendered on the cpu
with cycles is seeing a 5% reduction in render time on both an
AMD 7700x and an Intel 14900k.
2024-04-24 15:59:47 +02:00
Hans Goudey
3cd1c365c3 Geometry Nodes: Add Project point matrix node
With the matrix socket being introduced into geometry nodes, we
are starting to deal with more complex transforms like perspective
projection. For those matrices projecting a point is not as simple
as just matrix multiplication, there has to be an additional normalization
step after. To solve that in an intuitive way consistent with how it's
typically solved in code, add a new "Project Point" node.

The canonical use case for now is in combination with the mouse
position, viewport transform, and raycast nodes, to find where the
mouse clicked on the edited geometry.

Pull Request: https://projects.blender.org/blender/blender/pulls/120597
2024-04-24 15:56:33 +02:00
Hans Goudey
0c3763ddda Geometry Nodes: Add SDF grid boolean nodes
Add a simple node to compute the intersection, difference, or union
between SDF grids. This should be the first new use case for the
new volume grid nodes that wasn't possible before.

For naming and multi-inputs, the node uses the same design as the
mesh boolean node. We considered splitting each operation into a
separate node, but though most users considered these different
"modes" of the same operation.

One thing to keep in mind is that it's important for the grids to
have exactly the same transform. If they have different transforms,
the second grid must be resampled to match the first, because the
OpenVDB CSG tools have that requirement. Resampling is expensive
(for SDF grids it means a grid -> mesh -> grid round trip) and should
be avoided.

Pull Request: https://projects.blender.org/blender/blender/pulls/118879
2024-04-23 14:48:59 +02:00
Jacques Lucke
5f3ad33f38 Geometry Nodes: decentralize headers for some nodes
`NOD_zone_socket_items.hh` contained code for different nodes. It's better to
split this into headers per node, because that scales better. Also it helps to
keep the code for each individual node more closely together.

Pull Request: https://projects.blender.org/blender/blender/pulls/120945
2024-04-23 11:13:27 +02:00
Jacques Lucke
d7d8cefd72 Fix: incorrect safe float4x4 to quaternion conversion
The issue was that when a 4x4 matrix is normalized, it does not
always mean that any inner 3x3 matrix is normalized too.
2024-04-22 19:52:47 +02:00
Jacques Lucke
1609541bbf Fix #120875: crash when deleting all group output nodes
This didn't take `geometry_nodes_default_cpp_value` into account properly.
2024-04-22 13:29:51 +02:00
Lukas Stockner
cc541f2c07 UI: Add Wavelength unit for scene-independent nanometer-scale inputs
Currently this is only used for the Wavelength node, but it will also be relevant for the Thin Film Interference support in the Principled BSDF.

Pull Request: https://projects.blender.org/blender/blender/pulls/120900
2024-04-22 13:10:16 +02:00
Hans Goudey
11f0d88d13 Subdiv: Move most blenkernel subdiv code to C++ namespace
Move most code to `blender::bke::subdiv`. That helps organization
and makes using C++ in subdiv code easier, which will be useful for
removing the unnecessary opensubdiv C-API wrapper.
2024-04-19 09:03:31 -04:00