Geometry Nodes: Add Grease Pencil Input nodes

Grease Pencil geometry uses a handful of attributes to control a variety
of drawing behaviors. This patch exposes said properties as input nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/157224
This commit is contained in:
quackarooni 2026-06-12 16:59:05 +02:00 • committed by Hans Goudey
parent a95f69f476
commit 70898c5508
10 changed files with 256 additions and 0 deletions

View file

@ -171,6 +171,12 @@ class NODE_MT_gn_grease_pencil_read_base(node_add_menu.NodeMenu):
def draw(self, _context):
layout = self.layout
self.node_operator(layout, "GeometryNodeGreasePencilColor")
self.node_operator(layout, "GeometryNodeGreasePencilDrawTime")
self.node_operator(layout, "GeometryNodeGreasePencilFillID")
self.node_operator(layout, "GeometryNodeGreasePencilOpacity")
self.node_operator(layout, "GeometryNodeGreasePencilStrokeSoftness")
self.node_operator(layout, "GeometryNodeGreasePencilStrokeVisibility")
self.node_operator(layout, "GeometryNodeInputNamedLayerSelection")
self.draw_assets_for_catalog(layout, self.menu_path)

View file

@ -10690,6 +10690,12 @@ static void rna_def_nodes(BlenderRNA *brna)
define("GeometryNode", "GeometryNodeGizmoDial");
define("GeometryNode", "GeometryNodeGizmoLinear");
define("GeometryNode", "GeometryNodeGizmoTransform", rna_def_geo_gizmo_transform);
define("GeometryNode", "GeometryNodeGreasePencilColor");
define("GeometryNode", "GeometryNodeGreasePencilDrawTime");
define("GeometryNode", "GeometryNodeGreasePencilFillID");
define("GeometryNode", "GeometryNodeGreasePencilOpacity");
define("GeometryNode", "GeometryNodeGreasePencilStrokeSoftness");
define("GeometryNode", "GeometryNodeGreasePencilStrokeVisibility");
define("GeometryNode", "GeometryNodeGreasePencilToCurves");
define("GeometryNode", "GeometryNodeGridAdvect");
define("GeometryNode", "GeometryNodeGridCurl");

View file

@ -108,6 +108,12 @@ set(SRC
nodes/node_geo_gizmo_dial.cc
nodes/node_geo_gizmo_linear.cc
nodes/node_geo_gizmo_transform.cc
nodes/node_geo_grease_pencil_color.cc
nodes/node_geo_grease_pencil_draw_time.cc
nodes/node_geo_grease_pencil_fill_id.cc
nodes/node_geo_grease_pencil_opacity.cc
nodes/node_geo_grease_pencil_stroke_softness.cc
nodes/node_geo_grease_pencil_stroke_visibility.cc
nodes/node_geo_grease_pencil_to_curves.cc
nodes/node_geo_grid_advect.cc
nodes/node_geo_grid_clip.cc

View file

@ -0,0 +1,42 @@
/* SPDX-FileCopyrightText: 2026 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BKE_geometry_fields.hh"
#include "node_geometry_util.hh"
namespace blender::nodes::node_geo_grease_pencil_color__cc {
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_output<decl::Color>("Point"_ustr).structure_type(StructureType::Field);
b.add_output<decl::Color>("Fill"_ustr).structure_type(StructureType::Field);
}
static void node_geo_exec(GeoNodeExecParams params)
{
Field<ColorGeometry4f> vertex_color =
AttributeFieldInput::get_field<ColorGeometry4f, "vertex_color">();
params.set_output("Point"_ustr, std::move(vertex_color));
Field<ColorGeometry4f> fill_color =
AttributeFieldInput::get_field<ColorGeometry4f, "fill_color">();
params.set_output("Fill"_ustr, std::move(fill_color));
}
static void node_register()
{
static bke::bNodeType ntype;
geo_node_type_base(&ntype, "GeometryNodeGreasePencilColor"_ustr);
ntype.ui_name = "Grease Pencil Color";
ntype.ui_description = "Retrieve the color of Grease Pencil points and fills";
ntype.nclass = NODE_CLASS_INPUT;
ntype.declare = node_declare;
ntype.geometry_node_execute = node_geo_exec;
bke::node_register_type(ntype);
}
NOD_REGISTER_NODE(node_register)
} // namespace blender::nodes::node_geo_grease_pencil_color__cc

View file

@ -0,0 +1,41 @@
/* SPDX-FileCopyrightText: 2026 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BKE_geometry_fields.hh"
#include "node_geometry_util.hh"
namespace blender::nodes::node_geo_grease_pencil_draw_time__cc {
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_output<decl::Float>("Creation Time"_ustr).structure_type(StructureType::Field);
b.add_output<decl::Float>("Delta Time"_ustr).structure_type(StructureType::Field);
}
static void node_geo_exec(GeoNodeExecParams params)
{
Field<float> init_time = AttributeFieldInput::get_field<float, "init_time">();
params.set_output("Creation Time"_ustr, std::move(init_time));
Field<float> delta_time = AttributeFieldInput::get_field<float, "delta_time">();
params.set_output("Delta Time"_ustr, std::move(delta_time));
}
static void node_register()
{
static bke::bNodeType ntype;
geo_node_type_base(&ntype, "GeometryNodeGreasePencilDrawTime"_ustr);
ntype.ui_name = "Grease Pencil Draw Time";
ntype.ui_description = "Retrieve information as to when a Grease Pencil curve was drawn";
ntype.nclass = NODE_CLASS_INPUT;
ntype.default_width = bke::NodeWidth::_180;
ntype.declare = node_declare;
ntype.geometry_node_execute = node_geo_exec;
bke::node_register_type(ntype);
}
NOD_REGISTER_NODE(node_register)
} // namespace blender::nodes::node_geo_grease_pencil_draw_time__cc

View file

@ -0,0 +1,37 @@
/* SPDX-FileCopyrightText: 2026 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BKE_geometry_fields.hh"
#include "node_geometry_util.hh"
namespace blender::nodes::node_geo_grease_pencil_fill_id__cc {
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_output<decl::Int>("Fill ID"_ustr).structure_type(StructureType::Field);
}
static void node_geo_exec(GeoNodeExecParams params)
{
Field<int> fill_id = AttributeFieldInput::get_field<int, "fill_id">();
params.set_output("Fill ID"_ustr, std::move(fill_id));
}
static void node_register()
{
static bke::bNodeType ntype;
geo_node_type_base(&ntype, "GeometryNodeGreasePencilFillID"_ustr);
ntype.ui_name = "Grease Pencil Fill ID";
ntype.ui_description = "Retrieve information about the grouping of Grease Pencil fills";
ntype.nclass = NODE_CLASS_INPUT;
ntype.default_width = bke::NodeWidth::_160;
ntype.declare = node_declare;
ntype.geometry_node_execute = node_geo_exec;
bke::node_register_type(ntype);
}
NOD_REGISTER_NODE(node_register)
} // namespace blender::nodes::node_geo_grease_pencil_fill_id__cc

View file

@ -0,0 +1,41 @@
/* SPDX-FileCopyrightText: 2026 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BKE_geometry_fields.hh"
#include "node_geometry_util.hh"
namespace blender::nodes::node_geo_grease_pencil_opacity__cc {
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_output<decl::Float>("Point"_ustr).structure_type(StructureType::Field);
b.add_output<decl::Float>("Fill"_ustr).structure_type(StructureType::Field);
}
static void node_geo_exec(GeoNodeExecParams params)
{
Field<float> point_opacity = AttributeFieldInput::get_field<float, "opacity">();
params.set_output("Point"_ustr, std::move(point_opacity));
Field<float> fill_opacity = AttributeFieldInput::get_field<float, "fill_opacity">();
params.set_output("Fill"_ustr, std::move(fill_opacity));
}
static void node_register()
{
static bke::bNodeType ntype;
geo_node_type_base(&ntype, "GeometryNodeGreasePencilOpacity"_ustr);
ntype.ui_name = "Grease Pencil Opacity";
ntype.ui_description = "Retrieve the opacity of Grease Pencil points and fills";
ntype.nclass = NODE_CLASS_INPUT;
ntype.default_width = bke::NodeWidth::_160;
ntype.declare = node_declare;
ntype.geometry_node_execute = node_geo_exec;
bke::node_register_type(ntype);
}
NOD_REGISTER_NODE(node_register)
} // namespace blender::nodes::node_geo_grease_pencil_opacity__cc

View file

@ -0,0 +1,37 @@
/* SPDX-FileCopyrightText: 2026 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BKE_geometry_fields.hh"
#include "node_geometry_util.hh"
namespace blender::nodes::node_geo_grease_pencil_stroke_softness__cc {
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_output<decl::Float>("Softness"_ustr).structure_type(StructureType::Field);
}
static void node_geo_exec(GeoNodeExecParams params)
{
Field<float> softness = AttributeFieldInput::get_field<float, "softness">();
params.set_output("Softness"_ustr, std::move(softness));
}
static void node_register()
{
static bke::bNodeType ntype;
geo_node_type_base(&ntype, "GeometryNodeGreasePencilStrokeSoftness"_ustr);
ntype.ui_name = "Grease Pencil Stroke Softness";
ntype.ui_description = "Retrieve the softness of Grease Pencil strokes";
ntype.nclass = NODE_CLASS_INPUT;
ntype.default_width = bke::NodeWidth::_200;
ntype.declare = node_declare;
ntype.geometry_node_execute = node_geo_exec;
bke::node_register_type(ntype);
}
NOD_REGISTER_NODE(node_register)
} // namespace blender::nodes::node_geo_grease_pencil_stroke_softness__cc

View file

@ -0,0 +1,37 @@
/* SPDX-FileCopyrightText: 2026 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BKE_geometry_fields.hh"
#include "node_geometry_util.hh"
namespace blender::nodes::node_geo_grease_pencil_stroke_visibility__cc {
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_output<decl::Bool>("Is Hidden"_ustr).structure_type(StructureType::Field);
}
static void node_geo_exec(GeoNodeExecParams params)
{
Field<bool> hide_stroke = AttributeFieldInput::get_field<bool, "hide_stroke">();
params.set_output("Is Hidden"_ustr, std::move(hide_stroke));
}
static void node_register()
{
static bke::bNodeType ntype;
geo_node_type_base(&ntype, "GeometryNodeGreasePencilStrokeVisibility"_ustr);
ntype.ui_name = "Grease Pencil Stroke Visibility";
ntype.ui_description = "Retrieve the visibility of Grease Pencil strokes";
ntype.nclass = NODE_CLASS_INPUT;
ntype.default_width = bke::NodeWidth::_200;
ntype.declare = node_declare;
ntype.geometry_node_execute = node_geo_exec;
bke::node_register_type(ntype);
}
NOD_REGISTER_NODE(node_register)
} // namespace blender::nodes::node_geo_grease_pencil_stroke_visibility__cc

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:554a3003a1e68e7da457aae89d1593533e80c4dfd034f4b706eb8083c4d46012
size 2284711