Game Development Community

Terrain Texture Detail

by George Ison · in Torque Game Engine Advanced · 07/02/2011 (4:28 pm) · 1 replies

Hello all,

I have not worried about this to much up until now since this particular level Im coming to is nearing and end but the problem I seem to have is assigning sound and detail to various textures I have painted across the terrain.

So here's the best way I know to demonstrate the problem using the basics.
Engine Used: TGEA 1.8.2 on Win7 OS
Player Model: Stock Torque Orc (Kork)
Textures: Grass 256x256, Dirt 256x256 and Rock 256x256 all in .png format.
Details: Grassdetail 256x256 and a 256x256 detail for dirt and rock all in .png format.
AllTextureLocation: ~/data/terrains/texTest/

What I want to happen....
I want first and foremost grass to have obviously the grass detail texture and rock and dirt to have the detail texture that corresponds with them.
Secondly, I want grass to make a softer sound than dirt and rock with no footprints or dust trails. I want dirt and rock to have a harder sound with dust and footprints.

What I did to achieve this result...or what I thought should be done??
I created a file called material.cs within the AllTexturesLocation. I made material instances for the textures that I would be or have used to paint the terrain. Mapped these materials to there corresponding textures.
The material.cs file mentioned above contains the following code.

new Material(Grass)
{
mapTo = "Grass256";
//diffuse[0] = "Grass256";
baseTex[0] = "Grass256";
detailTex[0] = "detailgrass256";
detailScale[0] = 256;
bumpTex[0] = "";
//FootstepSoundId = 0; // Soft footstep sound defined on player datablock.
customFootstepSound = FootLightSoftSound;
//ImpactSoundId = 0; // Soft impact sound.
//ShowDust = false; // Don't show dust particles (footpuffs, hover trails, etc.)
//ShowFootprints = false; // But show footprints.
};

new Material(Dirt)
{
mapTo = "dirt256";
//diffuse[0] = "dirt256";
baseTex[0] = "dirt256";
detailTex[0] = "detaildirt256";
detailScale[0] = 256;
//bumpTex[0] = "";
//FootstepSoundId = 1; // Hard footstep sound defined on player datablock.
customFootstepSound = FootLightHardSound;
//ImpactSoundId = 1; // Hard impact sound.
//ShowDust = true; // Show dust particles.
//ShowFootprints = true; // And show footprints.
};

new Material(Rock)
{
mapTo = "rock256";
//diffuse[0] = "rock256";
baseTex[0] = "rock256";
detailTex[0] = "detaildirt256";
detailScale[0] = 256;
//bumpTex[0] = "";
//FootstepSoundId = 1; // Hard footstep sound defined on player datablock.
customFootstepSound = FootLightHardSound;
//ImpactSoundId = 1; // Hard impact sound.
//ShowDust = true; // Show dust particles.
//ShowFootprints = false; // And show footprints.
};

Here is the end result....

First, the details do not apply to any of the textures at all. The only way I can get detail to show up is by manually adding a detail file to the terrain object in the mission editor. This of course only allows for one detail which doesnt work so well if you want your paths to like like dirt instead of grass?

Secondly, sound is only applied to the base texture of the world, meaning the first texture the terrains is covered in, anything thats painted on is totally ignored. So Im constantly getting Hard footsteps even while walking on grass with dust and footprints... :-/

What I would like...?

For someone to please show me the light on what I am obviously overlooking....LOL
Any help you can provide would be greatly appreciated!!!

Thanks!

About the author

Love to engineer and develop just about anything. Our primary focus though is that of computer games and software tools.


#1
07/07/2011 (7:30 am)
Legacy terrains such as that used in TGE & TGEa only allowed one detail texture in total. It's only in Torque3D that the different material layers can have a unique detail texture.

Footstep sounds and dustpuffs are not directly declared through the terrain material like in your example, but through a pseudo material that your terrain material points to.

// This is an example of how to map terrain blend tiles to material
// instances within Torque.  None of these materials will be used
// for rendering, but they will be used by the collision detection
// code and thus play their part in defining interaction behavior
// when coming into contact with these materials.

//-----------------------------------------------------------------------
// Define two material templates...

new Material( TerrainSoft )
{
   FootstepSoundId = 0;       // Soft footstep sound defined on player datablock.
   ImpactSoundId = 0;         // Soft impact sound.
   ShowDust = false;          // Don't show dust particles (footpuffs, hover trails, etc.)
   ShowFootprints = true;     // But show footprints.
};
new Material( TerrainHard )
{
   FootstepSoundId = 1;       // Hard footstep sound defined on player datablock.
   ImpactSoundId = 1;         // Hard impact sound.
   ShowDust = true;           // Show dust particles.
   ShowFootprints = true;     // And show footprints.
};

// If you want custom sound effects for footstep and impact sounds,
// use the 'customFootstepSound' and 'customImpactSound' material properties
// that allow referencing SFXProfiles and will override the Id-based definitions.

// Note that for the footprint and footstep sound stuff to work, you character models
// must define correct triggers (1==left foot, 2==right foot) on their run animations
// (this is currently not the case with some example models coming with Torque).

//-----------------------------------------------------------------------
// Now define a material for each of the blend textures.

new Material( TerrainDirtGrass : TerrainSoft )
{
   MapTo = "dirt_grass";
};
new Material( TerrainGrass1Dry : TerrainSoft )
{
   MapTo = "grass1-dry";
};
new Material( TerrainGrass1 : TerrainSoft )
{
   MapTo = "grass1";
};
new Material( TerrainGrass2 : TerrainSoft )
{
   MapTo = "grass2";
};
new Material( TerrainRocks : TerrainHard )
{
   MapTo = "rocks1";
   
   // Choose a grey-ish particle color for the dust emitters.
   EffectColor[ 0 ] = "0.5 0.5 0.5 1.0";
   EffectColor[ 1 ] = "1.0 1.0 1.0 0.0";
};