Skip to content

New node: Blur #2477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

Conversation

calvintvu
Copy link

Closes #995

Implements both gaussian and box blurs under raster category

Screen.Recording.mp4

@calvintvu
Copy link
Author

Typo in commit message

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

Keavon commented Mar 25, 2025

I'll try to review this tomorrow.

@TrueDoctor
Copy link
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
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
Copy link
Member

Keavon commented Mar 25, 2025

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
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
Copy link
Member

Keavon commented Mar 26, 2025

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
Author

Yes ill keep that in mind

@Keavon
Copy link
Member

Keavon commented Mar 26, 2025

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
Copy link
Member

Keavon commented Apr 14, 2025

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
Copy link
Member

Keavon commented Apr 18, 2025

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
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
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
Copy link
Member

Keavon commented Apr 21, 2025

!build

Copy link

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

@Keavon
Copy link
Member

Keavon commented Apr 21, 2025

  • 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
Copy link
Member

Keavon commented Apr 21, 2025

Here is a test file you can work with:

blur-test.graphite.txt

@calvintvu
Copy link
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
Copy link
Member

Keavon commented Apr 21, 2025

!build

Copy link

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

@Keavon
Copy link
Member

Keavon commented Apr 23, 2025

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
Author

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

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