GPv3: Tint and Color modifiers #117297

Merged
Lukas Tönne merged 20 commits from LukasTonne/blender:gp3-color-modifier into main 2024-01-19 16:59:49 +01:00
Member

Implements the Tint and Color (aka. "Hue/Saturation") modifiers.

Testing is difficult for fill colors currently due to lack of renderer support.

Implements the Tint and Color (aka. "Hue/Saturation") modifiers. Testing is difficult for fill colors currently due to lack of renderer support.
Lukas Tönne added 4 commits 2024-01-18 18:03:43 +01:00
Hans Goudey reviewed 2024-01-18 18:10:17 +01:00
@ -0,0 +123,4 @@
for (const int64_t point_i : points) {
float3 factor = cmd.hsv;
if (use_curve) {
const float curve_input = points.size() >= 2 ? (float(point_i - points.first()) /
Member

It's a bit nicer to iterate over points.index_range() to avoid the subtraction of point_i - points.first():

for (const int i : points.index_range()) {
  const int point = points[i];
It's a bit nicer to iterate over `points.index_range()` to avoid the subtraction of `point_i - points.first()`: ``` for (const int i : points.index_range()) { const int point = points[i];
LukasTonne marked this conversation as resolved
Lukas Tönne added 1 commit 2024-01-18 18:12:39 +01:00
Falk David added this to the Grease Pencil project 2024-01-19 10:49:47 +01:00
Falk David requested review from Falk David 2024-01-19 10:50:00 +01:00
Falk David requested changes 2024-01-19 11:08:18 +01:00
Falk David left a comment
Member

Did a first pass. Didn't find anything major, just some cleanups :)

Did a first pass. Didn't find anything major, just some cleanups :)
@ -2542,11 +2544,10 @@ typedef enum GreasePencilModifierColorMode {
} GreasePencilModifierColorMode;
typedef enum GreasePencilOpacityModifierFlag {
MOD_GREASE_PENCIL_OPACITY_OPEN_INFLUENCE_PANEL = (1 << 0),
Member

Looks like these changes are not meant to be part of this PR?

Looks like these changes are not meant to be part of this PR?
LukasTonne marked this conversation as resolved
@ -7695,13 +7720,6 @@ static void rna_def_modifier_grease_pencil_opacity(BlenderRNA *brna)
srna, "rna_GreasePencilOpacityModifier_vertex_group_name_set");
rna_def_modifier_grease_pencil_custom_curve(srna);
prop = RNA_def_property(srna, "open_influence_panel", PROP_BOOLEAN, PROP_NONE);
Member

Maybe this one can also be put into another PR (or just committed as a cleanup)

Maybe this one can also be put into another PR (or just committed as a cleanup)
LukasTonne marked this conversation as resolved
@ -0,0 +45,4 @@
namespace blender {
using bke::greasepencil::Drawing;
using bke::greasepencil::FramesMapKey;
Member

Looks like you're not using FramesMapKey. Same for the other modifier.

Looks like you're not using `FramesMapKey`. Same for the other modifier.
LukasTonne marked this conversation as resolved
@ -0,0 +104,4 @@
const GreasePencilColorModifierData &cmd,
bke::CurvesGeometry &curves,
const IndexMask &curves_mask,
const MutableSpan<ColorGeometry4f> point_colors)
Member

point_colors -> vertex_colors

`point_colors` -> `vertex_colors`
LukasTonne marked this conversation as resolved
@ -0,0 +109,4 @@
const bool use_curve = (cmd.influence.flag & GREASE_PENCIL_INFLUENCE_USE_CUSTOM_CURVE);
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
Member

Looks like you just need attributes() here.

Looks like you just need `attributes()` here.
LukasTonne marked this conversation as resolved
@ -0,0 +110,4 @@
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
VArray<int> stroke_materials =
Member

const

`const`
LukasTonne marked this conversation as resolved
@ -0,0 +167,4 @@
bke::CurvesGeometry &curves = drawing.strokes_for_write();
IndexMaskMemory mask_memory;
IndexMask curves_mask = modifier::greasepencil::get_filtered_stroke_mask(
Member

const

`const`
LukasTonne marked this conversation as resolved
@ -0,0 +198,4 @@
const int frame = scene->r.cfra;
GreasePencil *grease_pencil = geometry_set->get_grease_pencil_for_write();
if (grease_pencil == nullptr) {
Member

This should be consistent with the other modifiers:

if (!geometry_set->has_grease_pencil()) {
   return;
}
GreasePencil &grease_pencil = *geometry_set->get_grease_pencil_for_write();
This should be consistent with the other modifiers: ``` if (!geometry_set->has_grease_pencil()) { return; } GreasePencil &grease_pencil = *geometry_set->get_grease_pencil_for_write(); ```
LukasTonne marked this conversation as resolved
@ -0,0 +203,4 @@
}
IndexMaskMemory mask_memory;
IndexMask layer_mask = modifier::greasepencil::get_filtered_layer_mask(
Member

const

`const`
LukasTonne marked this conversation as resolved
@ -17,6 +17,7 @@
#include "BKE_geometry_set.hh"
#include "BKE_grease_pencil.hh"
#include "BKE_modifier.hh"
#include "BKE_screen.hh"
Member

Same as the other comments: This can be it's own PR or just a cleanup commit :)

Same as the other comments: This can be it's own PR or just a cleanup commit :)
LukasTonne marked this conversation as resolved
@ -0,0 +166,4 @@
const GreasePencilTintModifierData &tmd,
bke::CurvesGeometry &curves,
const IndexMask &curves_mask,
const MutableSpan<ColorGeometry4f> point_colors)
Member

vertex_colors

`vertex_colors`
LukasTonne marked this conversation as resolved
@ -0,0 +173,4 @@
GREASE_PENCIL_INFLUENCE_INVERT_VERTEX_GROUP);
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
Member

Looks like you don't need the attributes_for_write() here, just attributes().

Looks like you don't need the `attributes_for_write()` here, just `attributes()`.
LukasTonne marked this conversation as resolved
@ -0,0 +174,4 @@
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
VArray<int> stroke_materials =
Member

const

`const`
LukasTonne marked this conversation as resolved
@ -0,0 +390,4 @@
const int frame = scene->r.cfra;
GreasePencil *grease_pencil = geometry_set->get_grease_pencil_for_write();
if (grease_pencil == nullptr) {
Member

Same comment here as for the other modifier :)

Same comment here as for the other modifier :)
LukasTonne marked this conversation as resolved
@ -0,0 +395,4 @@
}
IndexMaskMemory mask_memory;
IndexMask layer_mask = modifier::greasepencil::get_filtered_layer_mask(
Member

const

`const`
LukasTonne marked this conversation as resolved
@ -173,3 +173,3 @@
uiItemR(row, ptr, "use_custom_curve", UI_ITEM_NONE, "Custom Curve", ICON_NONE);
if (use_custom_curve) {
uiTemplateCurveMapping(row, ptr, "custom_curve", 0, false, false, false, false);
uiTemplateCurveMapping(layout, ptr, "custom_curve", 0, false, false, false, false);
Member

Seems like this fixed a bug that I introduced :D Please commit separately as a fix :)

Seems like this fixed a bug that I introduced :D Please commit separately as a fix :)
LukasTonne marked this conversation as resolved
Lukas Tönne added 1 commit 2024-01-19 11:24:11 +01:00
Falk David changed title from Tint and Color grease pencil modifiers to GPv3: Tint and Color modifiers 2024-01-19 11:25:57 +01:00
Lukas Tönne added 1 commit 2024-01-19 11:42:32 +01:00
Member

Quickly tested this locally (with the fill_color rendering now in main). Seems to work apart from the Gradient option which has no effect.

Quickly tested this locally (with the `fill_color` rendering now in main). Seems to work apart from the `Gradient` option which has no effect.
Lukas Tönne added 6 commits 2024-01-19 12:02:38 +01:00
Lukas Tönne added 1 commit 2024-01-19 12:04:06 +01:00
Falk David requested review from Hans Goudey 2024-01-19 12:04:27 +01:00
Member

Getting some warnings:

Forgot to call `finish()` for 'fill_color'.
Warning: Call `save()` to make sure that changes persist in all cases.

Maybe some function is returning early, befrore .finish() is called?

Getting some warnings: ``` Forgot to call `finish()` for 'fill_color'. Warning: Call `save()` to make sure that changes persist in all cases. ``` Maybe some function is returning early, befrore `.finish()` is called?
Lukas Tönne added 1 commit 2024-01-19 12:30:16 +01:00
Author
Member

Maybe some function is returning early, befrore .finish() is called?

Fixed.

> Maybe some function is returning early, befrore .finish() is called? Fixed.
Lukas Tönne added 1 commit 2024-01-19 12:37:49 +01:00
Lukas Tönne added 1 commit 2024-01-19 12:42:40 +01:00
Hans Goudey reviewed 2024-01-19 14:11:57 +01:00
@ -0,0 +108,4 @@
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
bke::AttributeAccessor attributes = curves.attributes();
const VArray<int> stroke_materials =
Member

Typically * is used instead of .varray. Just a bit shorter

Typically `*` is used instead of `.varray`. Just a bit shorter
LukasTonne marked this conversation as resolved
@ -0,0 +134,4 @@
});
}
static void modify_fill_color(Object *ob,
Member

Object * -> Object &

`Object *` -> `Object &`
LukasTonne marked this conversation as resolved
@ -0,0 +159,4 @@
fill_colors.finish();
}
static void modify_drawing(ModifierData *md, const ModifierEvalContext *ctx, Drawing &drawing)
Member

use references, use const for ModifierData

use references, use const for `ModifierData`
LukasTonne marked this conversation as resolved
@ -0,0 +192,4 @@
bke::GeometrySet *geometry_set)
{
auto *cmd = reinterpret_cast<GreasePencilColorModifierData *>(md);
const Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
Member

Other modifiers are using grease_pencil.runtime.eval_frame now

Other modifiers are using `grease_pencil.runtime.eval_frame` now
LukasTonne marked this conversation as resolved
@ -0,0 +172,4 @@
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
bke::AttributeAccessor attributes = curves.attributes();
const VArray<int> stroke_materials =
Member

* here instead of .varray too

`*` here instead of `.varray` too
LukasTonne marked this conversation as resolved
Lukas Tönne added 3 commits 2024-01-19 14:26:12 +01:00
Hans Goudey approved these changes 2024-01-19 15:48:51 +01:00
Falk David approved these changes 2024-01-19 16:54:28 +01:00
Lukas Tönne merged commit baeb4d7753 into main 2024-01-19 16:59:49 +01:00
Lukas Tönne deleted branch gp3-color-modifier 2024-01-19 16:59:52 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
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
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
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
EEVEE & Viewport
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
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
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
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#117297
No description provided.