Sculpt: Add per-brush input samples #117080

Merged
Hans Goudey merged 7 commits from Sean-Kim/blender:108109-unified-input-samples into main 2024-01-30 05:08:33 +01:00
Member

This pull request adds the ability for users to specify input_samples on a per brush basis.

The existing field in the main Paint struct forces all brushes of a particular tool type to use the same value. A new field was added to the Brush struct to allow for this value to be specified there instead, and a corresponding unified value in UnifiedPaintSettings has been created to allow users to use the same value across all brushes.

Limitations

While the previous functionality allowed for storing data on a per-tool basis, the current implementation in this pull request only provides users the ability to specify input_samples on a brush or overall basis. Therefore, if any user happens to currently specify different values for different tool modes, they will be unable to after this pull request is merged. Additionally, in the case that multiple non-default values exist for this field currently in a blend file, the current implementation does not favor a particular tool's value for migrating data into the UnifiedPaintSettings and instead leaves it at the default value of 1.

Testing

  • Added minor unit tests
  • make test results in 3 failures (46 - gpu, 49 - io_wavefront, 323 - imbuf_save), but these tests appear to fail even prior to any changes being applied when running locally
  • Manual testing with older version blend files to ensure the existing data is migrated appropriately

Appearance

image

Addresses #108109

This pull request adds the ability for users to specify `input_samples` on a per brush basis. The existing field in the main `Paint` struct forces all brushes of a particular tool type to use the same value. A new field was added to the `Brush` struct to allow for this value to be specified there instead, and a corresponding unified value in `UnifiedPaintSettings` has been created to allow users to use the same value across all brushes. ## Limitations While the previous functionality allowed for storing data on a per-tool basis, the current implementation in this pull request only provides users the ability to specify `input_samples` on a brush or overall basis. Therefore, if any user happens to currently specify different values for different tool modes, they will be unable to after this pull request is merged. Additionally, in the case that multiple non-default values exist for this field currently in a blend file, the current implementation does not favor a particular tool's value for migrating data into the `UnifiedPaintSettings` and instead leaves it at the default value of 1. ## Testing * Added minor unit tests * `make test` results in 3 failures (46 - gpu, 49 - io_wavefront, 323 - imbuf_save), but these tests appear to fail even prior to any changes being applied when running locally * Manual testing with older version blend files to ensure the existing data is migrated appropriately ## Appearance ![image](/attachments/097c9fc7-f34e-4219-92e9-4225a116206a) Addresses #108109
Author
Member

Tagging @Sergey @HooglyBoogly and @JulienKaspar as specified in the original issue for review.

Tagging @Sergey @HooglyBoogly and @JulienKaspar as specified in the original issue for review.
Sean Kim requested review from Sergey Sharybin 2024-01-13 00:16:20 +01:00
Sean Kim requested review from Julien Kaspar 2024-01-13 00:16:21 +01:00
Sean Kim requested review from Hans Goudey 2024-01-13 00:16:21 +01:00
Iliya Katushenock added this to the Sculpt, Paint & Texture project 2024-01-13 11:29:20 +01:00
Julien Kaspar approved these changes 2024-01-15 11:46:38 +01:00
Julien Kaspar left a comment
Member

On the user side this works exactly like expected 👍
This will be very useful for the upcoming essential brushes.

For now I'm fine with the loss of per mode Input Samples. At some point the Unified Settings should be stored per mode anyway, which would improve this further.

On the user side this works exactly like expected 👍 This will be very useful for the upcoming essential brushes. For now I'm fine with the loss of per mode Input Samples. At some point the Unified Settings should be stored per mode anyway, which would improve this further.
Julien Kaspar added the
Module
Sculpt, Paint & Texture
label 2024-01-16 10:17:30 +01:00
Sean Kim force-pushed 108109-unified-input-samples from 6509ffeda8 to 7ebb780257 2024-01-17 03:59:37 +01:00 Compare
Hans Goudey requested changes 2024-01-19 19:55:48 +01:00
Hans Goudey left a comment
Member

Looks good, just a few comments.

Looks good, just a few comments.
@ -0,0 +10,4 @@
#include "BKE_brush.hh"
namespace blender::bke::tests {
TEST(brush, BKE_brush_input_samples_get_unified)
Member

IMO these tests add more trouble than they're worth. The functions being tested are just a few lines long, with extremely simple logic. I'd suggest skipping them, and maybe instead spend time adding tests for more complex areas of the code :)

IMO these tests add more trouble than they're worth. The functions being tested are just a few lines long, with extremely simple logic. I'd suggest skipping them, and maybe instead spend time adding tests for more complex areas of the code :)
Author
Member

Will do, I was on the fence about adding them, but I decided to keep it in the PR when submitting just to err on the side of more rather than less.

Will do, I was on the fence about adding them, but I decided to keep it in the PR when submitting just to err on the side of more rather than less.
Member

You made the right call if you were on the fence :) I love to see the excitement about testing, just have to be pragmatic too I think

You made the right call if you were on the fence :) I love to see the excitement about testing, just have to be pragmatic too I think
Sean-Kim marked this conversation as resolved
@ -4559,6 +4559,61 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
FOREACH_NODETREE_END;
}
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 306, 12)) {
Member

Only the versioning in the 400.cc file should be necessary as far as I know. That will always be applied.

Only the versioning in the 400.cc file should be necessary as far as I know. That will always be applied.
Sean-Kim marked this conversation as resolved
@ -1339,2 +1343,4 @@
float secondary_rgb[3];
/** Unified brush stroke input samples. */
int input_samples;
Member

Could we just change the meaning of num_input_samples instead of adding a new field here? That seems simpler in the long run.

Could we just change the meaning of `num_input_samples` instead of adding a new field here? That seems simpler in the long run.
Author
Member

That seems like it would add more logic onto the python side of things to handle this instead of using the pattern that already exists for the UnifiedPaintSettings, and I think that having the flag stored with the other unified attributes while having the value stored in the Paint struct will add to confusion down the line. I'm not strictly opposed, but I think changing it this way groups the attribute nicely with other similar concepts.

That seems like it would add more logic onto the python side of things to handle this instead of using the pattern that already exists for the `UnifiedPaintSettings`, and I think that having the flag stored with the other unified attributes while having the value stored in the `Paint` struct will add to confusion down the line. I'm not strictly opposed, but I think changing it this way groups the attribute nicely with other similar concepts.
Member

Hmm, what I mean is just using the same integer in Paint. Why would that add logic in Python?

Hmm, what I mean is just using the same integer in `Paint`. Why would that add logic in Python?
Author
Member

It's not a big change, but this part of UnifiedPaintPanel.prop_unified :

        ups = context.tool_settings.unified_paint_settings
        prop_owner = brush
        if unified_name and getattr(ups, unified_name):
            prop_owner = ups

        row.prop(prop_owner, prop_name, icon=icon, text=text, slider=slider)

assumes that the only possible owners of a property are either the brush or the UnifiedPaintSettings struct. Keeping the value in Paint would either mean adding a property check against num_input_samples or adding a new optional property to the method signature to allow passing in the Paint object. In my opinion this seems like adding clutter to this method.

To me the added complexity of moving this attribute to UnifiedPaintSettings and deprecating the old one is worth it primarily due to future readability of the struct, instead of having the flag in one place and the actual value that it corresponds to somewhere else.

It's not a big change, but [this part](https://projects.blender.org/blender/blender/src/commit/b61496c5089260a5a35ed4863685ef072e7c5e79/scripts/startup/bl_ui/properties_paint_common.py#L89-L119 ) of `UnifiedPaintPanel.prop_unified` : ``` ups = context.tool_settings.unified_paint_settings prop_owner = brush if unified_name and getattr(ups, unified_name): prop_owner = ups row.prop(prop_owner, prop_name, icon=icon, text=text, slider=slider) ``` assumes that the only possible owners of a property are either the brush or the `UnifiedPaintSettings` struct. Keeping the value in `Paint` would either mean adding a property check against `num_input_samples` or adding a new optional property to the method signature to allow passing in the `Paint` object. In my opinion this seems like adding clutter to this method. To me the added complexity of moving this attribute to `UnifiedPaintSettings` and deprecating the old one is worth it primarily due to future readability of the struct, instead of having the flag in one place and the actual value that it corresponds to somewhere else.
Member

Aah, oops! I missed the separation between the two changes in this file, that they were in different structs. Sorry for wasting your time!

Aah, oops! I missed the separation between the two changes in this file, that they were in different structs. Sorry for wasting your time!
Author
Member

No worries, it was a fair question to ask! 😄

No worries, it was a fair question to ask! 😄
Sean-Kim marked this conversation as resolved
Sean Kim added 2 commits 2024-01-20 00:42:44 +01:00
Sean Kim requested review from Hans Goudey 2024-01-20 00:42:59 +01:00
Sean Kim added 1 commit 2024-01-25 03:52:19 +01:00
Hans Goudey approved these changes 2024-01-25 22:03:17 +01:00
Sean Kim added 1 commit 2024-01-25 22:09:20 +01:00
Member

@HooglyBoogly If this is all good to go could you merge the PR?

@HooglyBoogly If this is all good to go could you merge the PR?
Sean Kim added 1 commit 2024-01-29 21:15:40 +01:00
Hans Goudey merged commit a2b3fe5e01 into main 2024-01-30 05:08:33 +01:00
Sean Kim deleted branch 108109-unified-input-samples 2024-02-16 00:30:53 +01:00
Sign in to join this conversation.
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 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#117080
No description provided.