Author Topic: [DEPRECATED] Material Converter  (Read 50692 times)

2012-09-12, 11:22:11
Reply #15

GroveR_GoL

  • Active Users
  • **
  • Posts: 28
    • View Profile
    • www.gg3dcg.ru
Dead clown, your code is so cool, I've learned some new features from it. Thanks for sharing.

2012-09-12, 11:30:40
Reply #16

racoonart

  • Active Users
  • **
  • Posts: 1446
    • View Profile
    • racoon-artworks
Ok, this should be a stable version.
@Javadevil: Yes, I had swapped two commands here. It tried to convert the Ior value to a checkbox state ;)
@Keymaster: I will have a look on these license models. But, as this is a widely modified version of the VraySceneConverter I'm not sure if this is would be a "fair" thing to do. Anyway, I added a short comment at the beginning of the Script.
@GroveR_GoL: Thanks! I learned a lot from other people's scripts, so I try to always keep my code open to others :)

v0.04
supported materials:
- Standard mat
- VrayMtl
- VRayBlendMtl
- VRayLightMtl
- VRay2SidedMtl
- Vray-specific maps
- MR_ArchAndDesign
- fR_Advanced
- fR_Architectural 

changelog:
- Added fR_Advanced
- Added fR_Architectural
- fixed ArchAndDesign problems: anisotropy spinner*10, use refractmap slot, removed alpha from reflectioncolor
- added Debug conversion functions, will be removed or refined later
- Blend material works now
- Shellac will be converted to Blend (zero mix)
- DoubleSided will be converted to Blend (zero mix)


There is a new radiobutton control in the UI:
  • all materials + maps    , converting all materials and maps in the scene
  • sel. objects materials (Debug)    , for debugging purposes: It will convert the material assigned to the selected object(s). Note: If the objects material is also in a Materialeditor slot it will only modify the one on the object. Materialeditor slot will stay untouched (resulting in loosing the connection to the sel. objects)
  • current Mat.editor slot (Debug)    , same here vice versa. selected MatEditor slot will be changed, objects materials stay untouched

Removed blend Material conversion and added non-destructive shellac and DoubleSided conversion
« Last Edit: 2013-03-27, 16:52:46 by DeadClown »
Any sufficiently advanced bug is indistinguishable from a feature.

2012-09-12, 11:34:05
Reply #17

GroveR_GoL

  • Active Users
  • **
  • Posts: 28
    • View Profile
    • www.gg3dcg.ru
Only one thing. Plaese put brackets like this

rollout CoronaConverter "Convert Materials to Corona" width:200 height:160
   (
      groupBox grp1 "standard Materials" pos:[8,8] width:184 height:40
      checkbox chkReflstandardMat "convert specular to reflection" pos:[16,24] width:168 height:16 checked:standardMatSpecToRefl
      groupBox grp2 "Vray Materials" pos:[8,56] width:184 height:56
      checkbox chkConvVrayGloss "convert glossy values (experimental)" pos:[16,72] width:168 height:32 checked:VrayConvertGlossyValues
      button btnStartConverting "Convert Mats + Maps" pos:[8,120] width:184 height:32
      
      on chkReflstandardMat changed state do
      (
         standardMatSpecToRefl = state
      )
         
      on chkConvVrayGloss changed state do
      (
         VrayConvertGlossyValues = state
      )
      
      on btnStartConverting pressed do
      (
         mtlsToCorona()
         format "Converting unsupported maps...\n"
         ReplaceUnsupportedMaps()
         format "Done.\n"
      )
   )

and not like this

rollout CoronaConverter "Convert Materials to Corona" width:200 height:160 (
      groupBox grp1 "standard Materials" pos:[8,8] width:184 height:40
      checkbox chkReflstandardMat "convert specular to reflection" pos:[16,24] width:168 height:16 checked:standardMatSpecToRefl
      groupBox grp2 "Vray Materials" pos:[8,56] width:184 height:56
      checkbox chkConvVrayGloss "convert glossy values (experimental)" pos:[16,72] width:168 height:32 checked:VrayConvertGlossyValues
      button btnStartConverting "Convert Mats + Maps" pos:[8,120] width:184 height:32
      
      on chkReflstandardMat changed state do(
         standardMatSpecToRefl = state
      )
      
      on chkConvVrayGloss changed state do(
         VrayConvertGlossyValues = state
      )
      
      on btnStartConverting pressed do(
         mtlsToCorona()
         format "Converting unsupported maps...\n"
         ReplaceUnsupportedMaps()
         format "Done.\n"
      )
   )

otherwise "toggle all folds" function does not work. Thanks.

2012-09-12, 11:52:18
Reply #18

GroveR_GoL

  • Active Users
  • **
  • Posts: 28
    • View Profile
    • www.gg3dcg.ru
One more question. How about Blend, Shellac, DoubleSided materials? Why you create empty corona material instead of them? Blend material works fine in corona, doesn't it? What if convert Vray blend to simple blend with multi nesting.

2012-09-12, 12:01:57
Reply #19

racoonart

  • Active Users
  • **
  • Posts: 1446
    • View Profile
    • racoon-artworks
The simple answer is: I didn't test blend/shellac materials yet ;) . Personally, i don't use any of them, that's why I didn't spent time on these yet. If you need those you can simply comment their classes out ("-- Blend: CreateDefaultCoronaMtl orig_mtl") - that will keep blend materials the way they are, submaterials should still convert properly.

[Edit] updated v0.04, blend works now, shellac and doublesided are converted to blend materials.
« Last Edit: 2012-09-12, 12:45:55 by DeadClown »
Any sufficiently advanced bug is indistinguishable from a feature.

2012-09-12, 15:01:37
Reply #20

Javadevil

  • Active Users
  • **
  • Posts: 399
    • View Profile

Thanks Deadclown,

Just ran it through a scene with some cars in it. They all had Mental ray car paint shaders.
Can the script convert them too ? just to default corona mats ?

cheers

2012-09-12, 15:50:06
Reply #21

racoonart

  • Active Users
  • **
  • Posts: 1446
    • View Profile
    • racoon-artworks
Javadevil:
I'll try to figure out an "intelligent" way to convert this car paint stuff... A lot of properties which will not easily transfer into an normal material. Anyways. I made a little code snippet which will convert car paint materials into a simple corona material with it's original base color (no reflections, sorry). Just paste this to your maxscript editor and evaluate it.
Code: [Select]
for mp in (getClassInstances Car_Paint_Material__mi) do(
r=CoronaMtl TODOdiffuse:mp.base_color
r.name="Corona "+mp.name
replaceInstances mp r
)
Any sufficiently advanced bug is indistinguishable from a feature.

2012-09-13, 12:59:15
Reply #22

Javadevil

  • Active Users
  • **
  • Posts: 399
    • View Profile

Thanks Deadclown.


2012-09-14, 23:06:29
Reply #23

Ludvik Koutny

  • VIP
  • Active Users
  • ***
  • Posts: 2557
  • Just another user
    • View Profile
    • My Portfolio
I have not had time yet to test the script (recently moved and got a new job - yeah, i know, not an excuse, but still :P), so i could not try it on my own, but i wonder, how is conversion of glossiness values and maps in glossiness slot handled? Because Vray's glossiness curve and mapping of bitmap is quite different to Corona's, so i wonder if there is some re-mapping of these values going on, or if this part has to be done manually? :)

2012-09-14, 23:16:24
Reply #24

Ondra

  • Administrator
  • Active Users
  • *****
  • Posts: 9048
  • Turning coffee to features since 2009
    • View Profile
guys from vray were willing to share their curve, so its possible to do exact match. But Corona uses different BRDF model by default, so it still needs to be guessed :/
Rendering is magic.How to get minidumps for crashed/frozen 3ds Max | Sorry for short replies, brief responses = more time to develop Corona ;)

2012-09-15, 00:42:30
Reply #25

racoonart

  • Active Users
  • **
  • Posts: 1446
    • View Profile
    • racoon-artworks
it's simply a guess ;) . the funny thing is, the original vray converter is doing a Finalrender glossy conversion by using this equation
Code: [Select]
fn sqr x = x*x
1.0-sqr (origMtl.reflectGlossy*0.01)

So, since Rawalanche said finalrender glossys would be far better fitting than vray glossys I just turned this principle around and do it by the square root: (origMtl would be vray material here)
Code: [Select]
(1.0 - sqrt(1.0 - origMtl.reflection_glossiness))
I know it doesn't fit coronas model but it's at least a bit better than no conversion at all ;) It works quite well with higher values but since i don't have any mathematical proof or something else I labeled it "experimental"
« Last Edit: 2012-09-15, 00:45:13 by DeadClown »
Any sufficiently advanced bug is indistinguishable from a feature.

2012-09-16, 12:46:36
Reply #26

Ondra

  • Administrator
  • Active Users
  • *****
  • Posts: 9048
  • Turning coffee to features since 2009
    • View Profile
I've renamed the parameters in the newest build, so the script is temporarily broken, until somebody rewrites it.
Rendering is magic.How to get minidumps for crashed/frozen 3ds Max | Sorry for short replies, brief responses = more time to develop Corona ;)

2012-09-16, 13:36:36
Reply #27

racoonart

  • Active Users
  • **
  • Posts: 1446
    • View Profile
    • racoon-artworks
I will do that asap. May take some time though ;)
Any sufficiently advanced bug is indistinguishable from a feature.

2012-09-16, 13:40:38
Reply #28

Ondra

  • Administrator
  • Active Users
  • *****
  • Posts: 9048
  • Turning coffee to features since 2009
    • View Profile
ok, thanks, same goes for other converters (if they use any parameters)
Rendering is magic.How to get minidumps for crashed/frozen 3ds Max | Sorry for short replies, brief responses = more time to develop Corona ;)

2012-09-16, 14:06:58
Reply #29

racoonart

  • Active Users
  • **
  • Posts: 1446
    • View Profile
    • racoon-artworks
seems like displacement mapslot has wrong naming. It has the same name as diffuse.
.texmapDiffuse (Diffuse_texture) : texturemap
.texmapDiffuse (Displace_texmap) : texturemap
Any sufficiently advanced bug is indistinguishable from a feature.