Skip to content
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

Add support for structured noise (perlin) fuzzy skin #7678

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Arachnid
Copy link

@Arachnid Arachnid commented Dec 6, 2024

Description

Fixes #7467.

The existing fuzzy skin support does a good job of hiding printing artefacts, but uses a very naive algorithm based on randomly displacing points on the outside wall of an object. This means that there's no correlation between the displacements of vertically adjacent points, and this in turn gives the fuzzy skin a characteristic horizontal pattern that can accentuate rather than hide layer lines.

This PR adds libnoise, a library for creating structured noise, and uses it to enhance the fuzzy skin functionality with new options that have better aesthetics compared to the existing uniform random noise. Several noise algorithms are supported:

  • Perlin noise: A classic structured noise algorithm that creates spatially coherent noise.
  • Billow noise: A variation on perlin noise that has a more 'billowly' or cloud-like appearance.
  • Ridged Multifractal noise: Creates random ridgelike formations, or marble-like textures.
  • Voronoi: Divides space up into voronoi cells, and displaces each by a random amount. Creates a patchwork effect.

A number of parameters are provided to affect the output:

  • Feature size: Adjusts the size of the predominant features in the noise. In mm. Defaults to 1mm.
  • Octaves (all but Voronoi): Each noise algorithm uses several instances with decreasing feature size, and sums them. This controls how many instances are instantiated.
  • Persistence (Perlin, Billow only): Each octave contributes progressively less to the total. This controls the rate at which octaves' amplitude is reduced.

Existing parameters - depth and point distance - continue to be used in the expected manner.

Backwards-compatibility is provided for by having 'classic' as the default noise type when fuzzy skin is enabled.

I've included the library inline following the example of some other libraries used by Orca, as it's only available via download from Sourceforge via an interstitial. If there's a better way to do this, please let me know.

Screenshots/Recordings/Graphs

Screenshot from 2024-12-06 16-46-10

PXL_20241206_090346843 (1)
Bambulab Calibration Cube by prdak27.
0.2mm point distance, 0.2mm thickness.

PXL_20241206_090417016 (1)
0.2mm point distance, 0.2mm thickness.

PXL_20241206_090448835 (1)
PXL_20241206_154823381
Fuzzy Love Teddy Bear by SamActivity
Classic: 0.8mm point distance, 0.3mm thickness.
Voronoi: 0.2mm point distance, 0.2mm thickness, 5mm feature size
All others: 0.2mm point distance, 0.3mm thickness, 3mm feature size, 5 octaves, 0.66 persistence

@discip
Copy link
Contributor

discip commented Dec 7, 2024

@Arachnid
Thank you very much! 👍
Great, this is absolutely fantastic and contributes to Orca being the go to slicer!

I hope you don't mind: Here are some suggestions you might consider:

  1. Maybe you could reorder and rename the entries like this:

    • Structured skin
    • Noise type
    • Point distance
    • Amplitude
    • Feature size
    • Noise octaves
    • Noise persistence
    • Apply structure to first layer
  2. You may also want to hide irrelevant entries when a particular noise type is selected.

p.s.
Would it be possible to implement an option to use custom patterns (e.g. SVG) that define the structure of the skin? For example, something like a brick pattern.

@Arachnid
Copy link
Author

Arachnid commented Dec 8, 2024

I hope you don't mind: Here are some suggestions you might consider:

  1. Maybe you could reorder and rename the entries like this:

    • Structured skin
    • Noise type
    • Point distance
    • Amplitude
    • Feature size
    • Noise octaves
    • Noise persistence
    • Apply structure to first layer

I'm happy to consider it! I'd like to hear from the maintainers before renaming existing features, though - there may be concerns about confusion / backwards compatibility.

2. You may also want to hide irrelevant entries when a particular noise type is selected.

Already done!

p.s.
Would it be possible to implement an option to use custom patterns (e.g. SVG) that define the structure of the skin? For example, something like a brick pattern.

This is tricky. The existing noise library generates 3 dimensional noise, meaning we can get the value for any point just by querying it. Mapping a 2d object like an SVG to a surface is much more complex, and I'm afraid it's beyond my basic computational geometry skills!

@Arachnid
Copy link
Author

Arachnid commented Dec 9, 2024

Fixes #7467

@discip
Copy link
Contributor

discip commented Dec 9, 2024

@Arachnid

Fixes #7467

If you want the linked issue to be closed with the merge of this PR, you need to put it in the initial post via an edit. 😊

@Noisyfox
Copy link
Collaborator

Is it possible to add the libnoise as an external dep that can be downloaded as a zip during build?

@Arachnid
Copy link
Author

Is it possible to add the libnoise as an external dep that can be downloaded as a zip during build?

As far as I can tell, libnoise is only hosted on source forge, which has a browser interstitial for all downloads. I can try and bypass it for an automated download, but I was concerned that would be subject to breakage easily.

I can also delete irrelevant files such as docs, if that would help.

@Noisyfox
Copy link
Collaborator

I can also delete irrelevant files such as docs, if that would help.

Absolutely. Now my browser freezes as soon as I switch to the Files Changed tab

@discip
Copy link
Contributor

discip commented Dec 14, 2024

@Noisyfox
Could we please at least reorder the entries at this point?
I think the current order looks like it was patched together.

This is what I suggest to change in Tab.cpp:

2348        optgroup->append_single_option_line("fuzzy_skin");
2349        optgroup->append_single_option_line("fuzzy_skin_noise_type");
2350        optgroup->append_single_option_line("fuzzy_skin_point_distance");
2351        optgroup->append_single_option_line("fuzzy_skin_thickness");
2352        optgroup->append_single_option_line("fuzzy_skin_scale");
2353        optgroup->append_single_option_line("fuzzy_skin_octaves");
2354        optgroup->append_single_option_line("fuzzy_skin_persistence");
2355        optgroup->append_single_option_line("fuzzy_skin_first_layer");

Optionally line 2355 ("fuzzy_skin_first_layer") could be placed after 2349 ("fuzzy_skin_noise_type").

@Arachnid
While testing this very nice addition, I noticed that Multifractal and Billow are mixed up in the last image of the initial post. 😊

@Arachnid
Copy link
Author

I've reordered the options as suggested by @discip. I've also fixed the image - good catch.

I've also removed the docs folder to cut down on the number of files imported. Still happy to restructure it to download it at build time, if we have a good solution to the sourceforge hosting.

Copy link
Contributor

@discip discip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! 👍

Thank you!

@SeeTurtlee
Copy link

I've been playing with this for about a week now and its super cool! i was wondering however if it would be possible to add the option to apply fuzzy skin to the top layer? i know it's technically possible with https://github.com/TengerTechnologies/Fuzzyficator, but having it as an actual feature would be awesome!

@Arachnid
Copy link
Author

I've been playing with this for about a week now and its super cool! i was wondering however if it would be possible to add the option to apply fuzzy skin to the top layer? i know it's technically possible with https://github.com/TengerTechnologies/Fuzzyficator, but having it as an actual feature would be awesome!

Adding fuzzy skin to top surfaces is a whole different thing! I'd love to have it too, but I think it will require a separate pr reimplementing their hard work in C++.

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.

[Bounty: $250] Coherent noise fuzzy skin support
4 participants