OpenSCAD 3D rendering just got an order of magnitude faster
ochafik.com
ochafik.com
I recently built a printer and started to print things. OpenSCAD was the first software I reached because I’m developer and writing code felt natural for me. But it took so much time and result was kind of hard to understand and change.
Then I moved to FreeCAD, learned about parametric modelling and it was like the whole other world. I was like 10x more productive compared to OpenSCAD and result was easy to change and adapt.
Then I moved to Fusion and from that point I think that I’ve found a sweet spot, Fusion is similar to FreeCAD, but feels much more polished.
I suppose there's no accounting for taste.
Another example of OpenSCAD’s limitations is the render time for parts produced by boolean operations which this change purportedly helps a lot with. But there is also still not a guarantee that the output of those boolean operations is actually a manifold object. Slicers these days are actually quite good at repairing geometry but even with a moderately complex part produced by boolean operations (in my case it was often one that required subtraction of cylinders across multiple pieces of an object) I found OpenSCAD’s output to produce some bizarre issues with geometry that even the slicer could not repair very well.
I too like OpenSCAD the best and often find myself more productive in it than other pieces of software, especially for simple models. But for complex models it can’t really hold up to the more traditional parametric modeling software (yet)
For me the main limitation in OpenSCAD is the UI: distance labels along the XYZ axes are unreadable when they overlap with a surface, transparency only works with one object at a time. Also I'd love highlighted edges in the preview & split view, it would make alignment of parts so much easier.
Still I'm so much more productive in it than e.g. FreeCAD because I have most of what I need memorized and the rest can be looked up on the one-page cheatsheet.
FreeCAD->OpenSCAD->Fusion->back to OpenSCAD.
Some tasks are extremely easy in OpenSCAD. Fusion is not that hard either, but it is a commercial tool with a free-ish version where they keep your designs hostage. It doesn't run on Linux which makes life hard for multi platform folks. Also, in past I have had issues with STL generated by Fusion.
OpenSCAD is not perfect though, for example is missing important functions such as alignment and assembly
One thing Autodesk is truly infamous for industry-wide is being the utter worst when it comes to file formats.
They make their file format unreadable by anything other than they products by design.
And even within their own product line, it sometimes doesn't work.
So I'll ask you this: what can you do with your f3d file?
Can you import it into blender to render it with a proper rendering engine?
Can you open it with a text editor and change things in it?
Can you convert your model to a format that's readable by other tools?
Can fusion import models created by other tools?
B-rep solid export (STEP) is also very much a thing, you can exchange solid models between Fusion, SOLIDworks, FreeCAD, etc. (and import them from PCB design software and so on)
But this is just baked geometry of course. It's not parametric. There is no standard for parametric models, there is no way to exchange them between different programs.
Vector drawing software faces a similar problem. There's some agreed primitives but often you just get bezier soup.
This is apologism.
If their parametric export format was documented readable ascii text, there would be an entire ecosystem of 3rd party tool taking care of connecting it to other things.
Even better, if there was a push from them to design a standard for this, this would benefit the entire CAD/CAM/manufacturing industry.
But AutoDesk's mindset is the walled garden / captive audience business model.
The fact that creating open standards around their file format would actually benefit their business is simply something that's completely impossible to understand at the corporate culture level.
While that is true, the fact remains that there is no industry standard file format for exchanging parametric CAD models.
Everything is proprietary. I.e. if you export in something you can import elsewhere you need to 'bake' parameters into geometry.
This is not a problem Autodesk created.
And while it may be true that it is also not in their best interest to solve it this is not a good excuse to bash them over adding yet another proprietary parametric format to the list for their flavor of such modeler.
As for me, [proprietary 3D CAD]-> SolveSpace, since 2013.[0]
99% of the time I don't have to deal with that, but that 1% is pretty annoying.
It might be best to think of it as a platypus: An interesting element of the ecosystem, but disappointing if you need a duck.
I personally like the code based system, even when it's "harder" simply because it's easy to plop this into version control.
Alternative viewpoint:
1) It depends on the kind of object you want to model: for simple, geometric shapes, OpenSCAD is by far the best choice. Unless you don't know how to code, in which case it's unusable.
2) When you start to need chamfers and fillets, OpenSCAD simply doesn't work and Fusion is by far the superior solution. Also, if your model starts to become really complex (lots of boolean), OpenSCAD becomes very slow and eventually unusable, even with the change described by the OP.
3) If you need to model organic shapes neither freecad, fusion or OpenSCAD are unusable. Blender is way better for this use case.
4) If you are a programmer and enjoy building truly parametric models, as in: models that you can build with scripts and Makefiles, then neither freecad nor fusion are a fit. Cadquery is slowly getting to the sweet spot OpenScad occupies, but it's not there yet.
5) Fusion is proprietary, closed-source and costs money. Worse, you are basically at the mercy of the vendor. In particular, it's a complete black box: there is exactly zero guarantees that your carefully crafted model will still work 10 years down the road.
6) Freecad's UI is basically a nightmare and the CAD engine (the terminolgy in the CAD world for some reason it is called the "kernel") is the same that cadquery uses, and it's an old and clunky NURBS engine called OpenCascade (if I'm not mistaken). It is definitely not up to par with Fusion's engine.
7) Fusion is lousy at talking to the rest of the ecosystem. Proprietary and opaque file format that no other product outside of the AutoDesk ecosystem can read, lousy at reading things created with other softwares.
True. Well, it is usable, you can model a whole 3D printer or a (BIM) house or whatever in FreeCAD, people have done big projects with it. But OpenCASCADE really likes to give up (or even crash) on fillets >_<
Exp: https://www.thingiverse.com/thing:2029895/files
Broom holder. You can't share an STL that will fit every possible broom diameter. But what you can do is programmatically generate one, and let the users change the variables.
That's what parametric modeling do: you have a history of what you did, and traveling back in time to change something like a diameter is trivial.
Also, it's extremely reassuring to have a description of your model that wasn't generated by a program. In earlier versions of FreeCAD, my model would often not be saved correctly and be totally broken when I opened it again. FreeCAD also crashed randomly on me quite often. In contrast, all you need for editing .scad files is a text editor, and that probably won't crash that often. :)
That’s good to know. Though the fact that they’re zipped probably means they are not meant for humans to read anyway. Also, I don’t think GitHub or GitLab supports custom diff tools right now, and you would need that to do actual code reviews.
* Fasteners (screws, nuts, etc.) * Gears, sprockets, etc. * Computational art
99% of the time you want real parametric CAD (Solidworks etc.). Nobody is going to design a motorbike or a door handle or a vice with OpenSCAD.
It is really a product of open source 3d printers who were seeking a way to describe complex 3d objects, reliably version them, and then spread them around the internet.
It's a cool idea, but it's toolchain has always been sub par. It is my understanding that most of the people working on it are more concerned with getting it good enough, and the bulk of their development energy on 3d printing slicing engines. But I wouldn't want to use OpenSCAD to do any traditional design work or drafting, or really even to design any object that will have to be made with subtractive manufacturing. It's a happy medium that FreeCAD has an OpenSCAD workbench - that way you can do the complicated stuff directly in OpenSCAD for 3D printed parts, and then include them in your FreeCAD assemblies.
OpenSCAD and https://github.com/nophead/NopSCADlib is a winning combo.
> And threadlib[1]
And dotSCAD[2]
So, OpenSCAD user needs to install a lot of extra libs[3] to be productive;)
[0] https://github.com/revarbat/BOSL2
[1] https://github.com/adrianschlatter/threadlib
dotSCAD looks dope! I hadn't heard of it, but now I know what I'll be playing with next time I spin up my 3D printer.
I would also love for it to have a variable that rounds off corners to some diameter on the cubes, cylinders, and even polyhedrons. It's possible to round off corners using the intersection operator but it is a lot of work and something that I do in almost everything I build. Nobody likes unnecessary sharp corners.
https://hackaday.com/2018/02/13/openscad-tieing-it-together-...
True, but they are usable for the use case described (create a rounded cube by hull-ing 8 small spheres or 4 small cyclinders).
But with ADHD tendencies, the rendering time of OpenSCAD often had me getting distracted and forgetting to finish whatever I was doing for a while.
This is very exciting! Great work, OpenSCAD team.
I have good luck with Blender... much more then with Freecad... haven't tried OpenSCAD though...
1) Blender is a general purpose 3D tool, and many things that you need for CAD aren't there. Fillets, Chamfers and a robust boolean engine are missing. Also, when you do things in Blender, everything is geared towards how it will look, not towards making sure that things fit each other precisely. For example, getting blender to place an object 3.4mm off the face of a rotated cube along the normal of that face and rotated 33 degrees around that normal is possible, but really not easy.
2) It can be programmed via python, but it isn't the core use case and for programming 3D models using blender, a) the learning curve is very steep b) the resulting code is very verbose because the API wasn't really designed for this use case. c) there is almost no documentation and very little examples of parametric modeling using the blender python API available on the internets.
3) the boolean engine in blender is fast, but it is far less robust than the one in openscad (CGAL-based) and will often simply refuse to produce a model for reasons that are entirely obscure.
4) Even with the newer geometry node engine, Blender is basically centered around a destructive workflow (early steps in the construction of a model can only be changed via undo/redo), and building paramatric models is really not easy unless you get down to the python API.
5. I write my own blender plugins quite often, and they break with my next `git pull`. Blender moves fast and breaks things ;)
I do python professionally and gamedev 3D/VR stuff as a side piece. I spent 5 hours in blender tonight trying to bake an alpha channel. Something I’ve done before.
It’s a nightmare to maintain a blender plugin. Because (as you point out) blender is opensource clay, not a surgical scalpel. OpenSCAD is a precision knife.
But of course using a mesh modeling engine for CAD is not the best idea. You generally do want to work in B-rep, if not for precision then for exchange reasons (e.g. export electronic component models as STEP to add to PCB software, import a whole board STEP model from PCB software to build a case for the board)
Are they though?
E.g. if the determinant of some matrix becomes too close to zero, switch to exact arithmetic.
Implementing robust boolean operations on polyhedral geometry is and has been known for quite a while to be very hard if you do not have arbitrary precision math, or at the very least some sort of interval arithmetic that kind winds back a calculation and increases the precision up to the point where an unambiguous decision can be made about the sign of an expression.
Here's an example: create a sphere, tesselate it to - say - a million triangle (not much these days), make a rotated copy of the original by 0.01 degrees and intersect with the original. I guarantee you the resulting calculation will either crash your floating point based implementation or it'll produce a model that will be non manifold.
A useful test is to model a bolt. Make a cylinder. Make a 2D cutting tool that has one thread profile. Extrude the thread profile along a spiral. Subtract that from the cylinder. Now you have a threaded rod. Now make a 2D hexagon for the bolt head. Extrude. Union with cylinder. Now chamfer all edges of the bolt head. Also chamfer the end of the bolt.
Now take a close look at where the threads meet the bolt head, and where the threads meet the chamfer. If those are all correct, then you have a usable CSG CAD system for machined parts. Inventor started getting that right around 2012.
Admittedly, you don't usually model threads at that level of detail. Inventor has "cosmetic threads", which are just textures, which is what you use for ordinary bolts. This is mostly an exercise for CAD operators. It's like whiteboarding for programmers. You sit the applicant down at a workstation, hand them a bolt and calipers, and say "model this". Sometimes you do need that kind of detail, because you're going to have a machine tool machine the thing.
Inventor has pro features such as "would you like a finite element analysis of the weak points in that", and "Warning - gear tooth counts are not relatively prime and may result in uneven wear".
Those things needing (to be careful) arbitrary precision can sometimes be truncated back to 64 bit doubles, as long as necessary invariants are maintained.
A simple example: suppose you have a shape at the origin, that is designed for careful CNC, so maybe 1/10,000th of an inch or maybe even 1/100,000th of an inch accuracy. Suppose 1/10,000th accuracy is, say, ~14 bits of mantissa, then making the part 16 inches long is another 4 bits. We're up to 28 bits. Now suppose you do an operation, like intersection with another such part, or a fillet or rounding, whose computation merely needs to square numbers. Now you need 28*28 bits, anf you overflow the mantissa. Or move the part out to coordinate 64, uses another 6 bits. And god forbid you hit an algorithm that needs to cube numbers, which triples the number of bits you need in order to retain accuracy needed for the final part to meet tolerances.
It gets troublesome quite quickly.
Above was only position. Now build in Bezier surfaces, or better yet, NURBs so you can do true conics as well as crazy freeform surfaces.
Now compute the intersection of such objects. These intersections require very high degree polynomial representations. Now repeat.
If you quantize points on the intersection curves too much, you'll get all sorts of pathologies, things doubling back, near singularities ..
The way to deal with this flawlessly is to allow whatever precision is needed to prove necessary constraints are met.
A good lib would use each representation as needed: double, libdouble, liquid, liboct, etc. as needed, and eventually arbitrary precision. I've written several systems that do such over my career. It's a cool space
A nice simple place to try this is to make an arbitrary precision Mandelbrot zoomer that switches underlying types as needed for precision.
It's much more fun to make these work on various AVX flavors, or on GPUs. All are doable.
Bearer of bad news here: I've tried this on a model I had lying around, and ... :-\
box.scad is an old, somewhat complicated electronics enclosure where I experimented with building a non-trivial, fully filleted model with scad.
The model has quite a lot of "natural" booleans (eg holes and such), but also, the fillets are implemented either:
- with a ton of procedurally generated minkowski sums (offsets) combined with booleans.
- with hulls of far-apart spheres
TL;DR: as far as I can tell, fast-csg does not render the model properly :-(
speedup with fast-csg is decent (~5x) only at very low $fn
speedup is entirely underwhelming when $fn gets high
minkowski offsets likely gobble up the bulk of the render time
This also made it very clear that render times aren't linear at all when $fn grows, and this is both true for traditional openscad and fast-csg.Your mileage may get much better if you steer clear of hulls and minkowski sums, and to be fair, I'd need to run a benchmark with no minkski in it.
Benchmark:
old : time openscad -o z.stl box.scad
new : time openscad-nightly --enable fast-csg -o z.stl box.scad
$fn = 5
old = 6.8 sec
new --enable fast-csg = 1.2 sec
x 5.6
$fn = 10
old = 15 sec
new --enable fast-csg = 3 sec
x 5
$fn = 20
old = 67 sec
new --enable fast-csg = 25 sec
x 2.68
$fn = 40
old = 427 sec
new --enable fast-csg = 369 sec
x 1.15What I’m asking is how do the output and performance differ.
You should play around with it to find out. You will be disappointed though, because you're looking to compare a fish with a horse in a race.
There are some places where the point-and-click UI makes sense. For example I like how I can layout the parts on a simulated baseplate with Cura. But there is really no design or thought into that process. Just slap them onto the plate in a way they won't overlap and I'm done.
However I prefer to use the python scripting API in blender.
Either way it is important to point out that OpenSCAD is more for CSG, while blender is for surface modeling. If you are intending to 3D print your models you will ultimately need to get them in a mesh format so I see no problem using a mesh format from the get go.
I've used a wide range of CAD software over the years, and they're often a clunky mess. OpenSCAD is something I'd like to explore but if I could achieve much the same outcome with Blender, which I know quite well then it may not be worth the effort.
I've used the python API a lot and now I'm getting excited by Geometry Nodes.
From a non-technical perspective I was able to do (reasonably?) complex part design with almost no prior experience in about 3 days of work. This included debugging the model code, introducing various enhancements after realizing I would need them, completely changing the design a couple times after running real-world measurements.
In blender, based upon past experience, I would have spent a week just figuring out how to do all that. Sure there is code and the like, but how easy is it to hook that up to your external editor? How well does the refresh cycle work? (Hint - in OpenSCAD it just worked and I could use my editor of choice on a second screen monitor).
So the non-technical performance is pretty great. The technical "how fast does it go" - I'm not sure but I suspect Blender uses GMP under the hood as well, at that point it is somewhat arbitrary. I dont think the tooling is geared towards doing model designs, I get the impression FreeCAD is more the SolidWorks contender - which is next on my list to evaluate. Thanks for the tip about geometry nodes though!
Specifically these are hard to do with nodes:
- for loops
- if <complex condition is met> do this else do that, where <complex condition> requires to look at the evaluated output of an upstream node.
- recursion
- global variables
- self introspection
- accessing things by name rather than painfully dragging noodles from one point to the next
In general, node-based interfaces (Houdini, Blender, etc...) get absolutely impenetrable once your project gets very large.They all have that subtle APL-like write-once-read-never feel.
In my experience large code bases are way easier to navigate, refactor, change, test, debug than large node-based models, even when you take care of organizing your node hierarchically.
> OpenSCAD-2022.02.09.ai10824-2022.02.09.ai10824-x86_64.AppImage
BTW, As for "10x performance" — just tried, but not see speedup.[1]
[0] https://twitter.com/app4soft/status/1491575600439508992
[1] https://twitter.com/Torsten_Paul/status/1491712810916757508