diff options
author | Dalai Felinto <dalai@blender.org> | 2021-09-28 18:02:47 +0300 |
---|---|---|
committer | Dalai Felinto <dalai@blender.org> | 2021-09-28 18:03:03 +0300 |
commit | ff7e67afd5de2d0ce6614ecfda9a70735a2479ba (patch) | |
tree | fda70f5c7a799713c08f2559a27d30f336f2f2d1 /source/blender/editors/space_node | |
parent | 728ae33f3720894a59009e28d33ae82f77c380b3 (diff) |
Geometry Nodes: Dashed lines for function flow
Use dashes to represent the function flow (while keeping continuous
lines for the data-flow).
It is important to tell both flows apart (the data and the function
flow). The sockets help with that, the noodles help this further.
The "data flow" is evaluated at every single node. A user can inspect
the output sockets of those nodes and have a glimpse at their values.
The "function flow" (nodes) however is only evaluated in the geometry
nodes. The noodles are not transporting data in the same sense of the
"data flow". All that can be inspected are the attributes the functions
depend on.
Having this clearly communicated should help users to inspect the
nodetrees, read and understand the different flows in the same tree.
---
Known limitations:
At the moment the dash lines are not equidistant:
* It would be nice to get the "uv.x" to be resampled for the bezier curve
so the dashes are equally distributed in the curve.
* Using distance between the P3 and P0 instead of the real bezier curve
length seems to be fine.
---
Full disclaimer:
Changes with that much of a visual impact tend to be controversial. So
far the main feedback is that dashed lines can be associated to broken
link, and that there are better ways to represent the flows (or
different information that should be visually represented).
I'm fully aware of that. However dashed lines are already used in the
viewport and outliner to indicate (hierarchical) relation. Besides,
other approaches (double-lines, having the data flow to be more
distinct, ...) didn't pan out in the end (or didn't look as good as
this).
---
Impact in other editors:
The compositor uses mostly a "data flow" nodetree, so no change is
expected there.
The shader nodetree is one that could but doesn't have to change its
visual language.
The shader nodetree uses mostly "function flow" with some "data flow" nodes.
One can argue that it should be adapted to follow the
same pattern as geometry nodes (with the new noodles and the diamond
sockets). Oh the other hand, a shader nodetree has a single context.
When a node depends on the "UV", there is only one UV at a time for the
entire nodetree. So it can also be treated as a psedo "data flow"
nodetree if we want to avoid too many changes in other parts of Blender.
Differential Revision: https://developer.blender.org/D12602
Diffstat (limited to 'source/blender/editors/space_node')
-rw-r--r-- | source/blender/editors/space_node/drawnode.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index f64df0e7142..9e6662855cc 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -3934,10 +3934,12 @@ static struct { uint colid_id, muted_id; uint dim_factor_id; uint thickness_id; + uint dash_factor_id; GPUVertBufRaw p0_step, p1_step, p2_step, p3_step; GPUVertBufRaw colid_step, muted_step; GPUVertBufRaw dim_factor_step; GPUVertBufRaw thickness_step; + GPUVertBufRaw dash_factor_step; uint count; bool enabled; } g_batch_link; @@ -3956,6 +3958,8 @@ static void nodelink_batch_reset() g_batch_link.inst_vbo, g_batch_link.dim_factor_id, &g_batch_link.dim_factor_step); GPU_vertbuf_attr_get_raw_data( g_batch_link.inst_vbo, g_batch_link.thickness_id, &g_batch_link.thickness_step); + GPU_vertbuf_attr_get_raw_data( + g_batch_link.inst_vbo, g_batch_link.dash_factor_id, &g_batch_link.dash_factor_step); g_batch_link.count = 0; } @@ -4077,6 +4081,8 @@ static void nodelink_batch_init() &format_inst, "dim_factor", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); g_batch_link.thickness_id = GPU_vertformat_attr_add( &format_inst, "thickness", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + g_batch_link.dash_factor_id = GPU_vertformat_attr_add( + &format_inst, "dash_factor", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); g_batch_link.inst_vbo = GPU_vertbuf_create_with_format_ex(&format_inst, GPU_USAGE_STREAM); /* Alloc max count but only draw the range we need. */ GPU_vertbuf_data_alloc(g_batch_link.inst_vbo, NODELINK_GROUP_SIZE); @@ -4154,7 +4160,8 @@ static void nodelink_batch_add_link(const SpaceNode *snode, bool drawarrow, bool drawmuted, float dim_factor, - float thickness) + float thickness, + float dash_factor) { /* Only allow these colors. If more is needed, you need to modify the shader accordingly. */ BLI_assert(ELEM(th_col1, TH_WIRE_INNER, TH_WIRE, TH_ACTIVE, TH_EDGE_SELECT, TH_REDALERT)); @@ -4175,6 +4182,7 @@ static void nodelink_batch_add_link(const SpaceNode *snode, muted[0] = drawmuted; *(float *)GPU_vertbuf_raw_step(&g_batch_link.dim_factor_step) = dim_factor; *(float *)GPU_vertbuf_raw_step(&g_batch_link.thickness_step) = thickness; + *(float *)GPU_vertbuf_raw_step(&g_batch_link.dash_factor_step) = dash_factor; if (g_batch_link.count == NODELINK_GROUP_SIZE) { nodelink_batch_draw(snode); @@ -4191,10 +4199,13 @@ void node_draw_link_bezier(const View2D *v2d, { const float dim_factor = node_link_dim_factor(v2d, link); float thickness = 1.5f; + float dash_factor = 1.0f; if (snode->edittree->type == NTREE_GEOMETRY) { if (link->fromsock && link->fromsock->display_shape == SOCK_DISPLAY_SHAPE_DIAMOND) { /* Make field links a bit thinner. */ thickness = 1.0f; + /* Draw field as dashes. */ + dash_factor = 0.75f; } } @@ -4221,7 +4232,8 @@ void node_draw_link_bezier(const View2D *v2d, drawarrow, drawmuted, dim_factor, - thickness); + thickness, + dash_factor); } else { /* Draw single link. */ @@ -4248,6 +4260,7 @@ void node_draw_link_bezier(const View2D *v2d, GPU_batch_uniform_1i(batch, "doMuted", drawmuted); GPU_batch_uniform_1f(batch, "dim_factor", dim_factor); GPU_batch_uniform_1f(batch, "thickness", thickness); + GPU_batch_uniform_1f(batch, "dash_factor", dash_factor); GPU_batch_draw(batch); } } |