VrayLightMtl Global control Script

Hello All

Has anyone scripted? (or can quickly script!)
A way of changing the multiplier in the vray light material on multiple selected object/materials.

Ideally what would be great is:

I have say 10 objects each with there own vray light material with a different map in the first slot. Then I can say select 5 of the objects and change the multiplier light value in the material all to perhaps 100.

I’m thinking it would be useful for controlling multiple plane objects with self illuminating images on - for use in shop fronts etc.

I have 100 of shops to deal with someone help me !!!

yeah thats a wish of mine too. It would be nice if someone could add support for the vraylight material in the light lister

Yeah that would be the ideal solution!

Anybody?!

If every object has his own unique material then you can “mass-change” their light multiplier the following way:

- Select the objects you want to change their light multiplier
- Run this script from maxcript listener: $.material.multiplier = X
( change X for value you want multiplier to be )

The problem would be if you want to apply different multipliers to objects with the same material…

hope it helps

Ok tried that but got…

Unknown property: “material” in $selection <<

Doh , my bad :roll:

try this code instead:

for o in $ do o.material.multiplier = X

That’s because one of the objects you had selected did not have a material property (like a light/camera, etc)

Run this


objs = getCurrentSelection()

for o in objs do (
     if (isProperty o #material) then (
          if (isProperty o.material #multiplier) then (
               o.material.multiplier = X   -- alternatively, you can multiply it by itself like
               o.material.multiplier = o.material.multiplier * 2
               format "object: %   multiplier changed to: %\n" o.name o.material.multiplier
          )
     )
)

This code will make sure the object you are trying to do that to has a material and a multiplier property first then if it does change it’s value!

Codi you are a legend that works a treat!

Have same issues with yours as before though MoonDoggie

Unknown property: “material” in undefined.

Right all I need now is a nice button and somewhere to stick in the X value!
Any takers?

The other issue of course multi-subs - any easy way to deal with these?

You can give this a go:

-- Mass VRayLightMaterial Multiplier Updater
-- by Codi
Rollout light_mult "Mass Multiplier Updater"
(
	spinner mult_value "Multiplier: " type:#float fieldWidth:50 range:[0,30000,1]
	button apply_mult "Change Multiplier" width:120 align:#center

	on apply_mult pressed do 
	(
		for obj in $ do 
		(
			if (obj.material != undefined) then 
			(
				if (classof obj.material as string == "VRayLightMtl") then 
				(
					obj.material.multiplier = mult_value.value
					format "Object % material multiplier changed to %\n" obj.name mult_value.value
				)
				else 
				(
					if (classof obj.material as string== "Multimaterial") then 
					(
						for i = 1 to obj.material.numsubs do 
						(
							if ( classof obj.material.materialList[i] as string == "VRayLightMtl") then
							(
								obj.material.materialList[i].multiplier = mult_value.value
								format "Object % submaterial % multiplier changed to %\n" (obj.name as string) i mult_value.value
							)
							else (
								format "Object % submaterial % isn't a VRayLightMaterial\n" (obj.name as string) i
							)
						)
					)
					else (
						format "(Object % has no proper material assigned)\n" obj.name
					)
				)
			)
			else
			(
					format "(Object % has no material)\n" obj.name
			)
		)
	)
)

if light_mult_floater != undefined then CloseRolloutFloater light_mult_floater
light_mult_floater = newRolloutFloater "VRayLightMtl Tool" 180 100
addRollout light_mult light_mult_floater

To “install” it you just have to select all the text inside the Code box and drag the selection in your toolbar.

If the script finds a selected object with VrayLightMaterial it changes the multiplier value, and if it finds an object with a Multimaterial it will change the multipliers of any VrayLightMaterial it finds on it (it’s not recursive thoug, doesn’t check multimaterials inside multimaterials)

Hope it’s what you need.

BTW, use at your own risk and better save a copy of your work before runing this script. :wink:

The vraylightmtl will almost be made void soon when Vlado finishes ( if he hasnt already) proper mesh based vraylights. So any mesh can be a vraylight so vraylightmtl will not be used as much anymore.

Thats very interesting. Any idea as to when that feature will be available to us?
Vivek

Well if Vlado releases anything at siggy it might well be included in that :wink:

Codi thanks for the Code it works a treat, I can’t thank you enough for your time!

So these proper mesh based vraylights would mean you could just add a multiplier to an object e.g. a plane and it would become a light!?!

Would this be more advanced than just say increasing the Generate GI of that mesh?

No problem, was needing some scripting practice :wink:

Well the primary difference between a vraylight and a vraylightmtl is that the vraylight is a direct light and vraylightmtl is a GI light, thus alot slower and not as clean to render without high GI settings.

The vray mesh lights will be direct lights like the vray area lights, but just with the advantages of the vraylightmtl being that you can use it on any mesh shape.

Arh OK, thanks for clarifying this.

But in this case surely there will still be a place for the vray light mtl as it will be faster in animations for example when you actually want to save the light in a stored GI solution?

Your able to do that anyway with vraylights.

“store with IR map”

And vraylightmtl will almost always be slower to get clean results than using just vraylights anyway.

I’m guessing that you will be able to store the light coming from the object with the irradiance map, as you can with current Vray lights…

I’ve had a few occasions where I’ve needed to blend a light material with another, so I hope it remains for that purpose.