Commit Graph

76 Commits

Author SHA1 Message Date
Campbell Barton
4f8db2ee67 Cleanup: use static sets for contains checks, remove f-string use 2024-02-28 11:02:49 +11:00
Sergey Sharybin
a8a05ebba1 Compositor: Switch CPU compositor to Full-Frame
The tiled compositor code is mainly still around, which is only
expected to be a short-lived period. Eventually it will also be
removed.

The OpenCL, Group Buffers, and Chunk size options are already removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/118010
2024-02-14 14:23:49 +01:00
Sergey Sharybin
467a132166 Compositor: Implement per-node execution time report
Visually it is the same as the execution time implemented for the
geometry nodes, and it is to be enabled in the overlay popover.

The implementation is separate from the geometry nodes, as it is
not easy or practical to re-use the geometry nodes implementation.

The execution time is stored in a run-time hash, indexed by a node
instance key. This is similar to the storage of the mode preview
images, but is stored on the scene runtime data and not on the node
tree. Indexing the storage by key allows to easily copy execution
statistics from localized tree to its original version.

The time is only implemented for full-frame compositor, as for the
tiled compositor it could be tricky to calculate reliable time for
pixel processing nodes which process one pixel at a time.

Pull Request: https://projects.blender.org/blender/blender/pulls/117885
2024-02-09 10:19:24 +01:00
Lukas Tönne
5ad49f4142 Geometry Nodes: Menu Switch Node
This patch adds support for _Menu Switch_ nodes and enum definitions in
node trees more generally. The design is based on the outcome of the
[2022 Nodes Workshop](https://code.blender.org/2022/11/geometry-nodes-workshop-2022/#menu-switch).

The _Menu Switch_ node is an advanced version of the _Switch_ node which
has a customizable **menu input socket** instead of a simple boolean.
The _items_ of this menu are owned by the node itself. Each item has a
name and description and unique identifier that is used internally. A
menu _socket_ represents a concrete value out of the list of items.

To enable selection of an enum value for unconnected sockets the menu is
presented as a dropdown list like built-in enums. When the socket is
connected a shared pointer to the enum definition is propagated along
links and stored in socket default values. This allows node groups to
expose a menu from an internal menu switch as a parameter. The enum
definition is a runtime copy of the enum items in DNA that allows
sharing.

A menu socket can have multiple connections, which can lead to
ambiguity. If two or more different menu source nodes are connected to a
socket it gets marked as _undefined_. Any connection to an undefined
menu socket is invalid as a hint to users that there is a problem. A
warning/error is also shown on nodes with undefined menu sockets.

At runtime the value of a menu socket is the simple integer identifier.
This can also be a field in geometry nodes. The identifier is unique
within each enum definition, and it is persistent even when items are
added, removed, or changed. Changing the name of an item does not affect
the internal identifier, so users can rename enum items without breaking
existing input values. This also persists if, for example, a linked node
group is temporarily unavailable.

Pull Request: https://projects.blender.org/blender/blender/pulls/113445
2024-01-26 12:40:01 +01:00
Campbell Barton
c866c93b06 Cleanup: import UIList, following the convention for other UI classes 2024-01-22 12:44:56 +11:00
Pedro A
6d63da40ee Fix: error when custom socket has no 'draw' function
This `draw` method is optional. The same check is also done elsewhere.

Pull Request: https://projects.blender.org/blender/blender/pulls/117061
2024-01-16 15:41:03 +01:00
Lukas Tönne
53e34dba80 Fix #115727: Draw panel buttons in the node editor side bar
In 13fac109 the node panels got support for individual option button
callbacks, but these were not included in the node editor side bar.
Only the older top-level buttons are drawn there.

The panel structure is currently not accessible in python since it is
part of the `NodeDeclaration` system. To draw node input sockets and
buttons in the correct panel order as they appear on the node, a new
template function `uiTemplateNodeInputs` has been added. This iterates
over declared panels and their contents in the appropriate order and
draws the buttons before sockets in the same panel.

Pull Request: https://projects.blender.org/blender/blender/pulls/116936
2024-01-16 13:37:57 +01:00
Jacques Lucke
00eaddbd51 Geometry Nodes: new Bake node
This adds a new `Bake` node which allows saving and loading intermediate geometries.
Typical use cases we want address with this currently are:
* Bake some data for use with a render engine.
* Bake parts of the node tree explicitly for better performance.

For now, the format that is written to disk is not considered to be an import/export format.
It's not guaranteed that data written with one Blender version can be read by another
Blender version. For that it's better to use proper interchange formats. Better support for
those will be added eventually as well. We also plan an `Import Bake` node that allows
reading the blender-specific baked data independent of the Bake node and at different frames.

The baking works very similar to the baking in the simulation zone (UI and implementation
wise). Major differences are:
* The Bake node has a `Bake Still` and `Bake Animation` mode.
* The Bake node doesn't do automatic caching.

Implementation details:
* Refactored how we create the Python operators for moving socket items so that it also
  makes sense for non-zones.
* The `ModifierCache` stores an independent map of `SimulationNodeCache` and
  `BakeNodeCache`, but both share a common data structure for the actually baked data.
* For baking, the `Bake` node is added as a side-effect-node in the modifier. This will make
  sure that the node is baked even if it's currently not connected to the output.
* Had to add a new `DEG_id_tag_update_for_side_effect_request` function that is used
  during baking. It's necessary because I want to evaluate the object again even though none
  of its inputs changed. The reevaluation is necessary to create the baked data. Using
  `DEG_id_tag_update` technically works as well, but has the problem that it also uses the
  `DEG_UPDATE_SOURCE_USER_EDIT` flag which (rightly) invalidates simulation caches
  which shouldn't happen here.
* Slightly refactored the timeline drawing so that it can also show the baked ranges of
  Bake nodes. It does not show anything for baked nodes with a in Still mode though.
* The bake operator is refactored to bake a list of `NodeBakeRequest` which makes the
  code easier to follow compared to the previous nested
  `ObjectBakeData > ModifierBakeData > NodeBakeData` data structure.
* The bake operators are disabled when the .blend file is not yet saved. This is technically
  only necessary when the bake path depends on the .blend file path but seems ok to force
  the user anyway (otherwise the bake path may be lost as well if it's set explicitly).
* The same operators are used to bake and delete single bakes in `Bake` nodes and
  `Simulation Zones`. On top of that, there are separate operators of baking and deleting all
  simulation bakes (those ignore bake nodes).
* The `Bake` node remembers which inputs have been fields and thus may be baked as attributes.
  For that it uses an `Is Attribute` flag on the socket item. This is needed because the baked data
  may still contain attribute data, even if the inputs to the bake node are disconnected.
* Similar to simulation zones, the behavior of `Bake` nodes is passed into the geometry nodes
  evaluation from the outside (from the modifier only currently). This is done by providing the
  new `GeoNodesBakeParams` in `GeoNodesCallData` when executing geometry nodes.

Next Steps (mostly because they also involve simulations):
* Visualize nodes that have not been evaluated in the last evaluation.
* Fix issue with seemingly loosing baked data after undo.
* Improve error handling when baked data is not found.
* Show bake node in link drag search.
* Higher level tools for managing bakes.

Pull Request: https://projects.blender.org/blender/blender/pulls/115466
2023-12-18 13:01:06 +01:00
Jacques Lucke
ea98c39c50 Cleanup: remove debug print 2023-11-24 09:52:50 +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
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
Omar Emara
474b6fa070 Realtime Compositor: Support full precision compositing
This patch adds support for full precision compositing for the Realtime
Compositor. A new precision option was added to the compositor to change
between half and full precision compositing, where the Auto option uses
half for the viewport compositor and the interactive render compositor,
while full is used for final renders.

The compositor context now need to implement the get_precision() method
to indicate its preferred precision. Intermediate results will be stored
using the context's precision, with a number of exceptions that can use
a different precision regardless of the context's precision. For
instance, summed area tables are always stored in full float results
even if the context specified half float. Conversely, jump flooding
tables are always stored in half integer results even if the context
specified full. The former requires full float while the latter has no
use for it.

Since shaders are created for a specific precision, we need two variants
of each compositor shader to account for the context's possible
precision. However, to avoid doubling the shader info count and reduce
boilerplate code and development time, an automated mechanism was
employed. A single shader info of whatever precision needs to be added,
then, at runtime, the shader info can be adjusted to change the
precision of the outputs. That shader variant is then cached in the
static cache manager for future processing-free shader retrieval.
Therefore, the shader manager was removed in favor of a cached shader
container in the static cache manager.

A number of utilities were added to make the creation of results as well as
the retrieval of shader with the target precision easier. Further, a
number of precision-specific shaders were removed in favor of more
generic ones that utilizes the aforementioned shader retrieval
mechanism.

Pull Request: https://projects.blender.org/blender/blender/pulls/113476
2023-11-08 08:32:00 +01:00
Campbell Barton
fc1c41b121 Merge branch 'blender-v4.0-release' 2023-10-25 15:43:05 +11:00
Dalai Felinto
753e9e0f2b Fix Node Tools popovers dark text
Labels in popover menus are always darker. That made the popovers for
Type and Modes to have a way too dark color. Specially when the values
were off.

This commit mimics what we do in the viewport Selectability &
Visibility menu. Basically we don't gray out the labels even if the
values are off.

Co-authored by: Hans Goudey <hans@blender.org>
2023-10-24 16:32:13 +02:00
Hans Goudey
564c25291f Merge branch 'blender-v4.0-release' 2023-10-19 10:03:59 +02:00
Hans Goudey
eb41a7ec9d Fix: Misleading node tools popover label
Use "Hair Curves" instead of just curves, to clarify that it's just the
new curves system that's supported, not the legacy one. When the
old one is removed, the label will be changed to just say "Curves"
again.
2023-10-19 09:50:17 +02:00
Harley Acheson
2c7d15b19c Merge branch 'blender-v4.0-release' 2023-10-12 10:33:29 -07:00
Harley Acheson
b688414223 UI: Type To Search And Space Bar Search
Continue allowing spacebar search for all dropdown and context menus,
but also add the ability to allow some menus to have type to search,
like Add Modifiers, Objects, Nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/113520
2023-10-12 17:54:59 +02:00
Harley Acheson
311a3d5695 Merge branch 'blender-v4.0-release' 2023-10-09 07:58:47 -07:00
Harley Acheson
35d3d52508 UI: Search All Menus with Space Bar
Allow initiating the search of any named menu by pressing space bar.

Pull Request: https://projects.blender.org/blender/blender/pulls/113299
2023-10-09 16:56:16 +02:00
Brecht Van Lommel
3bbd4294d9 Merge branch 'blender-v4.0-release' into main 2023-10-04 21:32:58 +02:00
Jacques Lucke
5ad9c135e4 Cleanup: deduplicate uilist layout code for zone socket items 2023-10-04 15:40:57 +02:00
Lukas Tönne
164fbc2863 Fix #113013: Make in_out socket property read-only and remove the button
Pull Request: https://projects.blender.org/blender/blender/pulls/113048
2023-09-29 10:29:57 +02:00
Campbell Barton
790fea431f Cleanup: use since quotes for enum values, wrap multi-line brackets 2023-09-29 14:41:48 +10:00
Hans Goudey
1a7527b1df Geometry Nodes: Move node tools out of experimental
See #101778

Pull Request: https://projects.blender.org/blender/blender/pulls/112927
2023-09-27 16:04:36 +02:00
Hans Goudey
9e495c5b06 Geometry Nodes: Store tool group in a separate editor property
This enables switching back and forth between the modifier and tool
contexts of the geometry node editor without losing the assigned tool
node group.

See #101778

Pull Request: https://projects.blender.org/blender/blender/pulls/112926
2023-09-27 15:47:22 +02:00
Jacques Lucke
c8cc169d6f Geometry Nodes: add Inspection Index to Repeat Zone
Previously, it was only possible to inspect the data from the first iteration. That
applied to both, the viewer node as well as socket inspection. Now, there is a
new `Inspection Index` setting in the zone properties. It specifies which iteration
should be used by the inspection features.

In theory we could support features like counting the index from the end, but
that can be done separately as well, as it likely requires more UI.

Pull Request: https://projects.blender.org/blender/blender/pulls/112818
2023-09-27 11:09:39 +02:00
Hans Goudey
93b285be4b Fix: Use disabled status for non-selected node tool modes and types 2023-09-26 17:38:13 -04:00
Pablo Vazquez
b41fc86003 UI: Match Node Editor Node menu with Context menu
Leftover work from when the Context Menu was refactored.

Mainly matching icons, separators, order, and show/hide submenu.

Pull Request: https://projects.blender.org/blender/blender/pulls/112924
2023-09-26 23:34:59 +02:00
Hans Goudey
355ed0838c Geometry Nodes: Expose non-asset tools
Node tools are no longer required to be assets, and they aren't assets
by default anymore. Non-assets don't have catalogs for header menu
organization, so they are only exposed in the "Unassigned" menu, which
is now just an icon so it takes less spac, makes the connection to the
asset browser, and signals more that it's not the "final" place for a
tool. Tool node groups have fake user set by default, since they don't
have users. The "Is Tool" status of a node group is configurable in the
editor N-panel, just like the modifier status.

This is similar to af3461c387, and has the same check for
whether a node group is "local."
2023-09-26 17:01:50 -04:00
Hans Goudey
af3461c387 Geometry Nodes: Require modifier tag for add menu, show non-assets
Any geometry node group with the "Is Modifier" tag is exposed in the add
modifier menu. Local node groups that aren't assets are displayed in a
subsection of the "Unassigned" menu, as they are "asset wannabees"
that function similarly but aren't shared to other files.

Only modifier node groups can be assigned to the geometry nodes
modifier. Because of this, existing node groups are versioned to have
the tag if they have a geometry output.

Internally, this means the operator that used to only handle node group
assets has to also add local geometry node groups. That change isn't
so large though. The other changes are just UI, or changes to the
node group property poll functions.

Note: For assets, saving the file to generate asset meta-data may be
necessary for the versioning to affect the add modifier menu.

Pull Request: https://projects.blender.org/blender/blender/pulls/112918
2023-09-26 21:53:20 +02:00
Pablo Vazquez
05fc31f27f UI: Remove redundant "Context Menu" in menu titles
Context menus are a type of menu, like header menus, there is no need to mention
the type as part of the name since it is implied by context.

Pull Request: https://projects.blender.org/blender/blender/pulls/112662
2023-09-25 16:25:55 +02:00
Hans Goudey
652aab0b31 Fix: Swapped icons in node tool header popover 2023-09-22 20:51:34 -04:00
Hans Goudey
2cb34f7c0d UI: Improve geometry nodes tool popover layout
See #101778, #111524

Separate the layout into one popover for object types and another for
object modes. Use checkboxes with icons and full phrases like "Object
Mode". Also rename the modifier popover to "Modifier". Thought
it just has one option right now, so it looks quite weird.

---

![image](https://projects.blender.org/attachments/17e86c35-3c13-48e4-8113-817c5a80fdd3)
![image](https://projects.blender.org/attachments/f92a55a9-e4f0-4c29-8d15-a47a3154ed70)
![image](https://projects.blender.org/attachments/50cd0a93-0abb-4766-819b-62d265251822)

Pull Request: https://projects.blender.org/blender/blender/pulls/112749
2023-09-23 02:33:51 +02:00
Hans Goudey
1c51f74cb4 Geometry Nodes: Filter data-block buttons for tools and modifiers
In the data-block selectors in the node editor and the header,
apply a few rules to increase the separation between tool and
modifier node groups.
1. The modifier accepts non-asset groups or assets marked
   as modifiers (created in the modifier context). Tool node groups
   cannot be used by modifiers.
2. The tool context can only edit node group assets marked as tools
   (created in the tool context).

When switching contexts, the node group is cleared if the state would
be invalid. The tool node group is still stored in the editor's "root node
tree" property. Since it isn't retrieved from the context, the pin button
is useless, so it isn't displayed in the tool mode.

See #101778, #111526.

Pull Request: https://projects.blender.org/blender/blender/pulls/112389
2023-09-22 17:45:00 +02:00
Hans Goudey
6642bd6220 UI: Remove name property from node interface active panel UI
While it isn't "wrong" to have the name listed below too, In Blender
the name of an item is usually edited by double clicking inside
of list/tree views, and it's better to be consistent.
2023-09-08 10:03:16 -04:00
Hans Goudey
e86211cded Cleanup: Remove unnecessary search item in texture node add menu
Unnecessary since 7f9d51853c
2023-09-06 16:01:39 -04:00
Jacques Lucke
7f9d51853c UI: support searching in menus
The basic idea is very simple. Whenever a supported menu is open, one can just
start typing and this opens a search that contains all the (nested) menu entries.

The main downside is that this collides with accelerator keys. Those are the
underlined characters in each menu. For now, we just enable this new searching
behavior in a few selected menus: Node Add Menu, View3D Add Menu and
Modifier Add Menu.

This new functionality can be enabled for a menu by setting
`bl_options = {'SEARCH_ON_KEY_PRESS'}` to true in the menu type.

The status bar shows `Type to search...` when a menu is opened that supports search.

Pull Request: https://projects.blender.org/blender/blender/pulls/110855
2023-09-06 18:16:45 +02:00
Miguel Pozo
2aa7961e6f Workbench: Remove old implementation 2023-09-06 15:54:48 +02:00
Pablo Vazquez
5fac8f822b Texture Nodes: Refactor Add menu
Refactor the Add menu in Texture Nodes, with manually created menus,
inspired by Geometry Nodes and more recently Shader and Compositor.

Minor sorting adjustments by splitting categories in groups, with
separators in between groups, and sorted alphabetically.

Unlike other node editors, this menu will not feature assets for the time
being. Doing so would add (more) burden of maintenance to a system
that is deemed end-of-life, and likely to be rewritten before long.

Part of #111746

Pull Request: https://projects.blender.org/blender/blender/pulls/111838
2023-09-05 21:52:31 +02:00
Hans Goudey
6da4b87661 Geometry Nodes: Extend add modifier menu with node group assets
Implements part of #111538.

Change the modifier add button to create a menu with submenus.
Extend the submenus dynamically with geometry node group assets.
This makes it much simpler to share and use custom modifiers.

Node groups get a new "Is Modifier" property, which is controllable
in a popover in the node editor header when the group is an asset.

The built in modifier can be rearranged in different categories in
a next step. For now the existing organization is used, except for
the geometry nodes modifier, which is called "Empty Modifier" and
put in the root menu.

The changes in !110855 and !110828 will be important to improve
interaction speed with the new UI. Those are planned for 4.0 as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/111717
2023-09-05 14:47:18 +02:00
Campbell Barton
0c26c84704 Cleanup: spelling in comments 2023-09-05 11:04:27 +10:00
Campbell Barton
e8c812a307 Cleanup: spelling in comments, update dictionary 2023-09-03 21:35:07 +10:00
Pablo Vazquez
de09bdb510 Cleanup: rename compositing to compositor in menu file
Also use lowercase for menu bl_idname, since there won't be any
conflict it's not needed.
2023-09-01 23:43:13 +02:00
Pablo Vazquez
f8dd297531 Cleanup: rename shading to shader in add menu file
Also use lowercase for menu bl_idname, since there won't be any
conflict it's not needed.
2023-09-01 23:36:34 +02:00
Pablo Vazquez
9db4c0ca4b Shading Nodes: Refactor Add menu
Refactor the Add menu in Shading nodes, with manually created menus,
inspired by Geometry Nodes and more recently the Compositor.

Minor sorting adjustments by splitting categories in groups, with
separators in between groups, and sorted alphabetically. Shading
node group assets are also populated in the menus.

This is the first part of the re-organization of the Add menu,
part of #111746

Pull Request: https://projects.blender.org/blender/blender/pulls/111798
2023-09-01 20:46:12 +02:00
Hans Goudey
af56a4f0d3 UI: Remove gap for decorators in node group interface panel
Usually use_property_split is matched with false use_property_decorate
when the settings in the panel aren't animateable, which is the case
here. This matches the panel from before the node panels commit.
2023-08-30 10:34:55 -04:00
Lukas Tönne
e071288ab2 Nodes: Panels integration with blend files and UI
Part 3/3 of #109135, #110272

Switch to new node group interfaces and deprecate old DNA and API.
This completes support for panels in node drawing and in node group
interface declarations in particular.

The new node group interface DNA and RNA code has been added in parts
1 and 2 (#110885, #110952) but has not be enabled yet. This commit
completes the integration by
* enabling the new RNA API
* using the new API in UI
* read/write new interfaces from blend files
* add versioning for backward compatibility
* add forward-compatible writing code to reconstruct old interfaces

All places accessing node group interface declarations should now be
using the new API. A runtime cache has been added that allows simple
linear access to socket inputs and outputs even when a panel hierarchy
is used.

Old DNA has been deprecated and should only be accessed for versioning
(inputs/outputs renamed to inputs_legacy/outputs_legacy to catch
errors). Versioning code ensures both backward and forward
compatibility of existing files.

The API for old interfaces is removed. The new API is very similar but
is defined on the `ntree.interface` instead of the `ntree` directly.
Breaking change notifications and detailed instructions for migrating
will be added.

A python test has been added for the node group API functions. This
includes new functionality such as creating panels and moving items
between different levels.

This patch does not yet contain panel representations in the modifier
UI. This has been tested in a separate branch and will be added with a
later PR (#108565).

Pull Request: https://projects.blender.org/blender/blender/pulls/111348
2023-08-30 12:37:21 +02:00
persun
50afd1f05d UI: Rename and reorder group operators in Node Editor menus
Rename and reorder group operators in Node Editors header "Node" and
context menu for consistency and clarity.

Pull Request: https://projects.blender.org/blender/blender/pulls/111505
2023-08-29 15:05:42 +02:00
Rawalanche
411cd827b7 Nodes: Move Auto-Offset toggle to User Preferences
Move Auto-Offset toggle from Node Editor View menu
into the Editing > Node Editor section of User Preferences,
to reflect its use as a workflow option not configured
per editor or per file.

Pull Request: https://projects.blender.org/blender/blender/pulls/111589
2023-08-29 01:18:33 +02:00