Announcement

Collapse
No announcement yet.

Convert materials in scene to VrayOverrideMtl

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Convert materials in scene to VrayOverrideMtl

    Hi all,

    I'm trying to create a simple script, but I'm no scripter, so really hitting a dead end right now.

    What I'm trying to do is convert all the materials in a scene to VrayOverrideMtls, but keep the existing material in the basemtl slot. I then need to add a blank black vraymtl to the reflection slot.

    I think the general concept should be something like this -

    Code:
     [TABLE="align: center, border: 0, cellpadding: 6, cellspacing: 1"]
    [TR]
    [TD]for mat in scenematerials do
    			(
    			mat.material = VRayOverrideMtl basemtl:( mat.material) reflectMtl:(VRayMtl Diffuse = color 0 0 0)
    			)[/TD]
     		[/TR]
    [/TABLE]
    However when doing something like mat.material = VRayOverrideMtl, it discards the existing material, so I need a way to make the existing material move to the basemtl slot.

    Does anyone have any ideas? Any help would be really appreciated!

    Thanks,
    Dean

  • #2
    Hi
    I'm not expert in maxscript too but I think I can help here
    your problem is that you need to store the current material first before asking max to replace it
    also to make it easier and cleaner I would create a Vrayoverride material with the black material in reflection first then replace it in the next step with the current mat using "replaceInstances"
    finally you can add the temp material to the base of new override

    something like this should work :

    Code:
    for Mat in scenematerials do (
        Tmp=Mat
        Ovr= VRayOverrideMtl reflectMtl: (VRayMtl diffuse:(color 0 0 0) )
        replaceInstances Mat Ovr
        ovr.baseMtl = Mat
    )






    -------------------------------------------------------------
    Simply, I love to put pixels together! Sounds easy right : ))
    Sketchbook-1 /Sketchbook-2 / Behance / Facebook

    Comment


    • #3
      Hi,

      Thank you, I will test it.

      I also had another reply from another forum with a similar way of doing it -

      Code:
      blackMtl = VRayMtl diffuse:(color 0 0 0) name:"Black Reflection Override"
      
       for mtl in scenematerials where not isKindOf mtl VRayOverrideMtl and superclassof mtl == material do (
      
           tmp = mtl
          vrayOverride = VRayOverrideMtl reflectMtl:blackMtl name:(mtl.name + " override")
          replaceInstances mtl vrayOverride
          vrayOverride.baseMtl = tmp  
      )
      Cheers, Dean

      Comment


      • #4
        You are welcome !
        I see it is almost the same =D ... I like what he did before the loop so I would say go with That (Y)
        -------------------------------------------------------------
        Simply, I love to put pixels together! Sounds easy right : ))
        Sketchbook-1 /Sketchbook-2 / Behance / Facebook

        Comment

        Working...
        X