Author Topic: Converting away from CoronaPhysicalMaterial (to Physical Material, Vray, etc...)  (Read 654 times)

2022-09-23, 14:06:49

jaspercrowe

  • Active Users
  • **
  • Posts: 7
    • View Profile
Does anyone know of any method to convert Corona Physical Materials to either standard Autodesk Physical Materials or Vray materials. I need to import a scene into Unreal, and Datasmith doesn't have support for Corona Physical Materials.

Are there any plugins out there that do this, or will I have to manually convert each material myself?

2022-09-23, 14:31:13
Reply #1

James Vella

  • Active Users
  • **
  • Posts: 542
    • View Profile
I wrote a script that converts Vray Roughness to Corona Legacy material. This currently works for Corona 5.0 so you will have to swap the syntax for the Corona part.

If you are handy with maxscript you could inverse the functions and re-use the code to do whatever you like (keep in mind you might want to add some try/catch loops in case ive done something specific for my workflow such as the naming convention for bitmaps (_Roughness.png _Glossiness.png). It really only covers VrayMtl, Multi-Sub & Vray2Sided, other material types can be added using the template function ive created - fn convert_to_glossiness i :

Code: [Select]
macroScript RoughToGloss
category:"Vella"
internalcategory:"Automate"
tooltip:"Automate RoughToGloss"
buttonText:"Rough To Gloss"
Icon:#("SchematicView",1)

(
-- Function to replace BRDF Glossiness to Roughness
fn convert_to_glossiness i =
(
i.brdf_useRoughness = off

-- Convert Roughness to Glossiness bitmap
if i.texmap_reflectionGlossiness != undefined then
(
i.texmap_reflectionGlossiness.filename = substituteString i.texmap_reflectionGlossiness.filename "Roughness" "Glossiness"
)

-- Place BaseColor in Reflection, Remove Fresnsel (Metal), Set Diffuse to Black (Glossiness Metal Workflow)
if i.texmap_metalness != undefined then
(
i.Diffuse = color 0 0 0
i.texmap_reflection = i.texmap_diffuse
i.texmap_diffuse = undefined
i.reflection_fresnel = off
i.texmap_metalness = undefined
)

return i
)

-- Function to replace VRay2SidedMtl with VrayMtl
fn convert_Vray2Sided_to_VrayMtl i =
(
newMat = i.frontMtl

-- Convert Vray to VrayMtl
i = newMat

-- Convert from VrayMtl to StandardMtl using convert_to_stdmtl Function
convert_to_glossiness i
)


-- Find all VRay2SidedMtl and replace with VrayMtl in the scene
for i in sceneMaterials do
(
if (classof i == VRay2SidedMtl) do
(
p = convert_Vray2Sided_to_VrayMtl i

if (i.name == p.name) and (i.name != undefined) do
(
replaceinstances i p
)
)
)

-- Find all VrayMtls and VrayMtls in Multi-Sub in the scene
for i in sceneMaterials do
(
-- Convert VrayMtl to BRDF Glossiness using convert_to_glossiness function
if (classof i == VrayMtl) do
(
p = convert_to_glossiness i

if (i.name == p.name) and (i.name != undefined) do
(
replaceinstances i p
)
)
-- Find Multi-Sub Materials
if (classof i == Multimaterial) do
(
-- Convert VrayMtl to BRDF Glossiness using convert_to_glossiness function
for n in i do
(
if (classof n == VrayMtl) do
(
p = convert_to_glossiness n

if (n.name == p.name) and (n.name != undefined) do
(
replaceInstances n p
)

)
)
)
)

-- refresh asset tracker
ATSOps.Refresh()
)

« Last Edit: 2022-09-23, 14:40:58 by James Vella »