Author Topic: Add CoronaRaySwitch to 500 materials  (Read 1224 times)

2022-09-01, 05:06:40

Alex Abarca

  • Active Users
  • **
  • Posts: 422
  • Corona Certified Instructor
    • View Profile
    • Instagram
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?

2022-09-01, 09:31:56
Reply #1

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8843
  • Let's move this topic, shall we?
    • View Profile
    • My Models
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.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2022-09-01, 16:57:30
Reply #2

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 12755
  • Marcin
    • View Profile
I think someone with basic maxscript skill could help with this.
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2022-09-01, 23:44:18
Reply #3

Alex Abarca

  • Active Users
  • **
  • Posts: 422
  • Corona Certified Instructor
    • View Profile
    • Instagram
Hi Romulus, that's a lot of work it could take days. There's 500 of these, see attachment.

2022-09-02, 11:35:20
Reply #4

clemens_at

  • Active Users
  • **
  • Posts: 140
    • View Profile
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.