Painting detail meshes
Video: Painting detail meshesPainting detail meshes provides you with in-depth training on 3D + Animation. Taught by Adam Crespi as part of the Unity 4.3 Essential Training
- Next steps
Viewers: in countries Watching now:
Painting detail meshes provides you with in-depth training on 3D + Animation. Taught by Adam Crespi as part of the Unity 4.3 Essential Training
Interested in game making? Start in Unity—a game engine for mobile and desktop games and real-time simulations. Author Adam Crespi shows techniques used in game development with Unity and introduces the basics of scripting and game functionality. First, learn how to import models and textures, organize your project and hierarchies, and add terrain, water, and foliage. Next, Adam explores how to use lighting to bring the game to life, and add rendering, particles, and interactivity. The end result is a sample game with a lush environment, fully animated characters, and some basic interactive gameplay.
- Designing the game
- Creating and transforming objects
- Importing and configuring models and textures
- Setting properties in the Inspector
- Creating the terrain geometry
- Building materials and adding shaders
- Creating GameObjects
- Exploring physics
- Animating objects
- Lighting the scene
- Creating 2D game elements
- Adding special effects
Painting detail meshes
When you’re painting a landscape, one of the greatest things that you can do, is make your own pieces. We need trees, we need grass, we need rock and we need things in the landscape. Other species of plants for example, or other things that are scattered around. And in Unity, these are called Detail Meshes. We’ll use them in the same way, brushing them onto the landscape. But they can be meshes, that are more dimensional. What I've done is to model out some quick cattails. I've used a combination of bent planes and bent planes that are crossed.
They look like fluffy hot dogs on sticks and they've got some leaves that are bent at the end. This is a quick model I put together in Maya. And then, I've exported it out as an fbx and dropped it in the meshes folder in my Unity assets. I'll go over Unity and show how to bring this in as a custom detailed mesh to paint on. Here in Unity because I've dropped that cattails fbx into the meshes folder in my assets folder it automatically imported. I did this one in centimeters and so I'm going to leave the scale factor at 0.01 so it doesn't make giant cattails all over the landscape.
I'm not going to save any light map UVs in this one as its going to be lit differently. A light like the grass where its somewhat we call it self illuminating but that's not quite the right term. But really it doesn't respond to the lighting in quite the same way. It also doesn't need any colliders as I'm not really going to wade through these. Now I'll get a material on. It came in with a material from the fbx called cattails. And this is a basic transparent diffuse. Where the Alpha Channel triggers the material to be transparent, roughly around the cattails themselves and their fluffy seed buds.
I'm going to switch this material, dropping down the shader here from Transparent Diffuse and choosing, Nature. And, I'll use the Tree Creator Leaves Fast. These are special shaders here for nature that are made for the purpose of being sprayed around. And they've got a main color as well as a texture we can put in with an Alpha and an Alpha Cutoff. This is primarily made for leaves. So there's a real difference in the Alpha between black not-leaf and white leaf and not much gray or fuzziness in the difference.
The Translucency Color then allows us to have the idea of translucency when it is backlit. That is, if we're looking through this and the sun is on the other side, it will go translucent in this color. It's not quite a full sub-surface scatter but it's definitely an improvement over rendering really dark. And so it looks like it's well, translucent plant material. I'm going to leave this alone for now and I'll see how it looks and if I need to adjust anything. I think it'll be pretty reasonable. I may end up taking down the shadow strength only because these are going to shadow on everything else, and probably won't need much of a shadow at all.
I'll take this material and rename it, though, and move it over to my materials folder. Remember, we should always stay organized. Even if it seems like the tiniest detail. I've renamed that material cattails and I'll drag it into the materials folder. Then here in the meshes folder, I'll delete that materials folder. And now I'm ready to put these in. I'll take my cattails and put them into the scene, much like I did the tree. I'll put this one way over on the other side, where I'm never going to see them. Zooming in on that lone tree out on the flat plane and pulling in the cattails into my plant making place.
There's my cattails. I'll focus in and see how they look. They look good so far. The cross plains hold up nicely and I think they look like, well cattails. Now I'm ready to get these in the scene. What I'll do is to select that terrain, press f to focus and zoom back in on the lake. By the way, if you press f to focus and you say, wait a sec, that really isn't the area that I'd like to look at, try picking something else. I'll pick my plane here, that's my water, and then use that to zoom in on. Sometimes focusing on the terrain throws Unity a little bit and has a little trouble keeping pace and finding the right place.
I'll zoom in so I can see the grass I put in earlier. And I'm ready to spray in the cattails. I'll select the terrain once more and go into the Detail Mesh section. In the Paint Details we have our standard brushes. And I've already got the grasses, I put in earlier. I'll click Edit Details > Add Detail Mesh. The difference between the two is that a grass texture then is really a flat plane and a wavelike grass. Whereas, a detail mesh allows you to select a custom object and spray it around. It can be a more dimensional object. You could even have detail rocks, for example, if you needed to make a boulder strewn landscape.
I'll use my cattails, selecting Add Detail Mesh. And in the Add Detail Mesh section, I'll pick that GameObject. I'll make sure I'm selecting from the scene, and there's cattails. Those ones I dragged in out by the tree. In the Detail Mesh, we have a healthy color and a dry color. And that healthy color would make my cattails neon green and rather odd looking. So what I'll do is take that healthy color and grey it out. I'll leave some green in, but otherwise I'm going to let it be a really muted grey. I'll also take the dry color and do the same.
I don't want these to run to yellow as much as, well neutral grey-brown. Maybe I'll even bring a little more green in. So that there's always some version of green in there and kind of contrasting with any grass that's dried out. I'll leave the render mode as grass. Now I've got a random width and height to deal with. And I'll put the random width and height at, let's try a 1.1. Just so it varies a little bit. I'll click Add and my cattails should be ready. I'll try it out working with a small brush starting out with a soft brush and looking at the brush size.
I'll try a brush size of ten and brush in some cattails. It seems to be working although they are kind of small. I'd like to fix this and so what I'll do is to fix it by editing that Detail Mesh. Back here in Edit, I'll put up that random width and height. I'll try three and three. And they seem to stick up nicely. I'll click Apply and brush in some more. I'll put a few of these down by the waters edge. Move around to another place, spray in a couple more. Lower the opacity on that brush considerably.
Almost to nothing 0.01. And this way when I spray, I just get a few in here to stick up. I don't want a giant, intrusive flock of them as much as a few of them in the reeds here and there. And I'll put them down by the water's edge, and even some of them in the water. I'll spin around, make sure I'm in on the grass, land a few more in there, and populate with the cattails. It's that easy. You can make a detail mesh, or even multiple detail meshes, and spray them around.
And really fill out that terrain nicely. I'll leave some of them in the water but some I'll go back and erase in the same way. These that are just barely sticking out of the surface need a little work. So I'll hold Shift and just take them out. But I'll leave some of the ones that are sort of in the marshy edge alone. I'll spin around more to the more grass. Spray in a few more, kind of stay on the dirt and see if any of them need a little pick up here and there. And, I've got cattails. I'll erase some that are too deep in the water and keep going.
It's pretty easy to make a detail mesh and to simply land it where you need. And it can really help fill out a landscape. What we expect to see when we're making a landscape are usually multiple species. And they kind of commingle in a lot of places. Now, some places may be a little more monospecies. Things like a birch forest or a pine forest. Places where the conditions or the plants drive out other species. And you may not need as much of the detail mesh of another plant. But that's a great place to use a detail mesh of something different.
Maybe clumps of leaves or rocks or fallen bark or whatever it is that really help fill out your scene. I've got my cattails in and I'll give it a quick play test to see how noticeable they are. One of the things I'll do before I hit play, is to go into my game window and choose Maximize on Play. And that way I can see it full screen. Now that I'm playing running around the building, through the wall, out onto the water I can see my cattails. And they're waving in the wind with the grass. It holds up pretty nicely. I haven't really adjusted the wind much.
They do kind of sway quite a bit. Primarily because they're reacting as a grass. However, they look good. They stick out. Their shapes are clearly visible. They've turned, rotated and scaled randomly. So they all look different even though it's one model. And I have a custom detail mesh in my scene.
There are currently no FAQs about Unity 4.3 Essential Training.