Nodes: Add new shader for node sockets #119243
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#119243
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "lone_noel/blender:node-socket-shader"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Experiment to create a shader specifically for node sockets rather than
using the keyframe shader.
Motivation:
While there currently is no need for (2.) internally, there are a few
obvious use-cases for multi-input field (diamond) sockets like generalized
math nodes with an arbitrary number of inputs (Add, Multiply, Minimum etc.).
Screenshots
The changes for the wide reroute node below are not included in this PR.
It's only there to show how the socket shader can be used.
WIP: Experiment: Add new shader specifically for node socketsto WIP: Experiment: Nodes: Add new shader for node socketsGenerally looks like the right direction. Right now I mainly wonder why per-socket properties are passed as uniform parameters instead of as separate buffer which can have arbitrary size. It seems unconventional to have to limit the batch size to e.g. 32 sockets.
Looks nice overall, thanks for working on this. Just noticed a few cleanup changes.
@ -1813,0 +1817,4 @@
/* Node Socket shader parameters, must match the shader layout. */
struct NodeSocketShaderParameters {
rctf rect;
float color_inner[4];
Seems like
float4
would simplify this code a bit@ -1813,0 +1833,4 @@
gpu::Batch *batch;
Vector<NodeSocketShaderParameters, MAX_SOCKET_INSTANCE> params;
bool enabled;
} g_batch_nodesocket;
Because of the static initialization order fiasco, better to declare this static variable inside of
nodesocket_batch_init
.I see. I'm unsure how a declaration in
nodesocket_batch_init
would resolve this but I tried to apply the "construct on first use" idiom.@ -1813,0 +1835,4 @@
bool enabled;
} g_batch_nodesocket;
static gpu::Batch *nodesocket_batch_init(void)
(void)
->()
@ -1813,0 +1837,4 @@
static gpu::Batch *nodesocket_batch_init(void)
{
if (g_batch_nodesocket.batch == NULL) {
NULL
->nullptr
@ -1813,0 +1862,4 @@
/* draw single */
GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_NODE_SOCKET);
GPU_batch_uniform_4fv_array(
batch, "parameters", 4, (const float(*)[4])g_batch_nodesocket.params.data());
reinterpret_cast<const float(*)[4]>(
Same below
@ -1420,4 +1377,0 @@
immVertex2f(pos_id, locx, locy);
}
static void node_socket_tooltip_set(uiBlock &block,
I don't fully understand the reasoning for the removal of this tooltip code. Am I missing something?
No, this is just an oversight on my part!
@ -2426,0 +2277,4 @@
&rect, socket_color, outline_color, outline_thickness, dot_radius, sock.display_shape);
}
void node_draw_sockets(const SpaceNode &snode,
static void
@ -4467,6 +4161,32 @@ static StringRefNull reroute_node_get_auto_label(TreeDrawContext &tree_draw_ctx,
return label;
}
void reroute_node_draw_body(const bContext &C,
static void
@ -150,13 +150,6 @@ static bool node_under_mouse_tweak(const SpaceNode &snode, const float2 &mouse)
{
for (bNode *node : tree_draw_order_calc_nodes_reversed(*snode.edittree)) {
switch (node->type) {
case NODE_REROUTE: {
Things seem to work fine with this change too, just checking to make this change is purposeful though.
It was intentional but not really related to this patch anymore (it used to be part of the reroute changes).
node_to_view(*node, {node->locx, node->locy})
is not getting the node location, but the coordinates offset by{node->locx, node->locy}
relative to the node.The only reason this doesn't break currently is because the check for tweaking also looks for the node sockets, which for reroutes are identical to the node itself and therefore work as a fallback.
I made a separate PR for this: #130222
Great, thanks!
@ -0,0 +1,104 @@
/* SPDX-FileCopyrightText: 2018-2022 Blender Authors
2024
@ -0,0 +20,4 @@
/* Round the sharp corners of the square and diamond a little bit. */
#define CORNER_ROUNDING 0.15
/* Calculates a squared distance fiels of a square. */
fiels
->field
float4
. 16dc963286NULL
->nullptr
. Removevoid
parameter. 92bf2ebec6reinterpret_cast
. ee0dbc6c0c@ -1813,0 +1837,4 @@
static GBatchNodesocket &g_batch_nodesocket()
{
static GBatchNodesocket *nodesocket_batch = new GBatchNodesocket();
This should be a static variable rather than allocated on the heap. So just
static GBatchNodesocket nodesocket_batch;
Currently this leaks memory.
WIP: Experiment: Nodes: Add new shader for node socketsto Nodes: Add new shader for node socketsCheckout
From your project repository, check out a new branch and test the changes.