shader manipulator

shader manipulator

Anonymous
Not applicable
551 Views
10 Replies
Message 1 of 11

shader manipulator

Anonymous
Not applicable
I'm looking for a script to go through my scene select all the shaders and make sure the self illumination check box is unchecked and the ambient color is set to the default gray color and locked with the diffuse. it seems every shader that comes from Maya into Max has the self illumination check box checked and the ambiance color set to black. This creates a ton of work for me to go through each one and change it back.
0 Likes
552 Views
10 Replies
Replies (10)
Message 2 of 11

stigatle
Enthusiast
Enthusiast



for m in sceneMaterials do
(
m.useSelfIllumColor = off
m.ambient = color 150 150 150
m.adLock = on
)

0 Likes
Message 3 of 11

Anonymous
Not applicable
hedphelym, you're not guaranteed that every material has those properties. You have to test for them first or you'll get an error. The slowest, but most general would look like:


for m in sceneMaterials do (
if isProperty m #useSelfIllumColor then
m.useSelfIllumColor = off
if isProperty m #ambient then
m.ambient = color 150 150 150
if isProperty m #adLock then
m.adLock = on
)

You could optimize this if you know that, for example, every material with a #useSelfIllumnColor has an #ambient property, but if you don't have bazillions of materials, the above should work fine.
0 Likes
Message 4 of 11

Anonymous
Not applicable
thank you so much I really appreciate it. this will help out immensely.
0 Likes
Message 5 of 11

Anonymous
Not applicable
Well i was able to give this script a try and it doesn't seem to work. It says "OK" in the listener but nothing none of the material properties are changing. does it matter what kind of matereal I'm using the script on?
0 Likes
Message 6 of 11

Anonymous
Not applicable
The above code wouldn't care what material type it is, no. It simply tests if the properties exist and if so, changes their values.

Are you using Multi/Sub-Object materials in your scene? If so, the above code would not work. You would need something like this instead (untested code coming):

for m in sceneMaterials do (
if (classof m == Multimaterial) then ( -- It's a multi-sub, so loop thru submaterials
for s in m.materialList do (
if isProperty s #useSelfIllumColor then
s.useSelfIllumColor = off
if isProperty s #ambient then
s.ambient = color 150 150 150
if isProperty s #adLock then
s.adLock = on
)
) else ( -- Not a multi-sub
if isProperty m #useSelfIllumColor then
m.useSelfIllumColor = off
if isProperty m #ambient then
m.ambient = color 150 150 150
if isProperty m #adLock then
m.adLock = on
)
)


Truthfully this isn't even completely bulletproof. You can have nested Multi/Sub materials, and would need something recursive to handle that. Although I don't think I've ever seen someone intentionally use nested Multi/Subs. 🙂
0 Likes
Message 7 of 11

Anonymous
Not applicable
the majority of the materials in use are multi sub materials and composite materials although we don't have nested multi sub materials because that would be redundant this script still don't seem to be doing anything i ran this and also get the "OK" but nothing changes. I really appreciate everyone looking into this thanks you
0 Likes
Message 8 of 11

Anonymous
Not applicable
    fn fa_array_toate_standardmaterial_din_scena =
(
bit_tex_array = #()
bit_tex_array = GetClassInstances StandardMaterial
multi = GetClassInstances MultiMaterial
for m = 1 to m = multi.Count do
(
for mi in multi do
(
append bit_tex_array mi
)
)
bit_iesire = #()
for ms = 1 to bit_tex_array.Count do
(
if ((classof bit_tex_array) == StandardMaterial) do
(
append bit_iesire bit_tex_array
)
)
return bit_iesire
)


fn curata =
(
bit_scena = fa_array_toate_standardmaterial_din_scena()

for m = 1 to bit_scena.Count do
(
print bit_scena
if isProperty bit_scena #useSelfIllumColor then
bit_scena.useSelfIllumColor = false
if isProperty bit_scena #adTextureLock then
bit_scena.adTextureLock = true
if isProperty bit_scena #diffuse then
bit_scena.diffuse = (color 149.94 149.94 149.94)

)
)

curata()
0 Likes
Message 9 of 11

Anonymous
Not applicable
Ok Kikialex you came close i probably didn't explain what i needed very well so here is a picture of what I'm looking for. again thank you very much

0 Likes
Message 10 of 11

Anonymous
Not applicable
fn fa_array_toate_standardmaterial_din_scena =
(
bit_tex_array = #()
bit_tex_array = GetClassInstances StandardMaterial
multi = GetClassInstances MultiMaterial
for m = 1 to m = multi.Count do
(
for mi in multi do
(
append bit_tex_array mi
)
)
bit_iesire = #()
for ms = 1 to bit_tex_array.Count do
(
if ((classof bit_tex_array) == StandardMaterial) do
(
append bit_iesire bit_tex_array
)
)
return bit_iesire
)


fn curata =
(
bit_scena = fa_array_toate_standardmaterial_din_scena()

for m = 1 to bit_scena.Count do
(
print bit_scena
if isProperty bit_scena #useSelfIllumColor then
bit_scena.useSelfIllumColor = false
if isProperty bit_scena #adLock then
bit_scena.adLock = true
if isProperty bit_scena #diffuse then
bit_scena.diffuse = (color 149.94 149.94 149.94)

)
)

curata()
0 Likes
Message 11 of 11

Anonymous
Not applicable
thanks! that did it. I really appreciate it
0 Likes