Using the API to set material settings

(Lewis2e) #1


I am writing a Sketchfab uploader using Python. I have the upload working thanks to the API examples, but I am wondering is it possible to use the API to set material settings?

Specifically, I am looking to change the format of the transparency texture to “Luminance” (it defaults to “Alpha”) and to activate the “Invert Texture” option. Ideally this would be part of the initial upload.

I have been poking around the API documentation for a while now… I can’t see anything that makes this possible. Can I do this via the data dictionary that is passed for upload?

As a disclaimer, I am what you would call a hobbyist and not a professional developer… so please go easy on me! :grinning:

Many thanks

(Klaasnienhuis) #2

Hi @Lewis2e,

The data API doesn’t offer ways to set material properties. Your best bet is to setup the materials in the 3d software the models are built in, or even by manipulating the 3d file itself. E.g. with obj/mtl you could rewrite the mtl file to reflect the material settings you need. It’s nasty business though.

But the settings you describe are very specific to Sketchfab. I suspect there’s no 3d file format which matches the sketchfab settings so closely.

The viewer API does offer methods to change materials, but these changes aren’t “baked in” like the data API does. You need to apply the material settings each time the model is shown. This only works where you have full control over the loading, not on

Sketchfab used to have an API which made it possible to “bake” these material settings into the model, but it has been deprecated recently.

(Lewis2e) #3

Hi @klaasnienhuis

Ah, that’s a bit of a shame. In that case, it’s going to have to be a manual process for anyone using my software.

Oh well, at least I know now. Appreciate the information, thank you.