1 - Unzip Official Irrlicht 1.7.1 package
2 - Change irrCompileConfig.h to support 8 layers:
Code: Select all
#define _IRR_MATERIAL_MAX_TEXTURES_ 8
when i try to set the fourth layer (using GLSL) the mesh is rendered with no texture (just black).
here's my code:
Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
class MyShaderCallBack : public video::IShaderConstantSetCallBack
{
public:
virtual void OnSetConstants(video::IMaterialRendererServices* services,
s32 userData)
{
int d[] = {0, 1, 2, 3, 4}; //Sampler2d IDs
services->setPixelShaderConstant("myTexture",(float*)&d[4],1);
}
};
int main(int argc, char** argv)
{
IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<u32>(640, 480), 16, false, false, false, 0);
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
ISceneNode* node = smgr->addCubeSceneNode(10);
MyShaderCallBack* mc = new MyShaderCallBack();
static s32 material=smgr->getVideoDriver()->getGPUProgrammingServices()->addHighLevelShaderMaterialFromFiles(
"shader.vert", "vertexMain", video::EVST_VS_3_0,
"shader.frag", "pixelMain", video::EPST_PS_3_0,
mc, video::EMT_SOLID);
node->setMaterialTexture(0,driver->getTexture("L0.png"));
node->setMaterialTexture(1,driver->getTexture("L1.jpg"));
node->setMaterialTexture(2,driver->getTexture("L2.jpg"));
node->setMaterialTexture(3,driver->getTexture("L3.jpg"));
node->setMaterialTexture(4,driver->getTexture("L4.jpg"));
node->setMaterialFlag(EMF_LIGHTING,false);
node->setMaterialType((E_MATERIAL_TYPE)material);
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
while(device->run())
{
driver->beginScene(true, true, SColor(0,200,200,200));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
Code: Select all
void main(void)
{
gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
}
Code: Select all
uniform sampler2D myTexture;
void main (void)
{
gl_FragColor = texture2D(myTexture, vec2(gl_TexCoord[0]));
}
PS: OpenSUSE 11.2 + OpenGL 3.2.0 + GLSL 1.5 on Nvidia 9500M GS.