Cura icon indicating copy to clipboard operation
Cura copied to clipboard

[FR] Implement gradient infill

Open extesy opened this issue 4 years ago • 44 comments

Based on the idea from https://www.cnckitchen.com/blog/gradient-infill-for-3d-prints and code from https://github.com/CNCKitchen/GradientInfill:

alt text

extesy avatar Jan 11 '20 18:01 extesy

The main problem with this solution : it's not possible to use it on every machine type. I have made some tests on my Ender 3 and the result is not correct. You need to have a machine with a direct drive feeder . With a bowden type extruder, it 's not possible to have sufficient precision. This is linked to the fact that the wire driving is subject to skating (if only one driving wheel) and a direct link to the stepping motor (Estep = 93). So, logically, for maximum precision of the extrusion, you need a direct drive, and a much more linear dual drive (Estep = 415) like the BMG clone, for example on a Ender 3 machine.

5axes avatar Jan 21 '20 11:01 5axes

I have a SV01 which comes with a Titan/v6 clone and it would probably work OK. But as it happens, I am not particularly keen to implement this anyway.

smartavionics avatar Jan 21 '20 11:01 smartavionics

I like this. I usually end up manually adding infill overrides at joints to make them stronger but just varying the thickness would probably work better because the infill pattern wouldn't need to change.

It would be great if this could automatically get applied only where parts of a model get smaller (walls are closer) or where parts make a sharp turn (at joints, etc).

agibson2 avatar Feb 15 '20 06:02 agibson2

I'm still not convinced that gradient infill is going to be much use but it's a rainy day here so I thought I would have a play. Here's a teaser screen shot...

Screenshot_2020-02-15_18-45-24

My approach has been "cheap and cheerful" inasmuch that I am not calculating how far each infill line segment is from the boundary of the part in two dimensions (let alone 3 dimensions) because that would be very slow. So it simply use the distance along each infill line to modulate the line width. As you can see from the above image, this causes long infill lines that pass near the boundary of the object to be thinner than you may want. Whether this is a real problem in practice needs to be determined. I shall probably make a build with this tomorrow.

smartavionics avatar Feb 15 '20 18:02 smartavionics

By this evening (UK time) there should be Linux and Windows builds that have the experimental settings for gradient infill. In the end, I implemented 4 types of gradient infill. They only differ in how they determine the distance from the infill line being drawn to the boundary:

1D - trivial and fast, it simply calculates the distance to the closest end of the current infill line.

2D - bit slower, now calculates the minimum distance to the boundary on the current layer.

2D+ - same as 2D but also looks at the distance to the build plate and to the top of the print. A good choice if the model doesn't vary in height.

3D - the full monty, calculates the min distance to the nearest wall or skin (the object boundary). Could be very slow for large models and dense infill.

There's settings for specifying the min and max flows and for modifying the speed where the infill flow rate is changing.

Please experiment and report back here if you have any comments.

smartavionics avatar Feb 16 '20 15:02 smartavionics

Oh, I forgot to say that this release also has some upstream changes that may modify profiles and config files,etc. I don't know for sure but I strongly recommend backing up all your cura config files, etc. before using this release.

Personally, I put all of my cura config in a git repo and from time to time I do a snapshot so I can always get back to a working installation. I don't trust the upstream coders (much) so whenever they do anything that looks dangerous, I save my current config files so I can recover when they get trashed!

smartavionics avatar Feb 16 '20 15:02 smartavionics

Thanks a lot for implementing this, @smartavionics! I haven't actually printed anything yet with this feature, but I ran a few slicing experiments:

  1. It only works with infill types that use straight lines but doesn't work with curved infills (concentric, gyroid, schwarz).
  2. Looks like the infill line thickness is changing every 5mm or so. Can this be made configurable as well so that the transitions are a bit smoother?

extesy avatar Feb 16 '20 17:02 extesy

1 - I think it does work with gyroid and schwarz infills

Screenshot_2020-02-16_17-33-41

2 - well, given that the extruder can't step change the line width anyway, I doubt if you will see the transitions much. Let's wait until you have done some testing before adding yet another setting.

smartavionics avatar Feb 16 '20 17:02 smartavionics

I've tried curved infills again and found out that they only don't work in 1D mode, probably because instead of a single line they connect lots of tiny lines so that the gradient threshold is not triggered. Works great in 2D, 2D+ and 3D modes.

extesy avatar Feb 16 '20 17:02 extesy

Ah yes, good point. I'd forgotten that.

smartavionics avatar Feb 16 '20 17:02 smartavionics

Hm, concentric doesn't seem to work in any mode: image

extesy avatar Feb 16 '20 17:02 extesy

LOL, I didn't know that concentric infill existed!

smartavionics avatar Feb 16 '20 17:02 smartavionics

Yeah, I never use it myself, but I thought it's an interesting bug. 😄

extesy avatar Feb 16 '20 17:02 extesy

Just checked, the concentric infill is implemented as polygons. So are the cross and cross3d infill types. All the other infill types are implemented as a bunch of lines and they support the gradient infill. The polygons don't and I doubt if I will implement it for them.

smartavionics avatar Feb 16 '20 18:02 smartavionics

Fair enough, it already works for all practical use cases that I care about. Thanks again for implementing this! 👍

extesy avatar Feb 16 '20 18:02 extesy

Would be great also to get the possibility to change the infill printing speed as well as the flow for the people who don't have a direct drive (Parameter Max and Min speed) . https://github.com/CNCKitchen/GradientInfill/issues/12

5axes avatar Feb 17 '20 10:02 5axes

Try the speed factor setting. This adjusts the print speed where the extrusion rate is changing.

Screenshot_2020-02-17_10-54-39

You can use the layer view colouring to see the speed changes.

This hasn't really been tested at all (OK, I did a couple of small prints) so it may need further development. All feedback is welcome.

smartavionics avatar Feb 17 '20 10:02 smartavionics

As expected the result is not so nice with just one parameter for the speed factor. If your machine doesn't have a direct drive the print speed must be inversely proportional to the material flow. grad grad2

5axes avatar Feb 17 '20 22:02 5axes

hereafter a basic test 86695454_1243591222513905_6862110467620339712_o

  • Left part : Your gradient Infill ( 2D) without speed variation, the infill width variation is hard to mesure.
  • Center part : same gradient infill but with a Gradiant Infill Speed Factor = 50%
  • Right part the same part previously made with the Gradiant Infill postprocessor script : and a Speed variation 50% - 200% Flow variation 200% - 50% GradientInfill.py

5axes avatar Feb 17 '20 22:02 5axes

Thanks for giving it a go. I would say that the middle and right test parts are pretty similar. If anything, the middle part shows more infill width variation than the right part. Have you tried measuring the line widths with digital calipers?

smartavionics avatar Feb 17 '20 22:02 smartavionics

Yes, With my machine (Ender 3) without direct drive default settings line width : 0.4mm so the expected width should be for 200% 50% -> 0.8 - 0.2 - 0.8

  • Left part, Gradiant Infill ( 2D) without speed variation : Average variation 0.47 - 0.38 - 0.46
  • Center part, same gradiant infill but with a Gradiant Infill Speed Factor = 50% : 0.47 - 0.73 - 0.26 - 0.74 - 0.5
  • Right part with the Gradiant Infill postprocessor script (I have made a new part to be sure to use the same settings and same Cura release) : 0.73 - 0.24 - 0.71

86807007_1243616512511376_2482918729801793536_o

Settings of the Gradient Infill Script GradientInfill

hereafter the sample code from the script GradientMaster.zip

5axes avatar Feb 17 '20 23:02 5axes

Thanks for the measurements.

Center part, same gradiant infill but with a Gradiant Infill Speed Factor = 50% : 0.47 - 0.73 - 0.26 - 0.74 - 0.5

Don't understand what the first and last values are.

Anyway, my next release will provide a new setting (gradient infill speed scheme) which will let you choose between what it does now (speed is modified where the infill flow is changing) and the scheme you are asking for (constant extrusion rate). Constant extrusion rate is fab as it will produce nicely modulated line widths and generally speeds up the prints for infills that have straight lines. It would probably be death for infills like gyroid as the printer would be in danger of flying apart on the fast sections.

smartavionics avatar Feb 18 '20 10:02 smartavionics

Without a direct drive, The speed reduction must be (in my case) proportionnal to the Flow variation. In my test the width of the line close to the border is smaller than the width at the beginning of the flow increase . That's why I have these values.

Gradient

grad2

5axes avatar Feb 18 '20 10:02 5axes

I still don't understand why a bowden extruder should behave as you are saying. What I think is happening in your case is simply that the extruder/hotend cannot deliver 200% at the normal infill speed. It's nothing to do with the fact that it's a bowden extruder.

smartavionics avatar Feb 18 '20 10:02 smartavionics

Yes you're right the main issue comes from the limitation of this type of extruder to deliver 200% at the normal infill speed, but it's not because it's a bowden extruder. It's because, on my machine with the original extruder, it is not possible to have sufficient precision. This is related to the fact of the extruder is subject to skating (only one driving wheel) and to a direct link to the stepping motor (Estep = 93). So, logically, for a maximum precision of the extrusion, you need a direct drive, and a much more linear dual drive (Estep = 415) as the BMG clone for example on the Ender 3/5.

5axes avatar Feb 18 '20 12:02 5axes

At the end of the day, it's probably a combination of factors that stop the extruder/hotend performing as well as we would like.

Anyway, I am going to make a new build this afternoon that has the choice of speed modification algorithms and, hopefully, that will give you what you want. Stay tuned...

smartavionics avatar Feb 18 '20 12:02 smartavionics

New release now on dropbox 20200218, please give it a go.

smartavionics avatar Feb 18 '20 14:02 smartavionics

As someone as already write : Faster than the light !

5axes avatar Feb 18 '20 14:02 5axes

I think I need a little bit more explanations .

  • None : Ok it's clear the Infill speed is used everywhere

  • On Flow Change : It's the previous behavior , Speed reduction around the Gradient Infill distance area.

  • Fast ? : Inside the gradiant Infill area the speed gradualy change from the Infill speed to a value equal to { Infill Speed + ( Gradient Infill Speed Factor *Infill Speed) } Outside the gradient area Speed = { Infill Speed + ( Gradient Infill Speed Factor *Infill Speed) } . Ie : for 100mm/s 100% -> 200 mm/s ?

  • Slow ? : Outside the gradient area Speed = Infill Speed . In the gradient fill area the speed is gradualy reduce from the Infill Speed to 100% = minimum speed Ie : 100mm/s -> 10 mm/s ?

SpeedChange

5axes avatar Feb 18 '20 17:02 5axes

The fast and slow schemes both modify the print speed so that throughout all of the infill, the extruder will turn at the same speed. So for both schemes, when the flow rate doubles, the speed has to halve, and so on.

The fast scheme uses the normal print speed for normal flow so if that normal infill speed is 100 mm/S you will indeed get 200 mm/S where the flow is 50% and 50 mm/S where the flow is 200%. This is assuming the infill speed factor is 100%. If you modify that the speed changes will be less or more depending on whether you reduce the speed factor or increase it. Note that changing the speed factor from 100% will make the extruder rate change.

The slow scheme uses the normal print speed for the lowest flow and so all other flows will make the print speed reduce. So in your example, with the slow scheme, at 50% flow the speed will be 100 mm/S, at 100% flow the speed will be 50 mm/S and at 200% flow, the speed will be 25 mm/S.

That's the intention.

smartavionics avatar Feb 18 '20 18:02 smartavionics