Improve splatting

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10283 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-11-30 19:34:37 +00:00
parent 47d0e01f12
commit 8799b3ca3b
3 changed files with 42 additions and 4 deletions

View File

@ -3,12 +3,18 @@
uniform sampler2D tex_layout;
uniform sampler2D tex_detail0;
uniform sampler2D tex_detail1;
uniform sampler2D tex_detail2;
uniform sampler2D tex_detail3;
void main()
{
vec4 layout = texture2D(tex_layout, gl_TexCoord[0].st);
vec4 detail0 = texture2D(tex_detail0, gl_TexCoord[1].st);
vec4 detail1 = texture2D(tex_detail1, gl_TexCoord[1].st);
gl_FragColor = layout.r * detail0 + (1.0 - layout.r) * detail1;
vec4 detail2 = texture2D(tex_detail2, gl_TexCoord[1].st);
vec4 detail3 = texture2D(tex_detail3, gl_TexCoord[1].st);
gl_FragColor = layout.r * detail0 +
layout.g * detail1 +
layout.b * detail2 +
(1.0 - layout.r - layout.g - layout.b) * detail3;
}

View File

@ -87,6 +87,14 @@ public:
// Irrlicht knows this is actually a GLint and makes the conversion
int tex_detail1 = 2;
services->setPixelShaderConstant("tex_detail1", (float*)&tex_detail1, 1);
// Irrlicht knows this is actually a GLint and makes the conversion
int tex_detail2 = 3;
services->setPixelShaderConstant("tex_detail2", (float*)&tex_detail2, 1);
// Irrlicht knows this is actually a GLint and makes the conversion
int tex_detail3 = 4;
services->setPixelShaderConstant("tex_detail3", (float*)&tex_detail3, 1);
}
};
@ -218,6 +226,8 @@ Material::Material(const XMLNode *node, int index)
{
node->get("splatting-texture-1", &m_splatting_texture_1);
node->get("splatting-texture-2", &m_splatting_texture_2);
node->get("splatting-texture-3", &m_splatting_texture_3);
node->get("splatting-texture-4", &m_splatting_texture_4);
}
// Terrain-specifc sound effect
@ -660,9 +670,25 @@ void Material::setMaterialProperties(video::SMaterial *m)
{
ITexture* tex = irr_driver->getTexture(m_splatting_texture_1);
m->setTexture(1, tex);
tex = irr_driver->getTexture(m_splatting_texture_2);
if (m_splatting_texture_2.size() > 0)
{
tex = irr_driver->getTexture(m_splatting_texture_2);
}
m->setTexture(2, tex);
if (m_splatting_texture_3.size() > 0)
{
tex = irr_driver->getTexture(m_splatting_texture_3);
}
m->setTexture(3, tex);
if (m_splatting_texture_4.size() > 0)
{
tex = irr_driver->getTexture(m_splatting_texture_4);
}
m->setTexture(4, tex);
if (m_splatting_provider == NULL)
{
m_splatting_provider = new SplattingProvider();

View File

@ -170,7 +170,13 @@ private:
/** If m_splatting is true, indicates the second splatting texture */
std::string m_splatting_texture_2;
/** If m_splatting is true, indicates the third splatting texture */
std::string m_splatting_texture_3;
/** If m_splatting is true, indicates the fourth splatting texture */
std::string m_splatting_texture_4;
/** Only used if normal maps are used */
NormalMapProvider* m_normal_map_provider;