Author Topic: Autodesk Physical to Corona Physical Material Converter  (Read 1580 times)

2023-06-20, 14:07:14

James Vella

  • Active Users
  • **
  • Posts: 534
    • View Profile
Ok well I cracked something together, again without some real-world examples it may be missing some features or break (see the screenshot at the bottom). Feel free to give me feedback and send me some material cases. Warning: Still in test phase, save your files and don't send me death threats... pretty please. Script attached to this post.

This is what it converts:
- Diffuse (if it cant find Diffuse texture it will use the Swatch Color)
- Roughness
- Opacity
- Metal
- Normal
- Multi-Sub materials supported

Other notes:
- Autodesk Physical Material to Corona Physical Material
- Using CoronaBitmap nodes instead of standard Bitmap nodes
- Keeps naming convention from Physical Material map nodes instead of 'CoronaBitmap' naming
- Gamma 2.2 for Diffuse, Gamma 1.0 for all other textures
- Normal texture goes into the 'Corona Normal > Input Image' node. If you use standard Bump I can put a clause in there to swap it over if it doesn't find your naming convention. For example if "_Normal.png" not found in texture name then place in "Additional Bump Mapping" slot instead.
- If Metal texture used then Corona Physical Material switches Metalness to 'Metal'. Again can be scripted to find a value instead and switch it on if < 0 or whatever.
- Careful regarding Metal Materials, follow the PBR guide, for Diffuse textures lowest black value 40, highest white value 240 otherwise your Metals will blank out at lower values. Metal textures still can use the 0-255 range. We could use the standard workflow Corona introduced when converting from Vray materials with Metal but I have my doubts about this 'Mix' value (for those who have done their own comparisons).
- Do not stack Multi-Sub materials within Multi-Subs.
- The script works scene wide, not on selected objects. Only converts Autodesk Physical Materials so wont affect Corona or Vray materials etc.
- Currently only working with bitmap nodes plugged in as per the screenshots below, I need real-world material cases to test all situations. Default material import settings from sketchup or whatever is best for fastest workflow. For example if by default a material imports with multiple nodes between the bitmap and material then this script will not work.

Install:
- Drag the .ms file into 3dsmax
- Customize > Customize User Interface > Toolbars > Category: Vella > Automate PhysicalToCorona > Drag this to your toolbar.
- Click the button

Autodesk Physical Material
Material-01-Phys" border="0

Corona Physical Material - Converted with script
Material-01-Corona" border="0

Autodesk Physical Material (Multi-Sub)
Multi-Sub-02-Phys" border="0

Corona Physical Material (Multi-Sub) - Converted with script
Multi-Sub-02-Corona" border="0

Example of how the script will break (currently) if there are extra nodes between the bitmaps and the material (In the Autodesk Physical Material). This is why I need real-world examples of imported materials. Once I have a few examples I will put some try/catches in so it skips over anything it cant find so the script will be more stable (Reminder I'm not a pro scripter, there is some recursive things going on I need to get my head around, enough for today).
Broken-Nodes" border="0

However there is a fairly simply workaround for now I could do that wont break, that is just copy the entire tree into the nodes. So that means whatever nodes connect to each material input will be retained. This means that the Bitmaps will be standard Bitmap nodes instead of CoronaBitmaps. But you could just use the Corona Conversion script after to convert those from Standard Bitmap to CoronaBitmap if you want, Let me know your thoughts. Here is an example.
« Last Edit: 2023-07-23, 10:35:35 by romullus »

2023-06-21, 15:40:29
Reply #1

James Vella

  • Active Users
  • **
  • Posts: 534
    • View Profile
Ok update on this. Script attached to this post v01.1.0.

Install:
- Delete the old toolbar button (if you used previous versions)
- Drag the .ms file into 3dsmax
- Customize > Customize User Interface > Toolbars > Category: Vella > Automate PhysicalToCorona > Drag this to your toolbar.
- Click the button

Notes:
- Now works with multiple input nodes (such as color correction, falloff, etc)
- Skips any crashes now using try/catches (for those reading my code, yeah its a bit overkill but better safe than sorry lol)
- Supports the same textures as previously
- Using standard Bitmaps in this version (you can convert using Corona Converter to CoronaBitmap if you wish)
- Gamma 2.2 for Diffuse, Gamma 1.0 for all other textures (as previously)
- Still no nesting Multi-subs in Multi-subs (probably could add this if its a common request, recursive loops still do my head in)
- Undo (ctrl-z)

Autodesk Physical Material
Phys-01" border="0

Corona Physical Material - Converted with script
Corona-01" border="0

Autodesk Physical Material with additional nodes
Phys-02" border="0

Corona Physical Material with additional nodes - Converted with script
Corona-02" border="0

Autodesk Physical Material (Multi-Sub)
Phys-Multi" border="0

Corona Physical Material (Multi-Sub) - Converted with script
Corona-Multi" border="0
« Last Edit: 2023-06-21, 16:22:26 by James Vella »

2023-06-22, 11:23:22
Reply #2

cumalot

  • Users
  • *
  • Posts: 1
    • View Profile
Hi, tnx for script, but can You make it for legacy corona mtl?

2023-06-22, 12:57:24
Reply #3

James Vella

  • Active Users
  • **
  • Posts: 534
    • View Profile
Hi, tnx for script, but can You make it for legacy corona mtl?

Are you using glossiness or roughness workflow?

For example we have 2 situations:
1. Roughness texture can be put into a Color Correction node (inverted) to appear as glossiness
2. If the Autodesk Physical Material is using glossiness then we just copy that bitmap into the glossiness slot.


Dont worry ill just have it do both depending on which one is being used.

Edit:
Just be aware the reason I went with the Corona Physical is because both are Physical workflows. The Corona Legacy Mtl doesnt have Metal so if your material uses metal then that texture will be removed and the fresnel set to 999. Is this what you expect?

Alternatively you will need a fairly complex setup that does the metal as a mask, a bit of math to transfer the IOR to the Specular which is then used as a Reflection texture, which will mess up any workflow that already uses a Reflection texture. Also the Diffuse controls the color of Metal in Physical instead of Reflection for Legacy. For example if you download a model that is unwrapped with some areas with metal and dielectrics masked in this will not work. Not sure if thats a standard situation for your workflow but again if other people use the script and it gives them strange outputs they will be disappointed. Again examples are a must here, I need to know what users actually need on a daily basis. I dont know how the sketchup files appear on import and how the material setups look so without examples I'm just giving a blanket solution which may not be useful to what people in this thread actually need.

You are best sending me an example scene with 2 boxes, 1 with a metal workflow and 1 with a dielectric workflow.

I have written about the differences between the new Physical and Legacy workflows in the past you can see what I mean - Check the section on "Down the Rabbit Hole".

https://jamesvella.wordpress.com/2020/04/20/2019-9-2-substance-designer-to-vraycorona/
« Last Edit: 2023-06-22, 16:51:23 by James Vella »

2023-06-22, 16:30:18
Reply #4

James Vella

  • Active Users
  • **
  • Posts: 534
    • View Profile
Small update, attached to this post:

Supports both Roughness and Glossiness from Physical Mtl.
rough-phys" border="0

rough-mtl" border="0

Example Glossiness (inverts the texture using a Color Correction node for the Corona Physical Mtl):
gloss-phys" border="0

gloss-mtl" border="0

If no texture then the Roughness value will be used (or inverted for Glossiness):
value" border="0

Converted from Roughness:
rough-value" border="0

Converted from Glossiness:
gloss-value" border="0
« Last Edit: 2023-06-22, 16:37:48 by James Vella »

2023-07-13, 15:02:24
Reply #5

James Vella

  • Active Users
  • **
  • Posts: 534
    • View Profile
Updated Script attached to this post.

Version 1.3.0 - newly added features
- Displacement
- IOR
- Anisotropy - update on this textures work, but values need to be fixed.
- Emission / Self Illumination
- Replaced Inverted Glossiness with Advanced Options > Roughness mode to Glossiness mode (in the Corona Physical Material).
- Clearcoat - Amount/Glossiness/Roughness/IOR
- Clearcoat Not Supported - Coating Color (Autodesk Physical Material) and Absorption (Corona Physical Material) as this behaves differently (unless I'm misunderstanding something).

Notes:
- Glossiness: Due to the nature of Autodesk Physical Material using both Roughness & Glossiness instead of just Roughness or Glossiness in Corona Physical Material it will switch to either Roughness or Glossiness based on your Reflection selection. Since this has an effect on Sheen and Clearcoat your textures and values will be inverted to suit whichever workflow you have selected in the Autodesk Physical Material - Reflection (Roughness or Glossiness).
- Values & Colors: If no texture used for any of the nodes in the below screenshots then the values will be used instead. For example if not using an IOR texture but set your IOR to 1.35 then it will transfer the value instead, this applies to all nodes. This also applies to colors such as the Diffuse or Emission color. (This can be modified to use both if preferred).
- Maxscript: While the code could also be simplified with 'and or' statements I have kept it longer with 'and' statements for easy readability instead of efficiency. This affects the 'Clearcoat' section.

Autodesk Physical Material:
physical-01" border="0

Corona Physical Material:
corona-01" border="0

When using Reflection Glossiness in Autodesk Physical Material:
phys-gloss" border="0

This is how it converts to Glossiness in Corona Physical Material:
corona-gloss" border="0

As always, test/backup and give me feedback on your findings.
« Last Edit: 2023-07-13, 22:01:26 by James Vella »

2023-07-14, 17:47:00
Reply #6

James Vella

  • Active Users
  • **
  • Posts: 534
    • View Profile
Updated script attached to this post.

Version 2.0 - new features:
- Re written most code to include all Numeric values for each node such as Base Color or Roughness values regardless of using a bitmap or not. Same applies for color swatches. Exception for Bump this is set to 1.0 keeping the default for Corona, let me know if this is an issue.
- Normal and Additional Bump nodes now work as per the Physical Normal Bump node and can copy both textures.
- If not using a Normal texture then only the Bump will be copied across and does not Require a Corona Normal Bump node.
- Metal now respects numerical values as well as Bitmaps. If using both numerical values with a bitmap, the bitmap will be placed into an Output node and the numerical value will control the 'Output Amount'. If only using numerical values 0-1 then those will be copied into the output amount. If using 1.0 metal (with no bitmap) then Corona material set to just Metal. Also works opposite, if metal set to 0 in Autodesk Physical (with no bitmap) the Corona material will be non-metal.
- Clearcoat Bump and IOR bitmap nodes now supported.
- Anisotropy numerical value/rotation fixed.
- Displacement heights value copied from numerical value in Physical

Autodesk Physical Material
phys" border="0

Corona Physical Material
corona" border="0

Autodesk Physical Material - Metal not set to 0 or 1 and using a bitmap
phys-metal" border="0

Corona Physical Material - Metal not set to 0 or 1 and using a bitmap. When using a bitmap and set to 0 or 1 no output node created and uses just the bitmap.
corona-metal" border="0

Metal - numerical value of 0-1 (no bitmap)
metal-value" border="0

Metal - numerical value of 0 (no bitmap)
metal-0" border="0

Metal - numerical value of 1 (no bitmap)
metal-1" border="0

Autodesk Physical Material - Displacement (works the same for all numerical values)
phys-disp" border="0

Corona Physical Material - Displacement (works the same for all numerical values)
corona-disp" border="0
« Last Edit: 2023-07-14, 18:04:12 by James Vella »

2023-07-16, 18:08:21
Reply #7

arqrenderz

  • Active Users
  • **
  • Posts: 984
  • https://www.behance.net/Arqrenderz1
    • View Profile
    • arqrenderz

2023-07-17, 09:47:11
Reply #8

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8746
  • Let's move this topic, shall we?
    • View Profile
    • My Models
Sorry, i realized that i had confused the topics and posted to the wrong one. All the issues mentioned in my previous message are related to Corona to Autodesk physical converter script. I will leave my reply there after i'll do few more tests.

Edit: i moved conversation about the other script to the correct topic.
« Last Edit: 2023-07-17, 10:49:31 by romullus »
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2023-07-17, 10:54:51
Reply #9

James Vella

  • Active Users
  • **
  • Posts: 534
    • View Profile
Sorry, i realized that i had confused the topics and posted to the wrong one. All the issues mentioned in my previous message are related to Corona to Autodesk physical converter script. I will leave my reply there after i'll do few more tests.

Edit: i moved conversation about the other script to the correct topic.

Perfect thanks!

2023-07-18, 14:59:58
Reply #10

James Vella

  • Active Users
  • **
  • Posts: 534
    • View Profile
Script attached to this post.

Version 2.1 Features:
- Able to search/replace bitmaps in Blend/Multi-Sub/Nested Multi-Sub etc.
« Last Edit: 2023-07-18, 15:05:31 by James Vella »

2023-07-23, 10:29:27
Reply #11

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8746
  • Let's move this topic, shall we?
    • View Profile
    • My Models
Found couple issues with 2.1 - the script is not keeping track of normal map node settings (i've only tested green channel inversion, since basically it's the only setting i ever touch in that map). Second issue is with anisotropy - 0 anisotropy in Autodesk physical is translated to -1 in Corona physical.

One more thing, i think that previously your scripts would only convert materials that were assigned to objects and leave unassigned materials not converted, but now they are converting everything (V2.1 and V1.7). I liked previous behaviour more. Would it be possible to bring it back?
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2023-07-24, 14:42:49
Reply #12

James Vella

  • Active Users
  • **
  • Posts: 534
    • View Profile
Script attached to this post.

Thanks for pointing that out romullus. Unfortunately since the default anisotropy for 3dsmax 2021 is 1.0 its flipping out on you. Ive just removed the value/rotation for now so it doesnt mess up your settings (so to clarify it does not copy Anisotropy value or rotation from Physical to Corona, still works with bitmaps however). Let me know if you want it back and I might have to go on that one blind folded. There is a way once I install 3dsmax 2024 to have it behave differently for different 3dsmax versions but I wont be updating for now for work/pipeline reasons.

Version 2.2 Features:
- Materials convert only for scene materials that are applied to objects
- Anisotropy value/rotation removed for now (values only, bitmaps still convert)
- Normal Map settings convert - Flip Red/Green/Swap Red & Green

Test it out, let me know if I broke something else lol.
« Last Edit: 2023-07-24, 15:54:22 by James Vella »

2023-07-24, 15:20:34
Reply #13

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8746
  • Let's move this topic, shall we?
    • View Profile
    • My Models
I'm perfectly happy with removal of attempt to convert anisotropy value. Majority of my materials don't use anisotropy, so it's one less setting to check after conversion :] Thank you!

I will test the script later and will let you know if i'll find any more issues.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2024-01-22, 14:50:31
Reply #14

Tom van den Ende

  • Users
  • *
  • Posts: 1
    • View Profile
I really appreciate what you've done.
I think you should be rewarded. If possible I would give a donation.

Tom.