diff options
author | Jacques Lucke <jacques@blender.org> | 2022-09-28 18:54:59 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-09-28 18:54:59 +0300 |
commit | c55d38f00b8c0e6ae8bda9cc66614afe28fb3fc9 (patch) | |
tree | 0fc280eec3e2d0655197afda823de1062f51ea05 /source/blender/blenkernel/BKE_viewer_path.h | |
parent | 2312915b9620808d29e9b20529684800638d5a2a (diff) |
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
Diffstat (limited to 'source/blender/blenkernel/BKE_viewer_path.h')
-rw-r--r-- | source/blender/blenkernel/BKE_viewer_path.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_viewer_path.h b/source/blender/blenkernel/BKE_viewer_path.h new file mode 100644 index 00000000000..dfba289531f --- /dev/null +++ b/source/blender/blenkernel/BKE_viewer_path.h @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#pragma once + +/** + * A #ViewerPath is a path to data that is viewed/debugged by the user. It is a list of + * #ViewerPathElem. + * + * This is only used for geometry nodes currently. When the user activates a viewer node the + * corresponding path contains the following elements: + * - Object the viewer is activated on. + * - Modifier that contains the corresponding geometry node group. + * - Node tree path in case the viewer node is in a nested node group. + * - Viewer node name. + * + * The entire path is necessary (instead of just the combination of node group and viewer name), + * because the same node group may be used in many different places. + * + * This file contains basic functions for creating/deleting a #ViewerPath. For more use-case + * specific functions look in `ED_viewer_path.hh`. + */ + +#include "DNA_viewer_path_types.h" + +struct BlendWriter; +struct BlendDataReader; +struct BlendLibReader; +struct LibraryForeachIDData; +struct Library; +struct IDRemapper; + +#ifdef __cplusplus +extern "C" { +#endif + +void BKE_viewer_path_init(ViewerPath *viewer_path); +void BKE_viewer_path_clear(ViewerPath *viewer_path); +void BKE_viewer_path_copy(ViewerPath *dst, const ViewerPath *src); +bool BKE_viewer_path_equal(const ViewerPath *a, const ViewerPath *b); +void BKE_viewer_path_blend_write(struct BlendWriter *writer, const ViewerPath *viewer_path); +void BKE_viewer_path_blend_read_data(struct BlendDataReader *reader, ViewerPath *viewer_path); +void BKE_viewer_path_blend_read_lib(struct BlendLibReader *reader, + struct Library *lib, + ViewerPath *viewer_path); +void BKE_viewer_path_foreach_id(struct LibraryForeachIDData *data, ViewerPath *viewer_path); +void BKE_viewer_path_id_remap(ViewerPath *viewer_path, const struct IDRemapper *mappings); + +ViewerPathElem *BKE_viewer_path_elem_new(ViewerPathElemType type); +IDViewerPathElem *BKE_viewer_path_elem_new_id(void); +ModifierViewerPathElem *BKE_viewer_path_elem_new_modifier(void); +NodeViewerPathElem *BKE_viewer_path_elem_new_node(void); +ViewerPathElem *BKE_viewer_path_elem_copy(const ViewerPathElem *src); +bool BKE_viewer_path_elem_equal(const ViewerPathElem *a, const ViewerPathElem *b); +void BKE_viewer_path_elem_free(ViewerPathElem *elem); + +#ifdef __cplusplus +} +#endif |