Hello,
I’d like to say a few words about a new command I wrote these last days, namely output_obj.
This basically implements an export feature from G’MIC 3D meshes to the Wavefront .obj file format, which is a text format that many 3D viewers / modelers can import (including Blender, which was my target here).
A few things to know about this new feature:
-
This export feature should work with G’MIC 2.9.0+, and be available after a filter update:
$ gmic update. -
For the user, this means the
.objformat is now accepted when invoking the generic commandoutputin a G’MIC pipeline. So, a typical example of use would be:
$ gmic gmic3d output gmic3d.obj
(here, gmic3d is a G’MIC command that generates a 3D mesh).
I personnally use meshlab for a quick visualization of the generated .obj file:
$ meshlab gmic3d.obj
But, you can import it in Blender as well (with File / Import / Wavefront (.obj)):
-
Before that, G’MIC was only able to export 3D meshes into
.offfiles (Geomview), which is not easy to import into Blender and which does not support texture mapping. So having export to.objis a nice addition. -
.objexport supports face materials, so colors/textures are exported.
Example: Using G’MIC to generate a textured 3D elevation from an input image:
gmic sp colorful,64 b 2 elevation3d 0.1 sp colorful t3d.. . rm. o colorful.obj
and you get this:
- G’MIC, with its script language, is actually quite good at generating 3D procedural objects, from scratch or from image data. Of course, Blender has a lot of modeling options, as well as scriptable procedures to generate objects, but it’s pretty cool to have another way of generating procedural 3D objects. For instance, consider this small G’MIC script:
antoine3d :
R,N=1,18
torus3d 1,0.3
repeat 3,scale
repeat $N
ang={$>*360/$N}
+rotate3d[0] 0,1,0,{90*$>%2} +3d. {4*$R},0,0 rotate3d. 0,0,1,$ang
color={${-math_lib};hsv2rgb([$ang,1,1])}
if {!$scale} color3d. $color else l. split3d +[4] '$color' /[4] 2 a y endl fi
done
rm[0] +3d R*=4
done
It takes a torus, creates a loop of interlaced torii from it, and do this recursively with the new shape obtained.
$ gmic antoine3d o antoine3d.obj
This generates a 1679616-primitives object, that looks like this:
- Another example of procedural generation of 3D object, done by recursively interlacing torii
(I don’t show the G’MIC script here, it’s still a bit dirty
):
- From G’MIC 2.9.5, you will be able to specify an output option
save_materialsthat can take values0=noor1=yes. It allows to not save face material if it’s not wanted (it reduces the generated file size).
Things that have not been done, and limitations:
-
No equivalent import feature of
.objfiles into G’MIC. G’MIC is actually not very good at processing 3D meshes, so it’s not really that useful to have an import function for.objfiles. Not saying it wouldn’t be nice, but the export has more priority (because, on the contrary, G’MIC is quite flexible to generate objects from scratch or from images). -
The export does not support (yet) transparent primitives. It just export them fully opaque. I haven’t found a “standard” way in
.objmaterials to specify a level of opacity, so I gave up for the moment. There are apparently some material properties to set, but this doesn’t seem to be taken into account, both bymeshlabandblender. -
As
.objis basically a non-compressed text format, it produces large files when the 3D object to export is big. I’ve been able to export a 30-millions face object with G’MIC (this requires quite a lot of memory, but it works), as a 1.5 Gb.objfile.meshlabwas able to read it, but not Blender (it tooks all my 32Gb of RAM before starting to swap). More a Blender limitation here, but it’s good to know.
That’s it for now. I hope this will be useful for some people in the future (it will for me, without any doubts).
Cheers,
David.

















