I'm trying to create an initial material for the terrain. In the demo, in the createScene method, you have:
Code: Select all
MaterialPtr material (MaterialManager::getSingleton().getByName("ETTerrainMaterial"));
mTerrainMgr->setMaterial(material);
In my scenario, the user will choose to create a terrain, and will supply:
1) either defaultHeightmap or .raw file
2) terrain dimensions, ie 1500,300,1500 by default
3) choose a base splatting texture for the entire terrain
So the process is that when you create a *terrain* object, you also create a default material. This material will by default be configured with the baseTexture chosen by the user. The problem is, I'm not sure how to create this default material.
Here is my starting code:
Code: Select all
void Terrain::createNewMaterial(const Ogre::String& name, const Ogre::String& baseTexture)
{
mTerrainMaterial = Ogre::MaterialManager::getSingleton().create(name,"Terrain");
Ogre::Technique* t = mTerrainMaterial->getTechnique(0);
Ogre::Pass* p = t->getPass(0);
p->setLightingEnabled(false);
p->setVertexProgram("ET/Programs/VSLodMorph2");
p->setFragmentProgram("ET/Programs/PSSplat2");
}
The first problem is that I don't know how to set the FragmentProgram parameters. Also, if I tell the splatting manager to setNumTextures to 1, it will create a coverage map.. do I need to write this map out to file, and then add it to the material via createTextureUnitState?
ETTerrainMaterial:
Code: Select all
pass
{
// splatting pass
lighting off
vertex_program_ref ET/Programs/VSLodMorph2
{
}
fragment_program_ref ET/Programs/PSSplat2
{
param_named splatScaleX float 20
param_named splatScaleZ float 20
}
texture_unit
{
// first coverage map, dynamically managed
texture ETSplatting0
}
...
Thanks in advance,
KungFooMasta