Added support for heightmaps in parallax and normal mapping, since that seems to be irrlicht's preferred way to go

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7824 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-03-06 01:13:02 +00:00
parent 9af2cc36eb
commit be60946f28
2 changed files with 27 additions and 3 deletions

View File

@ -93,12 +93,24 @@ Material::Material(const XMLNode *node, int index)
{
m_normal_map = true;
}
else if (node->get("normal-heightmap", &m_normal_map_tex))
{
m_is_heightmap = true;
m_normal_map = true;
}
else if (node->get("parallax-map", &m_normal_map_tex))
{
m_parallax_map = true;
m_parallax_height = 0.2f;
node->get("parallax-height", &m_parallax_height);
}
else if (node->get("parallax-heightmap", &m_normal_map_tex))
{
m_is_heightmap = true;
m_parallax_map = true;
m_parallax_height = 0.2f;
node->get("parallax-height", &m_parallax_height);
}
s="";
node->get("graphical-effect", &s );
@ -224,6 +236,7 @@ void Material::init(unsigned int index)
m_zipper_speed_gain = -1.0f;
m_normal_map = false;
m_parallax_map = false;
m_is_heightmap = false;
for (int n=0; n<EMIT_KINDS_COUNT; n++)
{
@ -426,15 +439,26 @@ void Material::setMaterialProperties(video::SMaterial *m) const
}
if (m_normal_map)
{
m->setTexture(1, irr_driver->getTexture(m_normal_map_tex));
video::ITexture* tex = irr_driver->getTexture(m_normal_map_tex) ;
if (m_is_heightmap)
{
irr_driver->getVideoDriver()->makeNormalMapTexture( tex );
}
m->setTexture(1, tex);
m->MaterialType = video::EMT_NORMAL_MAP_SOLID;
modes++;
}
if (m_parallax_map)
{
m->setTexture(1, irr_driver->getTexture(m_normal_map_tex));
video::ITexture* tex = irr_driver->getTexture(m_normal_map_tex);
if (m_is_heightmap)
{
irr_driver->getVideoDriver()->makeNormalMapTexture( tex );
}
m->setTexture(1, tex);
m->MaterialType = video::EMT_PARALLAX_MAP_SOLID;
m->MaterialTypeParam = m_parallax_height;
m->SpecularColor.set(0,0,0,0);
modes++;
}

View File

@ -84,7 +84,7 @@ private:
/** For normal maps */
bool m_normal_map;
std::string m_normal_map_tex;
bool m_is_heightmap;
bool m_parallax_map;
float m_parallax_height;