Normal Map,Diffuse Map, and adding material?
by Nick Gingerella · in Torque Game Engine Advanced · 02/14/2009 (4:10 pm) · 3 replies
Hey guys, I've been reading this little guide that I got off a friend a while ago, I've been looking into creating nice looking textures for my terrain, thats when I ran into the concept of diffuse and normal maps. Now after reading about how to make a normal map using photoshop for a regular diffuse(it says that diffuse is a fancy word for full color) texture, it said something about adding the material via the materials.cs,the only place I found that is in the game/scriptsandassets/data/terrains/ (and there is also a materials.cs file in the terrains/test/ folder as well.
heres the script that the guide gave me to add
-----------------------------------------------------------------------
1.Creating better normal maps
Before applying the normal map plugin on a plain diffuse texture, desaturate a bit the image and remove any
unwanted noise or bits you won't need. Apply the plugin and look at the result: not much of a normal map there.
From here on we have two options:
1. Duplicate the layer and set the blending mode to overlay at 50% transparency. Apply a gaussian blur to this
layer. Then multiply it several times.
2. Edit the materials.cs file
Now that we have the textures lets set out and write the material.cs entry.
new Material (material_rockgrass)
{
mapTo = "rockgrass"; // this is the diffuse texture the material is mapped to. commonly mistaken with the dts object.
baseTex[0] = "rockgrass"; // this is the diffuse texture
bumpTex[0] = "rockgrass_normals";// this is the normal map texture
translucent[0] = false; // if the diffuse texture has an alpha channel this is required to tell the engine not to use the
alpha mask for transparency but for specularity control
pixelSpecular[0] = true;
specular[0] = "0.2 0.2 0.2 1.0"; // lower the numbers for a less shiny surface
specularPower[0] = 32.0;
};
For transparent materials (foliage stuff) here is an example that works fairly well.
new Material(material_leaf)
{
mapTo = "leaf.png";// this is the diffuse texture the material is mapped to. when exporting from Maya it is required to add the
file extension (ie .png)
baseTex[0] = "leaf"; // this is the diffuse texture; usually a png or a dds with alpha channel
translucentZWrite = true;
translucent = true;
translucentBlendOp = LerpAlpha;
alphaTest = true; // default value
alphaRef = 150; // alpha less than 128 in brightness (255 is max) will not be rendered
};
Could anyone possibly elaborate onto to this for me, it would be really helpful, and a little more info as to what benefit, if there is one that doing all of this would offer.
thanks in advance
heres the script that the guide gave me to add
-----------------------------------------------------------------------
1.Creating better normal maps
Before applying the normal map plugin on a plain diffuse texture, desaturate a bit the image and remove any
unwanted noise or bits you won't need. Apply the plugin and look at the result: not much of a normal map there.
From here on we have two options:
1. Duplicate the layer and set the blending mode to overlay at 50% transparency. Apply a gaussian blur to this
layer. Then multiply it several times.
2. Edit the materials.cs file
Now that we have the textures lets set out and write the material.cs entry.
new Material (material_rockgrass)
{
mapTo = "rockgrass"; // this is the diffuse texture the material is mapped to. commonly mistaken with the dts object.
baseTex[0] = "rockgrass"; // this is the diffuse texture
bumpTex[0] = "rockgrass_normals";// this is the normal map texture
translucent[0] = false; // if the diffuse texture has an alpha channel this is required to tell the engine not to use the
alpha mask for transparency but for specularity control
pixelSpecular[0] = true;
specular[0] = "0.2 0.2 0.2 1.0"; // lower the numbers for a less shiny surface
specularPower[0] = 32.0;
};
For transparent materials (foliage stuff) here is an example that works fairly well.
new Material(material_leaf)
{
mapTo = "leaf.png";// this is the diffuse texture the material is mapped to. when exporting from Maya it is required to add the
file extension (ie .png)
baseTex[0] = "leaf"; // this is the diffuse texture; usually a png or a dds with alpha channel
translucentZWrite = true;
translucent = true;
translucentBlendOp = LerpAlpha;
alphaTest = true; // default value
alphaRef = 150; // alpha less than 128 in brightness (255 is max) will not be rendered
};
Could anyone possibly elaborate onto to this for me, it would be really helpful, and a little more info as to what benefit, if there is one that doing all of this would offer.
thanks in advance
About the author
#2
02/15/2009 (6:52 am)
Yep, fireVein is correct. The Terrain uses the terrain shaders, and unless you add normal map support to that shader it won't show on the terrain.
Torque Owner Jason "fireVein" Culwell
Like I said, I could be wrong, so hopefully someone else will chime in here to clarify this.