Materials give an appearance to objects, and also allows us to use textures, so objects can have colors and lots of details. Without a material, objects would look absolutely black in the engine.
- Diffuse Textures
- Normal Maps
The Diffuse Texture, also called Diffuse Color, defines the color of an object's surface. It's the most basic and most used material channel. A lot of 3D games even use only this type of textures, with no lights. Let's look a comparison with a plain material, another with diffuse color and no lights, so you can understand what it is. The left image is the solid model, with a plain color material. The middle one is only the diffuse color texture applied to the model, in “shadeless” mode (no lighting effects, only pure color of the texture), and the right image has the material, with the diffuse texture and lights.
The diffuse texture is an image that gets projected over the 3D model. This image can be in several known and extended image formats, as .jpeg, .png or .tga. They're usually squared and the size should be a power of two measure: 128×128, 256×256, 512×512, 1024×1024…
Other type of textures (like specular, normal…) give a different appearance or effects to the object surface's material, but this one (diffuse) is probably the one that defines the most the character, as it provides it with color, shapes and details. Also, if this texture is done accordingly, it can look good even without lights. All of the first videogames in 3D didn't support dynamic lights at all, so everything was only diffuse textures!
Now let's see how to set it up in the material, so it gets exported in the .EAD file (it won't actually be exported, but the material will keep the filename of this texture, so when the image is introduced in the correct folder of the Engine, the model will take it, as its defined in the material). We select the material slot and add a name to the material. In the Diffuse Channel we can pick a plain color, or clicking on the slot, a popup will show. Into this popup we have to decide the type of texture we'll add to the Diffuse Channel, in this case it's a bitmap, so double click over Bitmap, and select a picture from the hard drive.
Now in the material slot we already see the texture projected over the sphere. Click “go to parent” to see the general parameters of the material. Click “Show Standard Map in Viewport” to be able to see the textures on the real-time viewport, and finally, assign the material to the selected objects. Done!
You can also check the basic tutorial about creating a scene to export to learn the basics.
You can use transparency in your models, using a mix of tecniques:
- .png or .tga diffuse texture containing alpha information.
- Setting the Material's opacity to 99%, so this parameter activates the transparency in the Engine.
- .cfg file (this is a text file that goes with the texture with some written parameters about the material, leaf to the .cfg documentation to learn about them).
- Currently, if you have an object including transparency, it should be a separated object with it's own texture. If transparent objects and solid ones are mixed you may experience some issues when the Engine will draw the models
TEXTURE WITH ALPHA CHANNEL
You need a texture with transparency to use this feature. Sometimes, in 3D software you need to add a greyscale texture that would make the black parts look transparent and white ones opaque. But for optimization, we're using this alpha image into the diffuse texture, in the shape of a .png with alpha image, for example (.tga is also supported). Just add this image as the Diffuse Texture, and that's it!
If you work with Photoshop, Gimp or similar Image Editors, they will let you see some kind of checkboard behind the image in the transparent part. That is how you know an image has alpha information. Either you have transparent parts in the image or not, .png images will include that channel, so it's not something complex to achieve.
3DS MAX MATERIAL
In 3Ds Max, you need to set the material's opacity value to 99%. This will activate transparency detection in the engine. Using inferior values, like 50% will also make the whole material transparent, whithout the need of a transparent texture as the diffuse channel. This is how it's done:
After exporting the material, once you take a diffuse texture and place it in the Engine's folders, you'll need to add a .cfg file with the same filename as the diffuse texture, so it's interpretated by the engine as information for that specific texture. The .cfg file contains several parameters that allow you to play with some material related stuff. One of them is transparency. Check .cfg documentation to learn more about them.
The Engine supports cube map reflections. Keep this in mind when you're going to use them:
- The whole material will be reflective, so make sure that you have separate objects with an specific material that will get reflections.
- Into the Textures folder near the .EAD files, you'll need to create a folder named “Reflections” in which you'll place the cube map reflection images.
- Reflection channel needs to be activated into the material.
- We need to use a .cfg file that will define the ammount of reflection the material will have, and the location of the reflection images.
SETTING UP REFLECTIONS IN 3DS MAX
The first thing we need to do when we want to use reflection, is to activate the Reflection channel in the material: We go into the “Maps” Tab, activate reflection, and introduce any map to it. Doesn't matter which texture we insert here (you can create a placeholder texture, and duplicate it everytime you need reflections with a different name), is just for the Engine to detect that there is a reflection going on in this material, as ultimately, it will pick the reflection images that are stated into the .cfg file.
CUBE MAP REFLECTION IMAGES
The cube map is made up from 6 textures, one for each face of a cube, as if we took photos from a 360º scenery, and each side was projected in the corresponding cube's face. If you want to learn how to generate your own cube maps, watch this section of the documentation.
SETTING REFLECTIONS FOR THE ENGINE
Once we have the cube map images for the reflection, we should set them to work in the Engine:
- Create a folder with the reflection images (usually inside a folder called “reflections” into the “textures” folder of the Engine.
- Add a .cfg file with the name of the texture you picked up for the reflections in the 3Ds Max material. This .cfg will contain the folder structure and name of the reflection images to look for them. Check the .cfg documentation for more info about this.
In realtime models we have limited polycounts. We should keep our models lowpoly, specially in mobile platforms. Normal maps allow us to emulate really highpoly models using lowpoly ones. The procedure is as follows:
- We create a highpoly model.
- We create a lowpoly one based on the highpoly one.
- We bake normal maps, to project the normal maps from the highpoly to the lowpoly model.
Normal maps use RGB channels to provide normal information. In a 3D model, each face or polygon has a normal, which is like a perpendicular line that tells the software in which way the light should reflect in that particular face. A normal map allows us to provide that information on each pixel of a texture, instead of a face, being able to emulate a complex surface into just one face, and it will react on lighting conditions. The lowpoly model (1) has only a few faces, while the highpoly one (2) has millions of faces. Using normal maps we can emulate the highpoly detail into the lowpoly one (3). It's not as accurate as having real polygons, but generally works pretty good, and the performance is much better, as we have a really light model, instead of a very heavy one.
At the left side of this text you can see how a normal map looks like. They are generated in 3D softwares, placing a highpoly and a lowpoly versions of the same model in the same place, so the software generates this RGB image based on the distance and normals orientation of the highpoly model to the lowpoly one on each pixel.
A normal map tells the light how to react, based on the RGB stored on it: each color channel in the map makes the ligh reflect in a given direction, like Blue = Depth; Red = Left/Right; Green = Up/Down.
This technique completely changed the way videogames and even movies are made since a few years ago. We need to keep in mind that this maps change the way lights affect a model, then we need lights in our scene. Otherwise this technique won't have any effect at all over the model.
SETTING UP NORMAL MAPS IN 3DS MAX To use normal maps in the Engine, we need first to set them up into 3Ds Max. We select the material, and add the normal map image to the “Bump” channel: The workflow isn't the same that for using normal maps in 3Ds Max, we just need to add the bitmap texture to the “Bump” channel. This will make the Engine recognize that texture as a normal map. The channel value (30 by default) isn't important either: the Engine will always use the normal map at 100% of its value.