Chaos Corona Forum

Chaos Corona for 3ds Max => [Max] I need help! => Topic started by: Alex Abarca on 2022-09-01, 05:06:40

Title: Add CoronaRaySwitch to 500 materials
Post by: Alex Abarca on 2022-09-01, 05:06:40
I have a photogrammetry of a city and I would like to add a CoronaRaySwitch in white for Global Illumation slot. Does anyone out there know how to do this on 500 materials?
Title: Re: Add CoronaRaySwitch to 500 materials
Post by: romullus on 2022-09-01, 09:31:56
I think the best way to handle such situation, would be to figure out how to assign different material IDs to different mesh parts and then give them single material with all the textures loaded through Corona multi-map. After that any material adjustments would be a breeze.
Title: Re: Add CoronaRaySwitch to 500 materials
Post by: maru on 2022-09-01, 16:57:30
I think someone with basic maxscript skill could help with this.
Title: Re: Add CoronaRaySwitch to 500 materials
Post by: Alex Abarca on 2022-09-01, 23:44:18
Hi Romulus, that's a lot of work it could take days. There's 500 of these, see attachment.
Title: Re: Add CoronaRaySwitch to 500 materials
Post by: clemens_at on 2022-09-02, 11:35:20
I hope I understood the problem correctly.
try running this:
Code: [Select]
(
global whiteMat = CoronaPhysicalMtl()
global cnt = 0

whiteMat.name ="GI_white"

for obj in geometry where obj.mat != undefined do 
(
raySwMat = CoronaRaySwitchMtl()
raySwMat.giMtl = whiteMat
raySwMat.reflectMtl = obj.mat
raySwMat.refractMtl = obj.mat
raySwMat.directMtl = obj.mat
raySwMat.name = ("RaySwitchMtl" + "_" + obj.name)
obj.mat = raySwMat
cnt+=1
)
print ("materials processed: " + (cnt as string))
)

please do a scene hold before you run it.