img2scad
Texture map images onto OpenSCAD surfaces, optionally rendering to STL.
Here is a preview of the planetary maps of the solar system found in images/1k/
, converted to OpenSCAD, and then rendered to STL:
These STLs can be downloaded on PrusaPrinters or Thingiverse.
Usage
Run:
./img2scad.kts <jpg folder> <scad folder> <stl folder> <optional: openscad command>
For example:
./img2scad.kts "jpg" "scad" "stl" "flatpak run org.openscad.OpenSCAD"
-
Pick up all images in the
jpg/
folder, generate OpenSCAD polyhedrons based on them, and write them toscad/
.Note: Planetary samples are provided in
images/.../
. Higher resolutions provide more details but are slower and resource intensive. -
Export all OpenSCAD files in the
scad/
folder as STLs tostl/
. This step is optional and only runs because the OpenSCAD command is specified.Note: This step is slow and requires a lot of RAM, e.g., up to 15GB for earth in 1k resolution.
Configuration
Shapes
The code renders onto a sphere, though img2scad.kt
can be adjusted to render onto just about any surface, provided you represent it mathematically. In the source code, an example is provided for a disk.
For any adjustment, review:
scad/model.scad-suffix
: By default, it provides a round base, which might not make sense for non-spherical shapes.scad/*.scad
&scad/*.scad-prefix
: By default, this separation is used to scale each planet diameter bylog2(diameter/1000)
, which you might not want.
Texture
Increase or decrease the intensity of the texture by tweaking the depth
argument of writeScad()
in img2scad.kt
.
Acknowledgements
Texture Mapping OpenScad's processing program is the foundation for the code in this repository.
Sample images of the solar system are provided by Solar System Scope.