I have used many times the tangent space calculations and it has gone well always.
Maybe the trouble is the exporter. the 3DSMAX 3DS exporter has the rare ability of exporting the normals/smoothing groups wrong, while all the other software exports them well (things go worse in home???) If you are using MAX try another format, like OBJ, or X, or B3D if posible. 3DSMAX 2010 exports OBJs very well and the panda X exporter also does a good job.
GLSL shader tangent and binormal calculation bug
What settings did you use for this
I've used several models (copied from RenderMonkey) and all of them have the same problem, it works perfect in RenderMonkey and artifacts in irrLicht.
Code: Select all
irr::scene::IMesh* tangentMesh = smgr->getMeshManipulator()->
createMeshWithTangents(mesh->getMesh(0),
true, // recalculate normals
false, // smooth
false, // angle weighted
true // recalculate tangents
);
Everything with the default options. And yes, it looks quite similar to that case.
This is my code to load that model.
I don't use any option to import that model.
And the Irrlicht version i use is from the SVN (i don't remember which now, but from very little time ago, one month at most.)
The model is exported from 3DSMAX 2010 to an X file with the normals enabled, no optimizations and in binary mode uncompressed. I use the Panda DirectX exporter from here:
http://www.andytather.co.uk/Panda/direc ... loads.aspx
BTW, that is an static model, it has no animation.
This is my code to load that model.
Code: Select all
scene::IAnimatedMeshSceneNode* meshLoaderWritter::loadModel(core::stringc s){
core::stringc currentPath = dev->getFileSystem()->getWorkingDirectory();
irr::scene::IAnimatedMeshSceneNode* model=0;
irr::scene::IAnimatedMesh* LoadedMesh = 0;
irr::scene::IMesh* Tmesh=0;
irr::scene::IAnimatedMesh* AMesh=0;
unsigned int i,j;
if(!smgr->getMeshCache()->isMeshLoaded(core::stringw(s.c_str()))){
LoadedMesh = smgr->getMesh(core::stringc(s.c_str()));
if(LoadedMesh){
Tmesh = smgr->getMeshManipulator()->createMeshWithTangents(LoadedMesh);
smgr->getMeshCache()->removeMesh(LoadedMesh);
}
if(Tmesh){
AMesh = smgr->getMeshManipulator()->createAnimatedMesh(Tmesh);
Tmesh->drop();
if(AMesh){
AMesh->getMesh(0)->setHardwareMappingHint(scene::EHM_STATIC,scene::EBT_NONE);
smgr->getMeshCache()->addMesh(core::stringw(s.c_str()),AMesh);
model = smgr->addAnimatedMeshSceneNode(AMesh,smgr->getSceneNodeFromId(0xFEE00000));
AMesh->drop();
}
}
}else{//The mesh was already there...
AMesh = smgr->getMesh(core::stringc(s.c_str()));
model = smgr->addAnimatedMeshSceneNode(AMesh,smgr->getSceneNodeFromId(0xFEE00000));
}
if(model){
dev->getFileSystem()->changeWorkingDirectoryTo(path);
for(i=0;i<model->getMaterialCount();i++){
model->getMaterial(i).MaterialTypeParam = 192;
model->getMaterial(i).AmbientColor=video::SColor(255,255,255,255);
model->getMaterial(i).AntiAliasing = antialiasing;
model->getMaterial(i).NormalizeNormals = true;
model->getMaterial(i).Lighting=true;
model->getMaterial(i).Shininess = 50;
model->getMaterial(i).setTexture(2,textIO->getTextureFile("nullnormal.bmp"));
model->getMaterial(i).setTexture(4,textIO->getTextureFile("shadowmap"));//The shadowmap rendertaget goes here!
for(j=0;j<8;j++){
model->getMaterial(i).TextureLayer[j].TrilinearFilter = true;
}
}
dev->getFileSystem()->changeWorkingDirectoryTo(currentPath);
}
return model;
}
Code: Select all
if(LoadedMesh){
Tmesh = smgr->getMeshManipulator()->createMeshWithTangents(LoadedMesh);
...
}
The model is exported from 3DSMAX 2010 to an X file with the normals enabled, no optimizations and in binary mode uncompressed. I use the Panda DirectX exporter from here:
http://www.andytather.co.uk/Panda/direc ... loads.aspx
BTW, that is an static model, it has no animation.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt