Wave
Não há avaliações suficientes
An analysis of the MTL file format
Por Rellik66
An overview of the MTL file format and what makes it interesting for Wave-making
   
Premiar
+ favoritos
Nos favoritos
- favoritos
So, what exactly is a MTL?
Good question, the MTL file is the companion file to the OBJ file, both alongside any optional textures complete a poly object, as defined by the Lightwave OBJ spec.

MTL in particular defines what each face of the object will look like in terms of color and texture.

Now, I could link the MTL spec[paulbourke.net] and call it a day, but it is very complicated and the vast majority is not used by Wave.

So let's get started!
An example MTL define
buried in the MTL spec are a few examples that I recreated in this Material Test object[poly.google.com], let's start with a simple example:
#This is a flat green material. newmtl flat_green Ka 0.0000 1.0000 0.0000 Kd 0.0000 1.0000 0.0000 illum 1

As it is strongly hinted, this is a flat green material, so any faces it is applied to on the object the object will be green, nothing else is defined outside ilumination values, (more on that later,) so it will be up to the software decide how shiny it is.

Let's go over the various parts:
#This is a flat green material.
This is just a simple comment. Doesn't define anything, but is useful for adding additional context to the material and how it is used.
newmtl flat_green
This is the name of the material that the OBJ calls out when a face needs a material. It is technically possible to change the name, but all references in the OBJ will need to be changed too
Ka 0.0000 1.0000 0.0000 Kd 0.0000 1.0000 0.0000 illum 1
These are the material color and illumination statements.

The keener eyes among you would notice the 0.0000 1.0000 0.0000 part is what defines the color as green, as it is using a RGB model. And you would be right! Want it to be white instead? use 1.000 1.000 1.000. Black? 0.000 0.000 0.000 Orange? 1.000 0.500 0.150 and so on.

The next items that would be defined would be any relevant image textures, but this material does not have any of that.

Now let's take a closer look at what Wave actually uses:
The Material Defines
Wave only currently uses a small subset of the mtl spec, this is largely due to the obj importer library being used I assume.

Below are the relevant definitions, pretty much anything else is ignored.

Kd r# g# b#
Diffuse Color, ie base color, using an RGB model each color goes from 0 to 1. Trailing zeroes are not needed, but are useful for organization
Examples from above:
Green:
Kd 0 1 0
White
Kd 1 1 1
Black
Kd 0 0 0
Grey
Kd 0.5 0.5 0.5
Orange
Kd 1.0000 0.4980 0.1529

One thing to be very aware of, particularly when using Sketchup or Blender is any image texture applied to the object will not show the diffuse color in the software or Google Poly, but will show in Wave. Make sure to set the diffuse color to white before applying any textures.

The diffuse color can be exploited as a way to darken textured objects to compensate for directional or point lights used in any scene. setting it around .3 .3 .3 will darken the object without having to use the darkness control too much.

d value
reference poly[poly.google.com]
Dissolve, ie transparency.

Not to be confused with image transparency, goes from 0 (100% Transparent) to 1 (Full opaque)

Of note is the fact that faces have two sides and can look odd when seen from the other side as seen in the reference poly

Also note that setting something to fully transparent can lead to odd behavior so it is recomended to set d to almost full transparency ie d 0.0001

Ns value
reference poly[poly.google.com]

Specular Exponent, aka Specular Hardness, Roughness, Glossyness

Every time you teleport or snap-turn in Wave, a snapshot of your surroundings is taken and used to for the reflection on every object, Specular Exponent uses this snapshot to to reflect it back and the number determines how "perfect" the reflection is. 0 means dull reflection 1000 means mirror-like refection.

illum value
Illum is interesting, there are a number of options, but as far as Wave is concerned, there are only two.

Below are the official definitions
Illumination Properties that are turned on in the model Property Editor 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

Reference Poly[poly.google.com]
Reference Poly #2[poly.google.com]

As you can see in the reference poly, there are only two modes, regular diffuse and "metallic"

Regular Diffuse
0, 1, 2 ,4 ,6, 7, 9
pretty much displays as-is.

"Metallic"
3, 5, 8
The difference according to the spec is "reflection on" but that doesn't make any sense in this context, that's why I am calling this "Metallic"

In short, from what I can tell the diffuse color is halved and not lit with invisible lights, reflections have a fall-off distance, and relies on the surrounding environment to brighten the material.

To keep things simple just stick with illum 2 for regular diffuse materials and illum 3 for "metallic" materials.

map_Kd filename.ext
reference poly[poly.google.com]

Image texture used for the diffuse material, JPG and PNG are known to be supported.

Usage of map_Kd assumes that the objects has been UV-mapped appropriately.

Important note: there is a very distinct difference between 24 bit PNGs and 32 bit PNGs. 24 bit PNGs do not have any transparency whereas 32 bit PNGs do. Because of this 32 bit PNGs can exhibit odd behavior, even when there is no alpha transparency present on the image. Tunnel objects and particle object suffer the most from this. see the image to the right for an example, the left cube is 24 bit, the right cube is 32 bit, Same texture, only difference is 24bit vs 32bit.

Conclusion
And that is it for what Wave uses, in the future, here's hoping for more support for thing like bump for normal maps and other image maps.

Blender 2.8
Blender 2.8 is currently the best free software available for controlling the materials, here's a rundown:
Importing OBJs
Upon importing an OBJ, first thing to do is just see what happens when you import it, if it is rotated wrong or too big, that can be fixed in the right pane of the import file menu

  • Usually some objects expect Y to be up, others expect Z to be up
  • Some objects import reeeeeaaaallllyy large, setting the clamp size around 10 or whatever works will prevent the object from being too large.
Shader Window Preset

After selecting the mesh you wish to alter, the top edge of the screen will will have a window preset for Shading


The important items are highlighted, changing the other things will have little or no effect in wave.

Of note is that meshes can contain multiple materials that can be selected at the top of the material tab.

Textured materials

Textured materials are a little different


Do note that the base color cannot be changed once a texture is connected. The base color is still there and will be exported to the mtl. You can still disconnect the texture and change the base color and reconnect it.

Also, you will quickly discover what your UV map looks like, editing UV maps are outside the scope of this guide, but there are plenty of guides out there, Google is your friend.

Exporting
Once the materials are the way you want, you can export the obj and mtl to a new file or replace the current obj/mtl. If the material names are not changed, you could export to a new file and use the created mtl to replace the original obj mtl without modifying the geometry.
Modeling Resources
Here are a few sites with Creative Commons textures and/or models that can be used in any modelling creations:

Models
poly.google.com
3dwarehouse.sketchup.com

Textures
texturehaven.com
cc0textures.com
opengameart.org

Other
color.adobe.com/explore (Useful for picking colors)