Material Editor - Creating New Materials and Overlays [Calibas Tutorials #6]

edited March 2016 in Tutorials

In this tutorial I'll go over how to create new materials for your custom game type using the Material Editor. I'll also cover how to use materials as overlays and how to add translucency.

enter image description here

While I'm only going to be using materials to apply new texture to meshes in this tutorial, understand that materials are much more than just textures. The core of each material is a shader, which can be used for special visual effects like ice and water, among many other uses.

First, launch the Material Editor, and you can do that through the Assets Browser or through the tools button in Hammer. Hit the New button, then the Save button, and I'm going to name my new texture bricks.vmat.

I'm going to use a brick texture that I found here, but I'll need to modify it some before I can use it in the material editor. The dimensions of an image file must be a power of two (2, 4, 8, 16, 32, 64, 128, 256, 512...), otherwise it wont work, so I've resized the image to 256 x 128 pixels. Here's what it looks like now, and you can download this image to use in your material.

enter image description here

You'll need to place the image file within your addon's content folder before using it, and you can find the location of the folder by selecting one of your addon's files within the Asset Browser and checking the Content File field. On my computer, which is running Win 7, the folder is located at C:\Program Files (x86)\Steam\steamapps\common\dota 2 beta\content\dota_addons\your_addon_name

There should be a materials folder there already, and you can drop the bricks.jpg image within so you'll be able to load it in your mod. If you did it correctly, bricks.jpg should now appear within your Assets Browser, though you may need to refresh the Assets Browser before it appears.

Switch back to the Material Editor and look for the area labelled Color. If you don't see it, make sure you're using the "Global Lit Simple" shader. Click the folder icon within the Color area to open a file browser, switch to "All Images" instead of "Images", and double-click on bricks.jpg. You should now see the brick texture within the preview pane and you can switch between a sphere, a cube and a flat plane there to see how it looks on each.

enter image description here

At the moment, the texture is a bit larger than I want it to be, so I'm going to increase both Text Coord Scale fields from 1.000 to 10.000, which will make the texture ten times smaller. Make sure to save the material and now I'll load up Hammer to use it to create a brick wall.

Use the Block Tool to create a long, skinny mesh, and then while it's still selected click on bricks.vmat within the Assets pane. If you had Hammer open while you were working on the material, you may need to restart Hammer before the new material appears.

enter image description here

That's it for creating and using a new material, but it's just the tip of the iceberg as far as what you can do with materials. If you really want to get fancy, you can do things like normal mapping, which can make flat textures appear 3d, or use Scroll UV to animate the texture.

Now I'll cover how to make an overlay, which is only marginally more difficult that what I've already covered. Create a new material just like before and save it, I'm naming mine grass.vmat. I found a grass texture I want to use here, then I cropped and resized it to 512 x 512 pixels. Here's the texture file, and you'll want to place it in your materials folder:

enter image description here

Note that this time I changed the file name to grass_color.jpg. Adding "_color" to the file name makes things easier as the Material Editor looks for those files first. Probably a good idea to name things that way from here on out.

So in the Material Editor, load this grass texture as the Color, then within the shader settings, which is the pane to the left, click the Overlay checkbox (you may need to scroll down some to see it). At this point, you've technically done everything needed to create a new overlay, so if you save it and reload Hammer, you'll see it in the overlay area. However, I want to make the edges translucent first so it blends better with other textures.

Making translucent (aka semi-transparent) materials works essentially the same way that masking does in Photoshop. You use a black and white image with the same dimensions to "map" the translucency. A white pixel means that part of the texture is completely opaque, a black pixel means it's transparent there, and a grey pixel means it's translucent. If you don't know what those terms mean, you can read this.

Here's the image I'm going to use, and I've named it grass_trans.jpg. The "_trans" at the end is the default suffix that the Material Editor uses for transparencies:

enter image description here

Save that file to your materials folder just like with the other images. Next, return to the Material Editor, and click the Translucent checkbox. It should use grass_trans.jpg automatically, but if it doesn't you can click the folder icon in the Translucency section and select the file that way.

Save your new material, and you should now see it within the Overlays list in Hammer (you may need to reload Hammer).

enter image description here

Here's another quick example of an overlay, and with this example I've saved the image files using the png-24 format. It's a lossless format, so it's usually a better choice than using jpeg images. I also ended up having to flip the text to get it to display correctly in Hammer. There may be a better way of doing it, but this was the only way I could figure out that worked. Here's d4l_color.png and d4l_trans.png, you can use them to create a new overlay just like before.

enter image description here

enter image description here

And here's how it looks on the brick wall we created earlier:

enter image description here

That's it for the basics of creating new materials and overlays. If you want to get fancy and do things like animated textures, check out Dynamic Material Expressions.

This part of a series of 7 tutorials that are designed to help the beginner get familiar with the Workshop Tools and they end with showing how to write a very simple script.

1. Getting Started, Your First Dota 2 Addon

2. Creating A Basic Dota-style Map

3. Level Design - Adding Terrain & Decorations

4. Level Design - Tilesets, Material Sets & Transitions

5. Level Design - Meshes & Materials

6. Material Editor - Creating New Materials and Overlays

7. Scripting - Basics

Comments

  • bpebpe
    Posts: 4

    Perhaps just an issue with the older build but you can flip the image to face the camera correctly, just use Microsoft paint.

  • Can Overlays be painted just like painting regular stuff like terrains and paths in the tile editor? i thought ill use it to make a glacier.