Page MenuHome

Geometry Nodes: Viewport preview.
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on Sep 13 2022, 10:34 AM.
Tags
None
Tokens
"Like" token, awarded by Endertainer007."Love" token, awarded by duarteframos."Love" token, awarded by HooglyBoogly."Love" token, awarded by rpserge."Love" token, awarded by SteffenD."Like" token, awarded by persun."Love" token, awarded by DaveDeer."Love" token, awarded by Raknaar."Love" token, awarded by cmermoud."Like" token, awarded by lichtwerk."Burninate" token, awarded by Emre_Can_Oezcan."Love" token, awarded by digim0nk."Burninate" token, awarded by LapisSea."Love" token, awarded by Dangry."Love" token, awarded by cmzw."Party Time" token, awarded by hadrien."Love" token, awarded by Stig."Love" token, awarded by Raimund58."Love" token, awarded by Yuro."Like" token, awarded by caneraslan."Yellow Medal" token, awarded by Lillya."Love" token, awarded by silex."Burninate" token, awarded by filedescriptor."Love" token, awarded by hitrpr."Love" token, awarded by sanek2005."Love" token, awarded by zNight."Party Time" token, awarded by Bit."Like" token, awarded by Oxicid."Love" token, awarded by charlie."Like" token, awarded by Moder.

Details

Summary

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.

Diff Detail

Repository
rB Blender
Branch
temp-geometry-viewport-preview (branched from master)
Build Status
Buildable 23978
Build 23978: arc lint + arc unit

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Wonder if there can be something like "view normalized values" option in case seeing overall distribution of values is more important.

For example, here, offset values for grass wind animation have negative values, and displaying them all black is not really helpful.

Wonder if there can be something like "view normalized values" option in case seeing overall distribution of values is more important.

We can consider adding such functionality at some point, but for now I'd like to see people build node groups that result in useful visualizations. That's way more flexible and can show us what functionality makes most sense to include in Blender directly.

  • Merge branch 'master' into temp-geometry-viewport-preview
  • add show viewer attribute checkbox
  • add Viewer Node option to View menu
  • fix hiding outline in curves sculpt mode
  • improve overlay drawing for curves
  • Merge branch 'master' into temp-geometry-viewport-preview
  • store active viewer in the workspace as a ground truth
  • highlight active viewer only in one node group instance
  • support disabling viewer with ctrl+shift+click
  • refactor ctrl+shift+click to support reenabling existing links to viewers
  • improve preferred domain for anonymous attributes
  • improve viewer node handling when there is an active viewer already
  • support instances attribute overlay
  • don't allow muting viewer node for now, this is consistent with all other viewer nodes
  • rename Viewer Attribute to Viewer Node in popover
  • Merge branch 'master' into temp-geometry-viewport-preview
  • change viewer text overlay
  • fix missing redraw
  • support toggling viewer node with icon in node header
  • Merge branch 'master' into temp-geometry-viewport-preview
  • cleanup
  • rename attribute overlay to viewer attribute overlay
  • use eye icon
  • disable all viewers when clicking in empty space
Jacques Lucke (JacquesLucke) retitled this revision from Geometry Nodes: Viewport preview (WIP). to Geometry Nodes: Viewport preview..Sep 28 2022, 1:27 PM
Jacques Lucke (JacquesLucke) edited the summary of this revision. (Show Details)
Jacques Lucke (JacquesLucke) edited the summary of this revision. (Show Details)
  • grey out overlay settings when appropriate
  • tweak property name

I can see we tweaking some of the behaviour after more test, but I think it is ready for master.

This revision is now accepted and ready to land.Sep 28 2022, 3:24 PM
  • enable viewer in some viewport if disabled in all
Hans Goudey (HooglyBoogly) requested changes to this revision.Sep 28 2022, 4:33 PM

This works very nicely! The only significant comment here is in wm_event_system.cc

source/blender/blenkernel/BKE_duplilist.h
53

It would make a bit more sense to me if this was a InstancesComponent pointer. Is there a reason you didn't do it that way?

source/blender/blenkernel/BKE_geometry_fields.hh
318
321
source/blender/blenkernel/BKE_viewer_path.h
47

Since there could be more than one?

source/blender/draw/engines/overlay/overlay_viewer_attribute.cc
62 ↗(On Diff #56234)

Looking up the viewer attribute by name for every instance seems expensive. Do you have an idea of how to improve this? Even if it isn't part of this patch.

63 ↗(On Diff #56234)

Return early

114–142 ↗(On Diff #56234)

Would be preferable to use const pointers here where possible

source/blender/draw/intern/draw_cache_impl_curve.cc
501

Looks like this colors_interpolated array isn't necessary-- it could just fill the vertex buffer directly.

source/blender/editors/space_node/node_select.cc
650

With the "ground truth" stored in the workspace currently, seems a bit simpler to clear that here.

source/blender/editors/space_view3d/view3d_draw.cc
1298 ↗(On Diff #56234)
source/blender/editors/util/ed_viewer_path.cc
26

Not a big deal either way though

source/blender/makesdna/DNA_view3d_defaults.h
41

Do we really want a default of 1.0? What about 0.8?

source/blender/makesdna/DNA_view3d_types.h
232

Can this go below sculpt_mode_face_sets_opacity?

source/blender/makesdna/DNA_workspace_types.h
148

This could use a comment to describe how it relates to the viewer path stored in editors.
I guess the other cases in DNA could use a short comment too.

source/blender/nodes/NOD_geometry_nodes_log.hh
318
source/blender/windowmanager/intern/wm_event_system.cc
491

It seems quite weird to process the viewer node in the generic event system. Is there somewhere else this could be done?

Generally, is storing a viewer path in the workspace necessary to make things work, or is it mainly for convenience and a more explicit ground truth? If the latter, maybe it's not worth adding this here.

This revision now requires changes to proceed.Sep 28 2022, 4:33 PM
Jacques Lucke (JacquesLucke) marked 12 inline comments as done.
  • Merge branch 'master' into temp-geometry-viewport-preview
  • fix typos
  • return early
  • avoid intermediate buffer
  • remove active viewer by clearing path in workspace
  • add const
  • use reference instead of pointer
  • change dna default
  • reorder dna fields
  • add comments
  • remove unused code
  • add comment
source/blender/blenkernel/BKE_duplilist.h
53

One reason right now is that this is also used to detect if the DupliObject belongs to a preview. A separate redundant flag could be added, but doesn't seem super necessary now.

source/blender/blenkernel/BKE_viewer_path.h
47

I was following existing naming conventions, e.g. action_id_remap. Think that's reasonable.

source/blender/draw/engines/overlay/overlay_viewer_attribute.cc
62 ↗(On Diff #56234)

Well, long term we should just pass all the instances to the renderer in one go. We could probably cache the value on the DupliObject somehow but doesn't seem worth it right now.
Performance wise I'm more concerned about creating a separate shading group for every instance, but didn't measure it yet.

114–142 ↗(On Diff #56234)

Not sure which pointer you refer to exactly, but curves_id can't be const right now because DRW_curves_texture_for_evaluated_attribute takes a non const Curves.

source/blender/windowmanager/intern/wm_event_system.cc
491

It's the ground truth, things work better now that it exists. Improved the comment a bit.
I tried to find another place for this, but couldn't find it. Previously this kind of check was done when editors were drawn, which was too late and led e.g. to double updates when the viewer path was updated as part of drawing code.

  • add ED_workspace_do_listen
Hans Goudey (HooglyBoogly) added inline comments.
source/blender/blenkernel/BKE_viewer_path.h
47

Then wouldn't it be called BKE_viewer_path_id_remap?

This revision is now accepted and ready to land.Sep 28 2022, 5:47 PM
This revision was automatically updated to reflect the committed changes.
Steff Kempink (mswf) added inline comments.
source/blender/blenkernel/BKE_duplilist.h
20

Typo? But it seems like this typedef is not even used within this file, because the typo got ignored.