Can I export custom attribute textures using MaxScript?

I am trying to export custom attributes textures using the babylon.js exporter for 3DS max, but
I bumped into an issue when trying to export the textureMap from custom attributes, the path of the textures gets exported successfully within the gltf in the extras node, but the texture itself is not exported to the textures export location (nor anywhere else).
The exporter simply ignores it.

According to the documentation:
" Texture : The texture is fully exported, including its bitmap. However, the Babylon loader doesn’t interprete the data as a BABYLON.Texture. They are instead row data that can be read or parsed after import."

Here is my simplified material setup, the base color map gets exported, but not the lightmap:

Thank you for the help!

adding @Guillaume_Pelletier one of the great mind behind the exporters :slight_smile:

In theory, Texture bitmap are only exported if type of “texturemap”.
Could you share the definition of your webMaterialAttr, and export log ??
Regards

1 Like

Thanks for the super fast replies guys! Also, Guillaume, incredible job on the exporter, it saves me so much time.

I create the custom attributes with a maxscript I wrote, here: add_attributes_threejs.ms - Google Drive

The final goal is to have my three.js gltf importer read the custom attributes and assign them where they belong.

As far as I know, the custom attribute type that I created is of textureMap type, here is the meaningful part in my maxscript so you can see the type (I am aware this is not a forum to help with maxscripts, this is just to give context :slight_smile: :

webMaterialAttrCA = attributes webMaterialAttr(
	parameters main rollout:params(
		lightMap type:#textureMap ui:lightMap
		lightMapIntensity type:#float ui: lightMapIntensity default: 1.0
		
		aoMapIntensity type:#float ui: aoMapIntensity default: 1.0
		
		opacity type:#float ui: opacity default: 1.0
		transparent type:#boolean ui: transparent default: false
		alphaMap type:#textureMap ui:alphaMap
		
		emissiveMap type:#textureMap ui:emissiveMap
		emissiveIntensity type:#float ui: opacity default: 1.0
		)
		
	rollout params "parameters"(
		mapButton lightMap type:#textureMap
		mapButton lightMapIntensity type:#float
		
		mapButton aoMapIntensity type:#float
		
		mapButton opacity type:#float
		mapButton transparent type:#boolean
		mapButton alphaMap type:#textureMap
		
		mapButton emissiveMap type:#textureMap
		mapButton emissiveIntensity type:#float
		)
	)

Here is the log for a test scene:


Thanks!

Just mimic your case and reproduce. Have to check why it’s did not export the bitmap itself.
Update : had a look into the code and NO lines are taking care of exporting the extra texture bitmap.
@bghgary because it is not implemented, but documented, and because I do not know the history behind. Do we update the code or the documentation ??

1 Like

I’m okay with either, but it sounds like @j.franc wants this feature, so we should try to do it. Is it a complicated change?

If this is a burden don’t worry about me! I have not seen much interest in this feature in the forums anyways :smiley:
If you can give me some quick guidance in terms of what part of the exporter’s code I need to edit to implement this feature, I can try, and if it works I can send it over so you can publish it.

I’ll let @Guillaume_Pelletier answer this one. :slight_smile:

2 Likes

Hey guy’s,
This is not big at all, but we might decide on some way how to deal with GLB, which is suppose to encompass all the files. I do not know if it’s reasonable, nor standard, to add some additional file into the GLB (which is basically a zip archive).
Otherwise we might setup a call to explain how to deal with the exporter code and focus on the part of interest. But honestly, It might take me more time than doing it by myself. :upside_down_face: But happy to share some knowledge if @j.franc want to ramp-up.

1 Like

Okay, I do not wish to waste your time, so if you update the code I will look at the code updates once they go live so that I can learn how you did it, and hopefully, with time I’d love to contribute to this exporter since I use it all the time!
Thanks a lot!

1 Like

It is possible to add additional chunks in a GLB, but it has to be with an extension. I haven’t seen anyone do this yet.

@j.franc You will not waste my time at all, happy to share with new contributor. Just let me know when you wish to do it.

@bghgary could you point me to the documentation it say that. i do not find any usefull info into the spec

I was referring to this, but I’m not sure this is what we should do. I just re-read the post and I didn’t understand what we were tying to do before. If we want to export something that can be read by a glTF loader, it must be some kind of extension or at least documented in some way. The first step is to create a glTF extension that adds the new textures and how they should be interpreted. Without this, the exported data will be useless since no loader will be able to read it.

Right, this is why i asked. I beleive the use case here is to support a inhouse non norminative extension to allow ThreeJs to load specific data.
I do not know how they achieve that and it sound a very bad pratice.
What I suggest is to export the texture data to gltf, but not glb. As the underlying code let think, the extra attribute capability of the exporter was at the begining dedicated to Babylon format, not GLTF.

I am available tomorrow and Friday during the morning CET time :slight_smile:
How should we do it? Is there a private way to share our contact info?

It would make sense for it to be exported only in GLTF and not in GLB, it could be a good idea to include a warning in the log in case a user tries to export a custom attribute texture to a GLB.

@j.franc you could also fork the project which might be easier to your needs ?

1 Like

If there is a custom glTF extension and it uses the typical buffer way to reference external data, then exporting to a GLB will not be an issue. It will just be included in the main BIN chunk of the GLB.