render One object with hundreds of different textures

Hi does enyone have a script or if it's possible to automate the process of having X object and render it with the files of a given folder. I.e. i need to showcase 100 diferent kinds of fabric applied to a sofa or marble in a kitchen counter etc...

also it'll be great if the output name could be _>texturename>.*

I already considered the renaming everything as a img sequence but that's not a real option because i'll have to shuffle thru a zillion files trying to find the image i want that's why let's say (stickung with the sofa example) sofa_whitefabric.*, sofa_brownleather.* etc would be great instead of sofa_leather01, sofa_fabric02.*

I need help!!

ty

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Graph's picture

How about something like

How about something like this:

(
	local objsToSwitchTextures = selection as array;	--define the objects that will have their textures replaced
 
	local textureFolder = @"C:\Users\Graph\Desktop\Neuer Ordner (2)\";	--define the folder to search for the replacement-textures
 
	local fileType = @"*.jpg";	--define the fileType of the textures to use
 
	local mapSlotName = "DiffuseMap";	--define the material's map slot to assign the new textures to
 
	local printMapSlotNames = true;	--if set to true the material's map slot Names are gonna be printed to the listener
 
	/* ************************ */
	/* ************************ */
	/* ************************ */
 
	fn getMatMapProps mat =
	(
		if mat != undefined AND superClassOf mat == material do
		(
			local str = stringstream ""
			showproperties mat to:str
			str = filterstring (str as string) "\r\n"
 
			local nonCollClasses = #(integer, float, array, arrayparameter, booleanclass, color, material)
 
			str = for prop in str where findString prop "alias" != undefined OR findString prop "map" != undefined collect
			(
				local prop2 = 0
				prop = replace prop 1 (findString prop ".") ""  --remove whiteSpace before prop
				prop = substring prop 1 ((findString prop " ")-1) --cut out only the prop
				local firstLetter = toUpper (substring prop 1 1) --get first letter in uppercase
				prop = replace prop 1 1 firstLetter --replace first letter with uppercase
				if hasProperty mat prop do --check if the generated prop string exists at all
				(
					prop2 = getProperty mat prop --get the value
				)
				if findItem nonCollClasses (classOf prop2) == 0 AND findItem nonCollClasses (superClassOf prop2) == 0 AND prop.count > 6 then prop else dontcollect --sort out and return the valid props to collect
			)
			return str
		)
	)--END getMatMapProps FN
 
	local textureFiles = getFiles (textureFolder + fileType) ;
	local isRndNameSet = rendOutputFilename.count >=5;
	local rendFilename = copy rendOutputFilename;
 
	if objsToSwitchTextures.count > 0 then
	(
		for texture in textureFiles do 
		(
			for obj in objsToSwitchTextures do
			(
				if obj.material != undefined do 
				(
					if printMapSlotNames do
					(
						local matMapProps = getMatMapProps obj.material;
 
						local str = obj.material.name + " | " + (classOf obj.material) as string + "\r\n";
 
						for slot in matMapProps do 
							str += "\t" + slot + "\r\n";
 
						print str;
					)
 
					if isProperty obj.material mapSlotName do
					(
						local tex = bitmaptex fileName:texture;
						setProperty obj.material mapSlotName tex;
					)
				)
			)
 
			if isRndNameSet then
			(
				rendOutputFilename = (getFilenamePath rendFilename) + (getFilenameFile rendFilename) + "_" + (getFilenameFile  texture) + (getFilenameType rendFilename);
			)
			else
			(
				rendOutputFilename = textureFolder + ("batchMatReplace_" + (getFilenameFile  texture)  + ".png");
			)
 
			render outputfile:rendOutputFilename;
		)
	)
	else
	(
		Messagebox "You didn't select any Objects to replace Textures on";
	)
)

Raphael Steves

barigazy's picture

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.