I'm currently doing a 7-layers material for my shader (OpenGL/GLSL). Here's the Material class code :
Code: Select all
//! Solid 7 layer material renderer
class COpenGLMaterialRenderer_SOLID_7_LAYER : public COpenGLMaterialRenderer
{
public:
COpenGLMaterialRenderer_SOLID_7_LAYER(video::COpenGLDriver* d)
: COpenGLMaterialRenderer(d) {}
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(7);
Driver->setTexture(6, material.getTexture(6));
Driver->setTexture(5, material.getTexture(5));
Driver->setTexture(4, material.getTexture(4));
Driver->setTexture(3, material.getTexture(3));
Driver->setTexture(2, material.getTexture(2));
Driver->setTexture(1, material.getTexture(1));
Driver->setTexture(0, material.getTexture(0));
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
Driver->extGlActiveTexture(GL_TEXTURE2_ARB);
Driver->extGlActiveTexture(GL_TEXTURE3_ARB);
Driver->extGlActiveTexture(GL_TEXTURE4_ARB);
Driver->extGlActiveTexture(GL_TEXTURE5_ARB);
Driver->extGlActiveTexture(GL_TEXTURE6_ARB);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_INTERPOLATE);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PRIMARY_COLOR);
/*glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE3_RGB_EXT, GL_TEXTURE);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE4_RGB_EXT, GL_TEXTURE);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE5_RGB_EXT, GL_TEXTURE);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE6_RGB_EXT, GL_TEXTURE);*/
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA);
}
}
}
virtual void OnUnsetMaterial()
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE6_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
}
}
};
I also did the modifications in the materials enums, and did the "addAndDropMaterial..;" thing (or something like that).
And the problem is that only the 4 first layers are working... Can someone help me?