Jump to content

mtl2mat - Learning Python


michael

Recommended Posts

so I want to start learning python...

and I thought a good way to do it besides just poking around at work would be to do a little project that actually did something useful in Houdini.

last year I was cleaning up my computer crap and found I had lots of little obj+mtl files around that I had collected from all over the place and while I had occasionally used a few of the objs I'd never bothered to even look at the mtls.

so that's the project - make a converter for an mtl file that will build a Houdini material.

(if there already is one that's cool - it would be useful for people to have)

so my question to you strange people who lurk in the Shaders area of od[force] is this:

what kind of material should I build?

I don't really want to build a shader right from scratch but I'd like something that can accommodate everything that an mtl file might try to describe.

this is an example from a file format description I found (from 1995!)

##############

# Material name statement:

newmtl my_mtl

# Material color and illumination statements:

# ambient reflectivity

Ka 0.0435 0.0435 0.0435

# diffuse reflectivity

Kd 0.1086 0.1086 0.1086

# specular reflectivity

Ks 0.0000 0.0000 0.0000

# transmission filter

Tf 0.9885 0.9885 0.9885

# illumination model

illum 6

# dissolve

d -halo 0.6600

# specular exponent

Ns 10.0000

# sharpness of the reflections

sharpness 60

#optical density

Ni 1.19713

# Texture map statements:

map_Ka -s 1 1 1 -o 0 0 0 -mm 0 1 chrome.mpc

map_Kd -s 1 1 1 -o 0 0 0 -mm 0 1 chrome.mpc

map_Ks -s 1 1 1 -o 0 0 0 -mm 0 1 chrome.mpc

map_Ns -s 1 1 1 -o 0 0 0 -mm 0 1 wisp.mps

map_d -s 1 1 1 -o 0 0 0 -mm 0 1 wisp.mps

disp -s 1 1 .5 wisp.mps

decal -s 1 1 1 -o 0 0 0 -mm 0 1 sand.mps

bump -s 1 1 1 -o 0 0 0 -bm 1 sand.mpb

# Reflection map statement:

refl -type sphere -mm 0 1 clouds.mpc

##############

most of this seems reasonably clear (Ka, Kd etc)

but what about these goof-ball texture map options?

and the illumination models listed:

0 Color on and Ambient off

1 Color on and Ambient on

2 Highlight on

3 Reflection on and Ray trace on

4 Transparency: Glass on

Reflection: Ray trace on

5 Reflection: Fresnel on and Ray trace on

6 Transparency: Refraction on

Reflection: Fresnel off and Ray trace on

7 Transparency: Refraction on

Reflection: Fresnel on and Ray trace on

8 Reflection on and Ray trace off

9 Transparency: Glass on

Reflection: Ray trace off

10 Casts shadows onto invisible surfaces

these seem like things people do in other ways now...

I had a quick look at the mantra surface node in the materials palette and it seems to have most everything I can decipher from the format description, and more (obviously), but is this the best way to go?

Ideally I'd want to make a material that does everything the mtl describes, that's first, but I'd also like to provide the user with a material that has the usual nice stuff to go beyond this (AOVs, SSS etc).

any advice on this would be great.

thanks!

Link to comment
Share on other sites

...

I had a quick look at the mantra surface node in the materials palette and it seems to have most everything I can decipher from the format description, and more (obviously), but is this the best way to go?

Ideally I'd want to make a material that does everything the mtl describes, that's first, but I'd also like to provide the user with a material that has the usual nice stuff to go beyond this (AOVs, SSS etc).

any advice on this would be great.

thanks!

seems to me like the most user friendly + forward looking way to do this would be to dynamically build a vop network (a-la 'shader fx') using a surface model and some texture nodes. that seems to maximize flexibility and minimize extraneous nodes/parameters that might come from trying to manage this all at the 'shop' level rather than the 'vop' level. this seems like it would create a nice 'framework' for building a complete network based on the mtl data as a starting point.

the nice thing about doing it this way is that you could take a look at the python for 'shader fx' to get started :)

just my 2c

Link to comment
Share on other sites

Nice idea Michael :rolleyes: Here is my thought:

Most of materials in .mtl files aren't very complex...i would say they are pretty simple. And the mantra surface is far more complex, with a lot of stuff, that you probably, never find in .mtl. So, maybe a good start will be to build a simple "surface model" otl,maybe some hand-written VOP OP, just to speed things up....

Anyway, good luck with that. I'm sure you'll love python.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...