--Copyright 2007 Emanuele Lecchi
--you're free to modify this script as you wish, as long as the above lines remain in place,
--and proper credit is given to the original author (me!) in case of public distribution and/or modification
fn fixthemats dodiffuse doreflection diffCoeff reflCoeff isDiffAbs isReflAbs=
(
undo on (
theMats = getclassinstances vraymtl
for i in theMats do
(
if dodiffuse do (
if i.texmap_diffuse != undefined do (
print "Found Diffuse Map"
if (hasproperty i.texmap_diffuse "*Output*") or (hasproperty i.texmap_diffuse "*RGB_Multiplier*") do
(
print "Found map with Output or RGB_Level Parameters"
if isDiffAbs then (
try (i.texmap_diffuse.RGB_Multiplier =diffCoeff ) catch ()
try (i.texmap_diffuse.output.RGB_Level =diffCoeff ) catch ()
try (i.texmap_diffuse.Texture_Output.RGB_Level =diffCoeff ) catch ()
print ("Multiplied the diffuse Texture RGB Output of the material " + i.name + " to " + diffCoeff as string)
) else (
try (i.texmap_diffuse.RGB_Multiplier *=diffCoeff ) catch ()
try (i.texmap_diffuse.output.RGB_Level *=diffCoeff ) catch ()
try (i.texmap_diffuse.Texture_Output.RGB_Level *=diffCoeff ) catch ()
print ("Multiplied the diffuse Texture RGB Output of the material " + i.name + " times " + diffCoeff as string)
)
)
if (not hasproperty i.texmap_diffuse "*Output*")and (not hasproperty i.texmap_diffuse "*RGB_Multiplier*") do
(
print "About to inset map in output map!"
oldmap=i.texmap_diffuse
i.texmap_diffuse = output map1ldmap name"output_"+oldmap.name)
if isDiffAbs then (
try (i.texmap_diffuse.output.RGB_Level =diffCoeff ) catch ()
try (i.texmap_diffuse.Texture_Output.RGB_Level =diffCoeff ) catch ()
print ("Embedded the diffuse Texture of the material " + i.name + " in an Output Map, and multiplied its RGB Output to " + diffCoeff as string)
) else (
try (i.texmap_diffuse.output.RGB_Level *=diffCoeff ) catch ()
try (i.texmap_diffuse.Texture_Output.RGB_Level *=diffCoeff ) catch ()
print ("Embedded the diffuse Texture of the material " + i.name + " in an Output Map, and multiplied its RGB Output times " + diffCoeff as string)
)
)
)
if (i.texmap_diffuse == undefined) do
(
i.texmap_diffuse = VRayColor name:"VRColor_Diff_"
i.texmap_diffuse.name = uniquename i.texmap_diffuse.name
i.texmap_diffuse.color = i.Diffuse
if isDiffAbs then (
i.texmap_diffuse.rgb_multiplier =diffCoeff
)else (
i.texmap_diffuse.rgb_multiplier *=diffCoeff
)
print ("Changed the Diffuse Colour of the material " + i.name + " with a VRayColor Map, and multiplied to " + diffCoeff as string)
)
)
if doreflection do (
if i.texmap_reflection != undefined do (
print "Found reflection Map"
if (hasproperty i.texmap_reflection "*Output*") or (hasproperty i.texmap_reflection "*RGB_Multiplier*") do
(
print "Found map with Output or RGB_Level Parameters"
if isreflAbs then (
try (i.texmap_reflection.RGB_Multiplier =reflCoeff ) catch ()
try (i.texmap_reflection.output.RGB_Level =reflCoeff ) catch ()
try (i.texmap_reflection.Texture_Output.RGB_Level =reflCoeff ) catch ()
print ("Multiplied the reflection Texture RGB Output of the material " + i.name + " to " + reflCoeff as string)
) else (
try (i.texmap_reflection.RGB_Multiplier *=reflCoeff ) catch ()
try (i.texmap_reflection.output.RGB_Level *=reflCoeff ) catch ()
try (i.texmap_reflection.Texture_Output.RGB_Level *=reflCoeff ) catch ()
print ("Multiplied the reflection Texture RGB Output of the material " + i.name + " times " + reflCoeff as string)
)
)
if (not hasproperty i.texmap_reflection "*Output*")and (not hasproperty i.texmap_reflection "*RGB_Multiplier*") do
(
print "About to inset map in output map!"
oldmap=i.texmap_reflection
i.texmap_reflection = output map1ldmap name"output_"+oldmap.name)
if isreflAbs then (
try (i.texmap_reflection.output.RGB_Level =reflCoeff ) catch ()
try (i.texmap_reflection.Texture_Output.RGB_Level =reflCoeff ) catch ()
print ("Embedded the reflection Texture of the material " + i.name + " in an Output Map, and multiplied its RGB Output to " + reflCoeff as string)
) else (
try (i.texmap_reflection.output.RGB_Level *=reflCoeff ) catch ()
try (i.texmap_reflection.Texture_Output.RGB_Level *=reflCoeff ) catch ()
print ("Embedded the reflection Texture of the material " + i.name + " in an Output Map, and multiplied its RGB Output times " + reflCoeff as string)
)
)
)
if (i.texmap_reflection == undefined ) do
(
if i.reflection != color 0 0 0 do (
i.texmap_reflection = VRayColor name:"VRColor_Refl_"
i.texmap_reflection.name = uniquename i.texmap_reflection.name
i.texmap_reflection.color = i.reflection
if isReflAbs then (
i.texmap_reflection.rgb_multiplier =reflCoeff
)else (
i.texmap_reflection.rgb_multiplier *=reflCoeff
)
print ("Changed the Reflection Colour of the material " + i.name + " with a VRayColor Map, and multiplied it times " + reflCoeff as string)
)
)
)
)
TheMats=#()
)
)
rollout PhMatConvRoll "VRay PhysMat Converter 1.1a" width:304 height:88
(
checkbox chk1 "Affect Diffuse" pos:[8,8] width:104 height:16 checked:true
checkbox chk2 "Affect Reflection" pos:[8,32] width:104 height:16 checked:true
spinner spn1 "Diff. Mult.:" pos:[120,8] width:88 height:16 range:[0,5,0.255] scale:0.001 fieldwidth:40
spinner spn2 "Refl. Mult.:" pos:[120,32] width:88 height:16 range:[0,5,0.255] scale:0.001 fieldwidth:40
button btn1 "Fix The materials!" pos:[8,56] width:288 height:24
checkbox chk3 "Relative" pos:[222,8] width:74 height:16
checkbox chk4 "Relative" pos:[222,32] width:74 height:16
on btn1 pressed do
(
fixthemats chk1.state chk2.state spn1.value spn2.value chk3.state chk4.state
)
on chk3 changed state do(
chk3.caption = if state then "Absolute" else "Relative"
)
on chk4 changed state do(
chk4.caption = if state then "Absolute" else "Relative"
)
)
createdialog PhMatConvRoll
you're welcome.
--you're free to modify this script as you wish, as long as the above lines remain in place,
--and proper credit is given to the original author (me!) in case of public distribution and/or modification
fn fixthemats dodiffuse doreflection diffCoeff reflCoeff isDiffAbs isReflAbs=
(
undo on (
theMats = getclassinstances vraymtl
for i in theMats do
(
if dodiffuse do (
if i.texmap_diffuse != undefined do (
print "Found Diffuse Map"
if (hasproperty i.texmap_diffuse "*Output*") or (hasproperty i.texmap_diffuse "*RGB_Multiplier*") do
(
print "Found map with Output or RGB_Level Parameters"
if isDiffAbs then (
try (i.texmap_diffuse.RGB_Multiplier =diffCoeff ) catch ()
try (i.texmap_diffuse.output.RGB_Level =diffCoeff ) catch ()
try (i.texmap_diffuse.Texture_Output.RGB_Level =diffCoeff ) catch ()
print ("Multiplied the diffuse Texture RGB Output of the material " + i.name + " to " + diffCoeff as string)
) else (
try (i.texmap_diffuse.RGB_Multiplier *=diffCoeff ) catch ()
try (i.texmap_diffuse.output.RGB_Level *=diffCoeff ) catch ()
try (i.texmap_diffuse.Texture_Output.RGB_Level *=diffCoeff ) catch ()
print ("Multiplied the diffuse Texture RGB Output of the material " + i.name + " times " + diffCoeff as string)
)
)
if (not hasproperty i.texmap_diffuse "*Output*")and (not hasproperty i.texmap_diffuse "*RGB_Multiplier*") do
(
print "About to inset map in output map!"
oldmap=i.texmap_diffuse
i.texmap_diffuse = output map1ldmap name"output_"+oldmap.name)
if isDiffAbs then (
try (i.texmap_diffuse.output.RGB_Level =diffCoeff ) catch ()
try (i.texmap_diffuse.Texture_Output.RGB_Level =diffCoeff ) catch ()
print ("Embedded the diffuse Texture of the material " + i.name + " in an Output Map, and multiplied its RGB Output to " + diffCoeff as string)
) else (
try (i.texmap_diffuse.output.RGB_Level *=diffCoeff ) catch ()
try (i.texmap_diffuse.Texture_Output.RGB_Level *=diffCoeff ) catch ()
print ("Embedded the diffuse Texture of the material " + i.name + " in an Output Map, and multiplied its RGB Output times " + diffCoeff as string)
)
)
)
if (i.texmap_diffuse == undefined) do
(
i.texmap_diffuse = VRayColor name:"VRColor_Diff_"
i.texmap_diffuse.name = uniquename i.texmap_diffuse.name
i.texmap_diffuse.color = i.Diffuse
if isDiffAbs then (
i.texmap_diffuse.rgb_multiplier =diffCoeff
)else (
i.texmap_diffuse.rgb_multiplier *=diffCoeff
)
print ("Changed the Diffuse Colour of the material " + i.name + " with a VRayColor Map, and multiplied to " + diffCoeff as string)
)
)
if doreflection do (
if i.texmap_reflection != undefined do (
print "Found reflection Map"
if (hasproperty i.texmap_reflection "*Output*") or (hasproperty i.texmap_reflection "*RGB_Multiplier*") do
(
print "Found map with Output or RGB_Level Parameters"
if isreflAbs then (
try (i.texmap_reflection.RGB_Multiplier =reflCoeff ) catch ()
try (i.texmap_reflection.output.RGB_Level =reflCoeff ) catch ()
try (i.texmap_reflection.Texture_Output.RGB_Level =reflCoeff ) catch ()
print ("Multiplied the reflection Texture RGB Output of the material " + i.name + " to " + reflCoeff as string)
) else (
try (i.texmap_reflection.RGB_Multiplier *=reflCoeff ) catch ()
try (i.texmap_reflection.output.RGB_Level *=reflCoeff ) catch ()
try (i.texmap_reflection.Texture_Output.RGB_Level *=reflCoeff ) catch ()
print ("Multiplied the reflection Texture RGB Output of the material " + i.name + " times " + reflCoeff as string)
)
)
if (not hasproperty i.texmap_reflection "*Output*")and (not hasproperty i.texmap_reflection "*RGB_Multiplier*") do
(
print "About to inset map in output map!"
oldmap=i.texmap_reflection
i.texmap_reflection = output map1ldmap name"output_"+oldmap.name)
if isreflAbs then (
try (i.texmap_reflection.output.RGB_Level =reflCoeff ) catch ()
try (i.texmap_reflection.Texture_Output.RGB_Level =reflCoeff ) catch ()
print ("Embedded the reflection Texture of the material " + i.name + " in an Output Map, and multiplied its RGB Output to " + reflCoeff as string)
) else (
try (i.texmap_reflection.output.RGB_Level *=reflCoeff ) catch ()
try (i.texmap_reflection.Texture_Output.RGB_Level *=reflCoeff ) catch ()
print ("Embedded the reflection Texture of the material " + i.name + " in an Output Map, and multiplied its RGB Output times " + reflCoeff as string)
)
)
)
if (i.texmap_reflection == undefined ) do
(
if i.reflection != color 0 0 0 do (
i.texmap_reflection = VRayColor name:"VRColor_Refl_"
i.texmap_reflection.name = uniquename i.texmap_reflection.name
i.texmap_reflection.color = i.reflection
if isReflAbs then (
i.texmap_reflection.rgb_multiplier =reflCoeff
)else (
i.texmap_reflection.rgb_multiplier *=reflCoeff
)
print ("Changed the Reflection Colour of the material " + i.name + " with a VRayColor Map, and multiplied it times " + reflCoeff as string)
)
)
)
)
TheMats=#()
)
)
rollout PhMatConvRoll "VRay PhysMat Converter 1.1a" width:304 height:88
(
checkbox chk1 "Affect Diffuse" pos:[8,8] width:104 height:16 checked:true
checkbox chk2 "Affect Reflection" pos:[8,32] width:104 height:16 checked:true
spinner spn1 "Diff. Mult.:" pos:[120,8] width:88 height:16 range:[0,5,0.255] scale:0.001 fieldwidth:40
spinner spn2 "Refl. Mult.:" pos:[120,32] width:88 height:16 range:[0,5,0.255] scale:0.001 fieldwidth:40
button btn1 "Fix The materials!" pos:[8,56] width:288 height:24
checkbox chk3 "Relative" pos:[222,8] width:74 height:16
checkbox chk4 "Relative" pos:[222,32] width:74 height:16
on btn1 pressed do
(
fixthemats chk1.state chk2.state spn1.value spn2.value chk3.state chk4.state
)
on chk3 changed state do(
chk3.caption = if state then "Absolute" else "Relative"
)
on chk4 changed state do(
chk4.caption = if state then "Absolute" else "Relative"
)
)
createdialog PhMatConvRoll
you're welcome.
Comment