Skip to content

New node: Blur - #2477

Merged
Keavon merged 10 commits into
GraphiteEditor:masterfrom
calvintvu:blur-implementation
Apr 30, 2025
Merged

Keavon merged 10 commits into
GraphiteEditor:masterfrom
calvintvu:blur-implementation

Conversation

@calvintvu

Copy link
Copy Markdown
Contributor

Closes #995

Implements both gaussian and box blurs under raster category

Screen.Recording.mp4

@calvintvu

Copy link
Copy Markdown
Contributor Author

Typo in commit message

@TrueDoctor
TrueDoctor self-requested a review March 25, 2025 06:44
@Keavon

Keavon commented Mar 25, 2025

Copy link
Copy Markdown
Member

I'll try to review this tomorrow.

@TrueDoctor

Copy link
Copy Markdown
Member

Is there a specific reason why you chose to convert this to an image data type first instead of using or inbuilt one? Also @Keavon should blur happen in srgb or linear? They should give different results, so we have to think about which one is correct / what is compatible with other tools

@TrueDoctor

Copy link
Copy Markdown
Member

It also looks like the current implementation quantizes the values to 8 bit which is most likely not what we want. We should also take SIMD friendliness into account here and potentially try to re-enable that target flag and hope that the chrome bug from two years ago has been fixed

@Keavon

Keavon commented Mar 25, 2025

Copy link
Copy Markdown
Member

We should have both linear and gamma, with linear as default. https://www.youtube.com/watch?v=LKnqECcg6Gw

@calvintvu
calvintvu force-pushed the blur-implementation branch from 606c186 to 4182032 Compare March 26, 2025 01:09
@calvintvu

Copy link
Copy Markdown
Contributor Author

I've updated it to convert from linear/nonlinear before/after blurring using the functions from graphene_core::raster::Channel and changed from u8 values to f32

@Keavon

Keavon commented Mar 26, 2025

Copy link
Copy Markdown
Member

Thanks. In the future, could you please add your followup work as additional commits instead of amending the original commit, so it's possible to compare them?

@calvintvu

Copy link
Copy Markdown
Contributor Author

Yes ill keep that in mind

@Keavon

Keavon commented Mar 26, 2025

Copy link
Copy Markdown
Member

A couple code review notes before I do a proper code review:

  • You're repeating a whole lot of code by doing X then Y without reusing the logic, please do a self-review pass keeping DRY in mind
  • Please replace whole-number decimals so they end in a decimal point (.) instead of point-zero (.0), per our style guide
  • Run cargo clippy

@Keavon
Keavon force-pushed the master branch 4 times, most recently from aa7ff13 to e11b57a Compare April 6, 2025 11:41
@Keavon

Keavon commented Apr 14, 2025

Copy link
Copy Markdown
Member

I pushed some code review improvements. We still will need you to remove usage of the image crate which you shouldn't need to be doing. Once you do that, please use our existing Color data type's linear/gamma conversion functions. Then please test that a solid red and green has a black border when gamma is active, rather than yellow as with linear.

  • Expected with gamma
    capture
  • Expected with linear
    capture

@Keavon
Keavon marked this pull request as draft April 14, 2025 10:55
@Keavon Keavon changed the title Implementation of gaussian blur and box blur and raster node category New node: Blur Apr 14, 2025
@Keavon

Keavon commented Apr 18, 2025

Copy link
Copy Markdown
Member

Hi @calvintvu, just checking in to see if this is something you're still interested in finishing. Hope to hear from you! Thanks 😄

@calvintvu

Copy link
Copy Markdown
Contributor Author

Hi @calvintvu, just checking in to see if this is something you're still interested in finishing. Hope to hear from you! Thanks 😄

Hey @Keavon yeah I can take a look and implement the changes, just busy with some other things at the moment

@calvintvu

Copy link
Copy Markdown
Contributor Author

I removed the use of theimage crate and switched the conversion functions to the ones in color.rs (to_linear_srgb and to_gamma_srgb). The linear version has a yellow bar as expected but the gamma verson doesn't seem to have the black bar and I'm not sure how to fix that. Thanks

gamma
linear

@Keavon

Keavon commented Apr 21, 2025

Copy link
Copy Markdown
Member

!build

@github-actions

Copy link
Copy Markdown
📦 Build Complete for ca98d59
https://e9f90a6f.graphite.pages.dev

@Keavon

Keavon commented Apr 21, 2025

Copy link
Copy Markdown
Member
  • I believe in your implementation, "Gamma" is actually linear, and linear is actually double linear.
  • I also noticed the checkbox for "Box Blur" is backwards.

@Keavon

Keavon commented Apr 21, 2025

Copy link
Copy Markdown
Member

Here is a test file you can work with:

blur-test.graphite.txt

@calvintvu

Copy link
Copy Markdown
Contributor Author

Ok fixed box blur option and the colors seem to match up better
Screenshot 2025-04-20 at 23 34 12
Screenshot 2025-04-20 at 23 34 18

@Keavon

Keavon commented Apr 21, 2025

Copy link
Copy Markdown
Member

!build

@github-actions

Copy link
Copy Markdown
📦 Build Complete for a8b3a0e
https://13f892af.graphite.pages.dev

@Keavon

Keavon commented Apr 23, 2025

Copy link
Copy Markdown
Member

It's looking like we need to either premultiply or not premultiply the alpha (the opposite of what's currently being done) to avoid dark areas around the blurred rectangle edges when we have a transparent instead of a white background. We should have functions to premult and unpremult available in the Color method.

@calvintvu

Copy link
Copy Markdown
Contributor Author

Got these results after alpha premult/unpremult
Screenshot 2025-04-24 at 18 21 49
Screenshot 2025-04-24 at 18 21 41

@Keavon
Keavon marked this pull request as ready for review April 29, 2025 21:01
@Keavon
Keavon force-pushed the blur-implementation branch from a73ad95 to eee6225 Compare April 30, 2025 01:55
@Keavon

Keavon commented Apr 30, 2025

Copy link
Copy Markdown
Member

Please leave a comment in #995 saying that you fixed this issue (#2477) for tracking purposes. Thanks.

@Keavon
Keavon enabled auto-merge (squash) April 30, 2025 02:39
@Keavon
Keavon merged commit 23b2c5b into GraphiteEditor:master Apr 30, 2025
@calvintvu
calvintvu deleted the blur-implementation branch April 30, 2025 08:14
@Keavon

Keavon commented May 2, 2025

Copy link
Copy Markdown
Member

@calvintvu friendly reminder to:

Please leave a comment in #995 saying that you fixed this issue (#2477) for tracking purposes. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gaussian blur node

3 participants