Join Adam Crespi for an in-depth discussion in this video Creating and editing a diffuse material, part of Unity: Materials and Lighting.
In this video, I'll look at exporting objects out of Maya, for proper material placement. I've opened up the market elements Maya ASCII file after setting my project to 0101 Maya. What we can see here, is a collection of elements that will become our market place in Unity. This is a modular approach, so that I can build an instance preface in unity versus building a complete model here in Maya. And thereby reduce my seen size of my draw of course. I need to export out a set of these doors.
And look at what comes across the export process. What we're seeing is that the textures for the doors or in the Maya project. And I'll select them and zoom in on them to show them better. The other textures for the scene are in the Unity project. So Maya is looking for them, but doesn't find them, and just displays white. For the doors then, I'll select them, and see what objects are included. A big difference between Maya and Unity is that Maya can assign materials by polygon. Unity can only assign material by object, so I need to make that choice in Maya before I export.
These doors are divided, right side and left side or one and two. So that way, if needed in Unity we can animate them to open. We can also select each door uniquely and put a Box Collider, for example, to optimize a bit. I'll select all three pieces, both doors and the door frame, and export them out as an FBX. I'll choose File, and Export Selection. In the Export dialogue, I'll change the file type to FBX, scrolling down and selecting FBX Export. This'll go into the Scenes directory in my Maya project, unless I put it somewhere else.
I've created a folder in here called Exports. And I'm exporting and moving over, to make sure I keep track of where these are going. This is a door frame, and Door panel A. We need to have a consistent naming convention for our files. Because we may have lots of little bits coming into unity. So I'll call this door, panel A 01. So that when I clone them, I should get A-02 and so forth. In the include under geometry, I'll check smoothing groups, because that covers our hard and soft edges here, and I've defined them so the doors look crisp on the edges.
I'll scroll down and bypass Animation and Lights and Cameras. There's no animation on these yet. Under Advanced options I'll go into Units and uncheck Automatic and convert the units to meters. This is actually modelled in inches but we'll convert the units and set the scale to one in Unity. I'll click Export Selection. And the doors are exported. Now I'll copy that FBX into my Unity assets folder, and pull that file up. I've copied that FBX into the meshes folder I've created in my assets folder in my 01_01 Unity project.
And Unity has imported in that door mesh automatically. I'll go into meshes. And what we can see here are all the FBX pieces I've brought across. What comes across for Maya, for example I'll choose a brick band. Is the object with its model, its materials and anything else we put on, like animations. The materials then are really just the name and whatever diffuse color or texture was applied. In this case for this brick it's just red. I'll select the door panel A I just imported and set the scale factor to one.
Here is scale I'll put one in because I had exported out as meters. For now I will also check generate colliders, when we are optimizing the colliders we may want to go and put box colliders instead of mesh colliders on the door, but for the moment this will work. I will scroll down and click apply, the material is on this object as we can see here in the preview It doesn't show here in the Inspector, but will show up when we drag the prefab into the scene. I'll pull this over by dragging into the hierarchy from the meshes.
I'll make sure that I'll land between objects so that it doesn't get parented, and there's that door. What we can see when we select it here is that this door has a bump defuse on it, because that material had a defuse and normal map. That's how that shader came across. Other materials such as the plaster wall for examples have just a defuse shader. Our defuse shader then is a Lambert shade. It's the equivalent of a Lambert and Maya and functions much the same way. It has no way to shine. And is actually really good in that, because it has no way to shine, it tends to ignore the alpha in a material and also doesn't get excessively bumpy with some normals.
So it's great for things that need to look a little different or slightly different in color because of the surface texture. Without the seeing the drama of a normal. I'll put in the awning to show this further. I'll scroll down here in my hierarchy and make sure I roll up, roll up any other objects that were accidentally open and then I'll drag this object in. I'll drag across and make sure that I go between objects to make sure, so it doesn't automatically parent to something else. There's this awning, and I'll press F to focus in on it.
It comes in where I had placed it in Maya, and I'll pull it out of the wall just a little bit, and look at its materials. This was exported as separate objects within one FBX. This one was called awning, and there's my diffuse shader. It's just got its original texture because it came with it. And that texture is in the textures directory in the assets folder. What I can do in diffuse materials aside from assigning a texture is click on the main color and set this color. I like to switch over to hsv or hue saturation value and move this around.
And this allows me to put a little bit of a color bias into that texture. As you can see when I switch over to blue the entire awning changes. For now though, I'm going to leave this alone with saturation way out and just a little bit of a we'll call it a yellow desert dust in there. Later I can use this to kind of unify my materials. But for now that diffused texture on the yawning is going to look like that canvas, not shine exactly, and be a math material with no excessive drama or texture from a normal map.
- Creating and editing a diffuse material
- Bringing out shine with specular materials
- Building reflective materials
- Creating a custom shader
- Lighting you scene
- Fine-tuning hard and soft shadows
- Color tinting a baked light