Advice optimizing render for large object

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Advice optimizing render for large object

stuartlynn
This post has NOT been accepted by the mailing list yet.
Hi I am looking for some advice on how to optimize rendering on OpenSCAD. I am using geodata to produce a model of the US with counties heights sized by some associated value. Pulling the data from a database and generating the scad file using a python script.

It takes a really long time to render (I actually haven't see it complete yet) and I was wondering if I am missing some optimisation tricks. In particular the geometries for each county shouldn't overlap at but I worry that SCAD is trying to compute unions assuming that they do.

Would really appreciate any advice.

The scad file can be grabbed here : https://github.com/stuartlynn/data_sculpture/blob/master/us_model2.scad

Thanks

Stuart
Reply | Threaded
Open this post in threaded view
|

Re: Advice optimizing render for large object

MichaelAtOz
Administrator
stuartlynn wrote
Hi I am looking for some advice on how to optimize rendering on OpenSCAD. I am using geodata to produce a model of the US with counties heights sized by some associated value. Pulling the data from a database and generating the scad file using a python script.

It takes a really long time to render (I actually haven't see it complete yet) and I was wondering if I am missing some optimisation tricks. In particular the geometries for each county shouldn't overlap at but I worry that SCAD is trying to compute unions assuming that they do.

Would really appreciate any advice.

The scad file can be grabbed here : https://github.com/stuartlynn/data_sculpture/blob/master/us_model2.scad

Thanks

Stuart
Unfortunately, ATM OpenSCAD does a top level union of all objects.
There is a change in the system to stop that, but I doubt it will be any time soon.

As you basically do many render() linear_extrude()  polygon(); there is little to optimise.

It may be worth trying the development snapshot, It will often be more efficient than the official release, but not by huge amounts.

BTW, I have had renders of over 24hrs on complex things.
Admin - email* me if you need anything, or if I've done something stupid...
* click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.
Reply | Threaded
Open this post in threaded view
|

Re: Advice optimizing render for large object

Parkinbot
In reply to this post by stuartlynn
A union including about 3200 shapes will be very slow. OpenSCAD does not seem to use any optimization for non-intersection arrangements. I did some testing on that, and results were discouraging.

I just did some fast test also for your code, using the first 200 of your polygons and measured how long F6 will take. It took about 80s, which means, that with suspected O(n²) full rendering will take about 6h.
BTW it is not worth investing this time, because I got (as expected):

WARNING: Object may not be a valid 2-manifold and may need repair!

This is because of numeric problems with shapes having closely adjacent faces, not being matched exactly.

Don't know how good your programming is. In cases like this, you always have the option to compose the full shape on your own by use of polyhedron. This means, you have to either retrieve or calculate neighborhood relations first to be able to do the facing.
I don't see more land with current OpenSCAD. What about using Blender?

Reply | Threaded
Open this post in threaded view
|

Re: Advice optimizing render for large object

MichaelAtOz
Administrator
In reply to this post by stuartlynn
It took 2 hours, 32 minutes, 11 seconds on my 2.5GHz system. But got the errors below.
The exported STL had lots of holes and degenerate faces.


Compiling design (CSG Tree generation)...
Rendering Polygon Mesh using CGAL...
ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: e->incident_sface() != SFace_const_handle() File: /opt/mxe/usr/x86_64-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h Line: 326
Geometries in cache: 9676
Geometry cache size in bytes: 38935640
CGAL Polyhedrons in cache: 13
CGAL cache size in bytes: 316064560
Total rendering time: 2 hours, 32 minutes, 11 seconds
   Top level object is a 3D object:
   Simple:         no
   Vertices:   112591
   Halfedges:  348212
   Edges:      174106
   Halffacets: 105486
   Facets:      52743
   Volumes:        20
WARNING: Object may not be a valid 2-manifold and may need repair!
Rendering finished.
Admin - email* me if you need anything, or if I've done something stupid...
* click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.
Reply | Threaded
Open this post in threaded view
|

Re: Advice optimizing render for large object

Parkinbot
MichaelAtOz wrote
It took 2 hours, 32 minutes, 11 seconds on my 2.5GHz system. But got the errors below.
As I read it, it took this time until an error was encounterd and the task got dropped.
Reply | Threaded
Open this post in threaded view
|

Re: Advice optimizing render for large object

stuartlynn
Thanks everyone! That was such a fast and helpful approach. Ok so it sounds like this might be a bit of a dead end. My next plan was to try and construct the entire model in one go but I might try a few alternatives first.

Thanks again

Reply | Threaded
Open this post in threaded view
|

Re: Advice optimizing render for large object

MichaelAtOz
Administrator
In reply to this post by Parkinbot
Parkinbot wrote
MichaelAtOz wrote
It took 2 hours, 32 minutes, 11 seconds on my 2.5GHz system. But got the errors below.
As I read it, it took this time until an error was encounterd and the task got dropped.
No, I don't think so, a complete looking STL was exported.
Admin - email* me if you need anything, or if I've done something stupid...
* click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.