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

Bug fix: Disable filament shrink compensation for multicolor/material prints which was causing incorrect colour segmentation. #5774

Conversation

igiannakas
Copy link
Contributor

@igiannakas igiannakas commented Jun 20, 2024

Description

Fixes the below issues reported when using filament shrink compensation together with a multi-color/material print.

The fix is detecting the use of multiple extruders and disables the compensation for multi material/color prints as it is not compatible. This is similar to the XY hole compensation that is correctly also disabled when printing multi-material prints.

This has been reported several times on both discord and here so maybe this correction helps.

Fixes #5756
Fixes #5152
Fixes #4551
Fixes #5664
Fixes #4091

image

Tests

Tested with multi colour print with shrink compensation - slices successfully
Tested with single colour print with shrink compensation - slices successfully and applies XY correction.

@igiannakas igiannakas marked this pull request as ready for review June 20, 2024 12:26
@igiannakas igiannakas changed the title Disable filament shrink compensation for multicolor/material prints Disable filament shrink compensation for multicolor/material prints which was causing incorrect colour segmentation. Jun 20, 2024
@igiannakas igiannakas changed the title Disable filament shrink compensation for multicolor/material prints which was causing incorrect colour segmentation. Bug fix: Disable filament shrink compensation for multicolor/material prints which was causing incorrect colour segmentation. Jun 20, 2024
@BioCookieYT
Copy link

Thanks for the workaround!
I'm wondering if there is another way to achieve filament shrinkage correction since the current way has some issues with some slicer features. An idea would be to simply use the already build in object scaling function as a shrinkage correction:
-> check if shrinkage is activated -> scale object using object scaling -> run slicing process

image

From my testing scaling doesn't affect MMU painting:
image
image

I'm not really in the C++ game so not sure if something like this would be possible. Just some idea since scaling is basically filament shrinkage correction from my understanding.

@igiannakas
Copy link
Contributor Author

The problem is that scaling may also vary by filament. One could be 0.9 and the other 0.95 or something. Then what do you use? 🤔

@BioCookieYT
Copy link

Good point 🤔
There are 3 ways I can think of:

  1. Cancel slicing with the error "Filament shrinkage must be equal"
  2. Calculate the average shrinkage from all used filaments
  3. Use the shrinkage of the "main filament" (in the cube example the black one -> the filament which was used first)

It kinda depends on the situation, for parts with just some colored text I would use option 3 or 1, for parts with like 4 colors in one layer option 2. Maybe an option for this in the Multicolor printer tab would be useful? (probably a lot of work to implement😐)

@igiannakas
Copy link
Contributor Author

It’s the same issue as XY hole compensation that is skipped when doing a multi color print. In my view, material shrinkage should be baked into the model by design, so I’ve never used this. And if needed we can just adjust the size of the model as a complete scale factor.

However, many ppl have this set up and then try to slice a multi material print and then it fails and they don’t know why. So I’m proposing this approach for now, to protect the user from using an incompatible feature.

I’ll investigate if there is an alternative way but not very hopeful as this feature was lifted from SS, which also has this issue, and neither Bambu nor prusa have this implemented, so we cannot cross check what the “upstream” branches have done.

@SoftFever
Copy link
Owner

I think it would be better to have a warning notification instead of silently disable shrinkage

@igiannakas
Copy link
Contributor Author

I think it would be better to have a warning notification instead of silently disable shrinkage

I tried that in a similar manner that XY compensation does but the method to raise the slicing message is protected and can’t call it from the parameter pointer :(. Any idea on what pop up to use as an alternative?

@igiannakas
Copy link
Contributor Author

Mmm let me try something different

@SoftFever
Copy link
Owner

I think it would be better to have a warning notification instead of silently disable shrinkage

I tried that in a similar manner that XY compensation does but the method to raise the slicing message is protected and can’t call it from the parameter pointer :(. Any idea on what pop up to use as an alternative?

I was referring to a notification(appears at the bottom right)
You can take a look at Print::validate() function, which is the place we do validate for the print and throw warning/errors notifications

@igiannakas
Copy link
Contributor Author

igiannakas commented Jun 20, 2024

Hey @SoftFever I've implemented the warning message in two places - one triggered at slice time and one at the validate function. Pick your favourite and I'll remove the other :)

The slice time message takes you to the multicoloured object, so that's nice; however it needs me to mark a function as public which I'm not too keen.

Pick one and I'll cleanup the code removing the other one 🥳

}
}
if(display_shrinkage_comp_error){
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SoftFever this is the slice time messsage here

}
}
if (filament_shrinkage_found){
warning->string = L("Filament shrinkage compensation is incompatible with multi color and multi material prints. It will be ignored when printing this model.");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

And the validate message here :)

@ExR90
Copy link

ExR90 commented Jun 22, 2024

I'm having this issue, but my filaments are set to 100% for shrink already. Easy to reproduce, starting in version 2.1 (any, even Beta) create a primitive cube. Paint one vertical side with any color, then slice. That color won't be in the finished product. Reverting to 2.0 and it behaves as expected.

I don't have the ability to compile my own build to test your fix for my issue but I thought I would chime in mentioning I'm having this problem with the shrinkage already at 100.

@igiannakas
Copy link
Contributor Author

I'm having this issue, but my filaments are set to 100% for shrink already. Easy to reproduce, starting in version 2.1 (any, even Beta) create a primitive cube. Paint one vertical side with any color, then slice. That color won't be in the finished product. Reverting to 2.0 and it behaves as expected.

I don't have the ability to compile my own build to test your fix for my issue but I thought I would chime in mentioning I'm having this problem with the shrinkage already at 100.

Please save the sliced cube project file and upload it here in a zip file.

I’ve done the exact same test as mentioned above and it doesn’t behave the same as yours.

@igiannakas
Copy link
Contributor Author

You can download the ready made build here: https://github.com/SoftFever/OrcaSlicer/actions/runs/9615570849

bottom of the page.

@ExR90
Copy link

ExR90 commented Jun 22, 2024

I'm having this issue, but my filaments are set to 100% for shrink already. Easy to reproduce, starting in version 2.1 (any, even Beta) create a primitive cube. Paint one vertical side with any color, then slice. That color won't be in the finished product. Reverting to 2.0 and it behaves as expected.
I don't have the ability to compile my own build to test your fix for my issue but I thought I would chime in mentioning I'm having this problem with the shrinkage already at 100.

Please save the sliced cube project file and upload it here in a zip file.

I’ve done the exact same test as mentioned above and it doesn’t behave the same as yours.

@igiannakas

Video of the behavior in 2.0 and 2.1 from my POV. I am on MacOS 14.5 (23F79) on M3 CPU
https://share.zight.com/eDuKnZX6

Project file of the test cube and Gcode created of same cube is attached.
cube with 3 colors.zip

@ExR90
Copy link

ExR90 commented Jun 22, 2024

You can download the ready made build here: https://github.com/SoftFever/OrcaSlicer/actions/runs/9615570849

bottom of the page.

I tried this but cannot execute the binary, Finder tries to launch it and I get an error that the file is corrupted. It unzipped fine into the DMG, which also mounted fine and was able to extract the binary fine - it just states it is damaged when I try to run it.

Zight 2024-06-22 at 3 01 28 AM

@igiannakas
Copy link
Contributor Author

You can download the ready made build here: https://github.com/SoftFever/OrcaSlicer/actions/runs/9615570849
bottom of the page.

I tried this but cannot execute the binary, Finder tries to launch it and I get an error that the file is corrupted. It unzipped fine into the DMG, which also mounted fine and was able to extract the binary fine - it just states it is damaged when I try to run it.

Zight 2024-06-22 at 3 01 28 AM

You need to run this command here to sign the file:
xattr -dr com.apple.quarantine /Applications/OrcaSlicer.app

@igiannakas
Copy link
Contributor Author

Your project file attached above is slicing OK for me:
image

image

Honestly I'm lost as cannot reproduce it :(

@SoftFever any thoughts?

@ExR90
Copy link

ExR90 commented Jun 23, 2024

Your project file attached above is slicing OK for me:

Honestly I'm lost as cannot reproduce it :(

@SoftFever any thoughts?

I thought maybe there was something bitched up in the preferences, so I signed into my Mac with a new user, which gave me a brand new profile like on a fresh new install of Orca - it took me through the wizard and everything. I did not configure anything other than saying I had an X1C, then did the test shown above which appears to suggest the preferences are not storing something to cause the problem.

@ExR90
Copy link

ExR90 commented Jun 23, 2024

@igiannakas

Curious, I am on a Mac, and so is the other person that just chimed in on this thread. You on PC or Mac? Maybe there is something to that with respect to OS build?

@igiannakas
Copy link
Contributor Author

I’m on an M1 Pro MacBook…

@ExR90
Copy link

ExR90 commented Jun 23, 2024

I’m on an M1 Pro MacBook…

No idea then. If I roll back to 2.0 it works fine. Something strange is afoot at the local Circle-K....

@igiannakas
Copy link
Contributor Author

Just sliced the above model successfully with an M1 MacBook Pro. We need someone to debug this with an Intel Mac? Looks like this is happening with that only?

image

@igiannakas
Copy link
Contributor Author

@SoftFever need help :) :) :)

I've been trying to investigate this - but I'm hitting a brick wall.

There are two issues here.

Issue 1: Shrink compensation, that is addressed with this PR successfully (pending comments above etc)

Issue 2: There seems to be a secondary issue that is present in the built files from the GitHub actions:

The below is taken from the build of this PR. Also it's the same with the main release build.
image

However when I build the main branch locally with already built dependencies all is good:
image

Then I deleted my GitHub local folder including all build files etc and recloned the repo and rebuilt from scratch. It still works properly even after a clean dependency rebuild etc.

I've also tried running a build using a slightly older version of the GitHub actions on my cloned main branch here:
https://github.com/igiannakas/OrcaSlicer/actions/workflows/build_all.yml

Firstly I downloaded my dev branch binaries from here:
https://github.com/igiannakas/OrcaSlicer/actions/runs/9632430284

These were built with dependencies cached around 2 weeks ago.
https://github.com/igiannakas/OrcaSlicer/actions/caches

It doesnt work again... So there is something up with the way the actions are building the binary for MacOS as it works with a local build but doesnt work with a GitHub actions build...

image

@Maximizer18
Copy link

@SoftFever need help :) :) :)

I've been trying to investigate this - but I'm hitting a brick wall.

There are two issues here.

Issue 1: Shrink compensation, that is addressed with this PR successfully (pending comments above etc)

Issue 2: There seems to be a secondary issue that is present in the built files from the GitHub actions:

The below is taken from the build of this PR. Also it's the same with the main release build. image

However when I build the main branch locally with already built dependencies all is good: image

Then I deleted my GitHub local folder including all build files etc and recloned the repo and rebuilt from scratch. It still works properly even after a clean dependency rebuild etc.

I've also tried running a build using a slightly older version of the GitHub actions on my cloned main branch here: https://github.com/igiannakas/OrcaSlicer/actions/workflows/build_all.yml

Firstly I downloaded my dev branch binaries from here: https://github.com/igiannakas/OrcaSlicer/actions/runs/9632430284

These were built with dependencies cached around 2 weeks ago. https://github.com/igiannakas/OrcaSlicer/actions/caches

It doesnt work again... So there is something up with the way the actions are building the binary for MacOS as it works with a local build but doesnt work with a GitHub actions build...

image

Hi, so I'm encountering the same issue on Mac OS 12.7.5
Orca slicer version 2.0.0 works perfectly fine. I don't know the slightest bit about code, but can't you see what changes between the 2 versions to see what could be causing this?

@Maximizer18
Copy link

Just sliced the above model successfully with an M1 MacBook Pro. We need someone to debug this with an Intel Mac? Looks like this is happening with that only?

image

I have an intel Mac. Tell me what I need to do to test whatever.

@ExR90
Copy link

ExR90 commented Jun 24, 2024

Just sliced the above model successfully with an M1 MacBook Pro. We need someone to debug this with an Intel Mac? Looks like this is happening with that only?

image

I have an intel Mac. Tell me what I need to do to test whatever.

It isn't Intel or Mac silicon only. I've got M3 with the problem, others don't. As others have said it impacts any 2.1 version. All 2.0 versions and before slice fine. I've tried fresh install on fresh user profile and no change in behavior, as I had thought maybe something in the preferences was causing this but no.

…rink-compensation-for-multicolor/material-prints
…rink-compensation-for-multicolor/material-prints
@igiannakas
Copy link
Contributor Author

igiannakas commented Jun 25, 2024

Latest nightly Mac build should solve the non shrinkage related MMU issue. Download from the nightly and use this command to "sign" it if needed so it opens.

xattr -dr com.apple.quarantine /Applications/OrcaSlicer.app

@SoftFever
Copy link
Owner

I've updated the CI/CD build script, the problem should be fixed.

@Maximizer18
Copy link

Nightly build works! Thank you guys! Would the next update of the regular build include this fix?

@ExR90
Copy link

ExR90 commented Jun 26, 2024

@igiannakas @SoftFever

Just tried the nightly and it DOES solve the "no color on vertical surfaces" issue. Hooray!

@SoftFever
Copy link
Owner

Thank you @igiannakas

I have two feedback:

  1. I think a warning in Print::validate is sufficient.
  2. It's probably better to check whether all used filaments have same shrinkage value? e.g. if all used filaments has 98% shrinkage, then they should just work fine. There is a way to get what filaments are used in this print, I cant' remember whether the info is available before the validation check at the moment though.

@igiannakas
Copy link
Contributor Author

I tried it by checking if the extruders have the same shrink comp value but the algo fails even if the shrink value is the same:

image
image

image

I've pushed the latest update removing the slice time message :)

@igiannakas
Copy link
Contributor Author

igiannakas commented Jun 29, 2024

My hunch is that the subsequent polygon segmentation ops dont like the polygons having moved.

Also if memory is not failing me, I've noticed that this:
const size_t extruder_id = pr->extruder(FlowRole::frPerimeter) - 1;
Returns all extruders when even one has shrink compensation enabled... Which is very very odd as I would have guessed the below correctly identifies the associated extruder but for some reason it appears not to.

unsigned int PrintRegion::extruder(FlowRole role) const
{
    size_t extruder = 0;
    if (role == frPerimeter || role == frExternalPerimeter)
        extruder = m_config.wall_filament;
    else if (role == frInfill)
        extruder = m_config.sparse_infill_filament;
    else if (role == frSolidInfill || role == frTopSolidInfill)
        extruder = m_config.solid_infill_filament;
    else
        throw Slic3r::InvalidArgument("Unknown role");
    return extruder;
}

@SoftFever
Copy link
Owner

My hunch is that the subsequent polygon segmentation ops dont like the polygons having moved.

Also if memory is not failing me, I've noticed that this: const size_t extruder_id = pr->extruder(FlowRole::frPerimeter) - 1; Returns all extruders when even one has shrink compensation enabled... Which is very very odd as I would have guessed the below correctly identifies the associated extruder but for some reason it appears not to.

unsigned int PrintRegion::extruder(FlowRole role) const
{
    size_t extruder = 0;
    if (role == frPerimeter || role == frExternalPerimeter)
        extruder = m_config.wall_filament;
    else if (role == frInfill)
        extruder = m_config.sparse_infill_filament;
    else if (role == frSolidInfill || role == frTopSolidInfill)
        extruder = m_config.solid_infill_filament;
    else
        throw Slic3r::InvalidArgument("Unknown role");
    return extruder;
}

I see.
Thank you for digging deep into the issue.
I'm thinking it might be better to port PrusaSlicer's new implementation when any of us have time: prusa3d/PrusaSlicer@4b8fe98

I feel that is a better implementation.
What do you think?

@igiannakas
Copy link
Contributor Author

igiannakas commented Jun 30, 2024

Oooh that looks nice!

@igiannakas
Copy link
Contributor Author

Seems pretty straightforward to port - I’ll have a go at it next week/ the week after once I get a bit of free time from work :)

closing this PR as there is a better way forward.

@igiannakas igiannakas closed this Jun 30, 2024
@igiannakas igiannakas deleted the Disable-filament-shrink-compensation-for-multicolor/material-prints branch June 30, 2024 16:34
@igiannakas igiannakas restored the Disable-filament-shrink-compensation-for-multicolor/material-prints branch July 1, 2024 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants