Change map type?

After selecting a bunch of Bitmap Maps in the Slate Material Editor, I would like to convert them to RGB Multiply maps, keeping the original bitmap in the Color 1 slot.

I enabled the Macro Recorder, but the command it spits out refers to each specific material and bitmap path:
meditMaterials[9].diffuseMap = RGB_Multiply MAP1:( Bitmaptexture fileName:"c:\project\scene\texturefile.tga")

How do I make this more generic?

I'm also looking for a quick way to instance a specific bitmap into the Color 2 slot of every RGB Multiply, if possible.

This is for a custom game engine which requires lightmaps to be provided via RGB Multiply.

Thanks for any help!

Eric

Comments

Comment viewing options

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

#2fn part2

Ok lets try like this
If you supplied "lightMap2" argument with filename then map will be added in map2 slot. Also you have "overwrite" option to overwrite map in MAP2 slot if already exsists.

fn convertToMultiply smeViewName: mapSlotName: lightMap2: overwrite: =
(
	if (view = trackViewNodes[#sme][smeViewName]) != null do
	(
		if (smeNodes = view.numsubs) != 0 do
		(
			local lightMap2 = if lightMap2 != unsupplied then BitmapTex filename:lightMap2 else null
			for n = 1 to smeNodes where isKindOf (mat = view[n].reference) Standard do
			(
				if (map = getProperty mat mapSlotName) != null do
				(
					if isKindOf map RGB_Multiply then 
					(
						if overwrite then map.map2 = lightMap2 else (if lightMap2 != null do map.map2 = lightMap2)
					)
					else 
					(
						rgbMulty = RGB_Multiply map1:map
						if overwrite then rgbMulty.map2 = lightMap2 else (if lightMap2 != null do rgbMulty.map2 = lightMap2)
						setProperty mat mapSlotName rgbMulty
					)
				)
			)
		)
	)
)
convertToMultiply smeViewName:"bga" mapSlotName:#diffusemap lightMap2:@"c:\mapfolder\light_map.jpg" overwrite:true

bga

er.cchadw.ck@gmail.com's picture

btw, I'm using Max 2012.

btw, I'm using Max 2012.

3D Game Artist - http://ericchadwick.com
Admin for the Polycount wiki - http://wiki.polycount.com

barigazy's picture

...

I wil separate this solution in two functions:

#1 first function will helps you to fill new SME view with materials of selected objects by filtering only standard materijal.
This way you can operate only on materials in specified SME View.
You can delete unwanted materijal or maps or even add some new before you assigne RGB_Multiply map

#2 With second function you will be able to:
-- assigne RGB_Multiply map in specified map slot
-- add previous map in MAP1 slot of RGB_Multiply
-- add MAP1 to MAP2 slot as instance

bga

barigazy's picture

#1 fn

Select some scene objects and run this fn
fn arguments:
objs - array of objects (selection)
newViewName - name of new SME View which will be created

fn selectionStdMatsToSME objs newViewName: = if objs.count != 0 do
(
	local objsStdMats = #()
	for o in objs where o.mat != null do
	(
		if isKindOf o.mat Standard then append objsStdMats o.mat else
		(
			join objsStdMats (getClassInstances Standard target:o.mat)
		)
	)
	if objsStdMats.count != 0 do
	(
		local newSMEView = sme.GetView (sme.CreateView newViewName)
		for m = 1 to objsStdMats.count do newSMEView.CreateNode objsStdMats[m] [(m-1)*500,0]
	)
)
selectionStdMatsToSME selection newViewName:"bga"

bga

Comment viewing options

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