Back to the Shapespark home page

Auto population of material parameters from fbx


#1

Hi, I’m importing an fbx with over 500 materials. Are there any workarounds to automatically populate the reflection and bump values/bitmap locations?

Would I need to write a script to extract the values from the fbx, overwrite the relevant scene.json values, and copy the textures to the /raw/textures folder?


#2

The only workarounds that we are aware of are for populating a new scene with materials setting from some other scene, as you discussed together with @tim in this forum thread: Quickly re-using models

But this won’t help for a completely new scene with 500 different materials. Do you have some ideas how to map FBX reflections related settings to Shapespark in a portable way? If this is doable, we could extend importer to import such settings.


#3

Are you still thinking about the possibility to add a material library to Shapespark? This would make things much easier. Objects could/must come with a UVW mapping. But Materials could be added or adjusted inside Shapespark.


#4

Hi Jan

I believe the fbx file holds all of the standard material properties including reflection, reflection map, bump values,bump map, opacity, diffuse colour, diffuse map etc. So it should just be a case of reading them and assigning them to the relevant shapespark material properties on import. I’d have to double check though which exact material properties are included in the FBX.

Alternatively, you could create a python or maxscript script which loops through all scene materials in 3ds max, and then writes them out to an intermediatery xml file. Then during import this file could be referenced against to get the correct shapespark material parameters.


#5

I think the need for a material library would be negated by the ability to import all material properties, as it’s probably just as convenient to use the material library in the 3d modelling application.

It would be nice to be able to assign an existing scene material to an object though, as sometimes I notice the wrong material is assigned to an object, and I have to reimport and re-bake the entire scene.


#6

We are currently working on a way of importing additional properties via .json file that could be passed together with a main file (FBX, OBJ, DAE), but we don’t yet have a way to export such properties from 3ds max.


#7

In case all data could be extracted from the fbx file (or the Shapespark exporter file) I agree. But currently you need to assign all maps and settings manually, what is a real timewaster, as you know.


#8

These may be useful:

http://www.scriptspot.com/3ds-max/scripts/mxsjson

And here’s something i’m working on which will show you how to read the properties.

–loops through the nodes connected to MatOrMap (the parameter passed to the function)
fn getSubmapsArray MatOrMap = (

Submaps = #()
submaps_count = getNumSubTexmaps MatOrMap
for i = 1 to submaps_count do(
	SubMap = getSubTexmap MatOrMap i
	if(SubMap != undefined) then
	(
		append Submaps (SubMap)
		
	)


)

return Submaps

)

–gets the map of the current parameter only (diffuse)
fn getSubmat DifMap =
(
c = classof DifMap
format “\n\n\n % \n\n\n\n” c

	submaps = getSubmapsArray(DifMap)
	submapCount = submaps.count
	
	
	print ("there are " + (submaps.count as string) + " nodes connected to the " + c as string +"\n\n\n\n")
	
		
		for sub in submaps do(
			print sub
			
			--check if it's a bitmap and if not repeat
		)
	
	props = getPropNames DifMap
	for prop in getPropNames DifMap do
		(
			--print getProperty PassedMaterial prop
			--format "% value is %\n" prop  (getProperty $PassedMaterial prop)
			--print getProperty prop
			val = getProperty DifMap prop
			 format "the value of % is % \n " prop val
		)
	
		
)

----main function

Sel = selection as array
count = 0
for TheGeo in Sel do
if classof TheGeo.material == Multimaterial then
(
print (“multisub \n”)
for m = 1 to TheGeo.material.numsubs do
(
connectedToMultiMat = TheGeo.material[m]
if classof connectedToMultimat == Subanim do continue
c = classof connectedToMultimat as string
print (" " + c +"\n")
ListPropsAndValues(connectedToMultimat)

	)
	
)
else(
	--gets the full array of maps
	--print (ReadAllMaps(TheGeo.Material))
	
	--gets just the specified map
	
	ListPropsAndValues(TheGeo.Material)
	
)

#9

The recent Shapespark release adds support for importing additional properties via a JSON file. The format of this file is described here: https://github.com/shapespark/shapespark-extras-json

We won’t be able to work on exporting such properties from 3ds Max in the September (we started work on Revit), but if someone would like to work on such exporter we can help with any issues on Shapespark site.


Initial support for importing additional material properties via a JSON file
#10

Brilliant, thanks Jan. This will be a game changer, particularly if there can be an option to update materials from file.