I have been having major issues with smooth normals. I mean, the first time I had the issue, I figured out that it was because of the file format (3DS), so I moved to MD2 and it was working well. Now after that with other shaders I was never able to got the smooth normals to work.
I'm using this one:
http://www.irrlicht3d.org/wiki/index.ph ... ByOmaremad
I believe if I solve this one, I'll figure it out permanently. So any help would be appreciated.
Thanks!
Here is what I get in RenderMonkey:
and here is what I get in Irrlicht:
Irrlicht:
Code: Select all
//Shader test
IAnimatedMesh* boxmesh = resourceManager_.getMesh( resourceManager_.loadMeshFromFile(
"root/models/OBJ/ninjaHead.obj" ) ).getRawPointer();
IMesh* tangentMesh = sysInt_.getScene()->getMeshManipulator()->createMeshWithTangents( boxmesh->getMesh( 0 ) );
ISceneNode* boxScene = sysInt_.getScene()->addMeshSceneNode( tangentMesh );
ITexture* colorMap = resourceManager_.getTexture( resourceManager_.loadTextureFromFile(
"root/textures/BMP/VariableSpecular.bmp" ) ).getRawPointer();
ITexture* normalMap = resourceManager_.getTexture( resourceManager_.loadTextureFromFile(
"root/textures/TGA/ati.tga" ) ).getRawPointer();
boxScene->setMaterialTexture(0, colorMap);
boxScene->setMaterialTexture(1, normalMap);
// boxScene->setScale( vector3df( 1.7, 1, 1.7 ) );
// boxScene->setMaterialFlag(EMF_NORMALIZE_NORMALS, true);
boxScene->setPosition( vector3df( 2002.71f, 170.0f, 2294.66f ) );
boxScene->setMaterialType( (irr::video::E_MATERIAL_TYPE)( fxCompositor_.getEffect( FXCompositor::DIFFUSE_ENV_SPECULAR ) ) );
Code: Select all
VEC3D lightPos( 80, 85, 100 );
VEC3D viewPos( SystemInterface::getInstance().getScene()->getActiveCamera()->getAbsolutePosition() );
core::matrix4 world = driver_->getTransform( video::ETS_WORLD );
world = world.makeInverse();
world = world.getTransposed();
services->setVertexShaderConstant("matWorldInverseTranspose", world.pointer(), 16);
services->setVertexShaderConstant("fvLightPosition", reinterpret_cast<f32*>(&lightPos), 3);
services->setVertexShaderConstant("fvEyePosition", reinterpret_cast<f32*>(&viewPos), 3);
VEC4D fvLowTone(1, 1, 1, 1);
VEC4D fvSpecular(1, 1, 1, 1);
VEC4D fvHighTone(1, 1, 1, 1);
float fSpecularPower = 23.94250f;
int var0=0;
services->setPixelShaderConstant("baseMap", (float*)(&var0), 1); //the colormap
int var1=1;
services->setPixelShaderConstant("cube", (float*)(&var1), 1); //the cubemap
services->setPixelShaderConstant("fvLowTone", reinterpret_cast<f32*>(&fvLowTone), 4 );
services->setPixelShaderConstant("fvSpecular", reinterpret_cast<f32*>(&fvSpecular), 4 );
services->setPixelShaderConstant("fvHighTone", reinterpret_cast<f32*>(&fvHighTone), 4 );
services->setPixelShaderConstant("fSpecularPower", reinterpret_cast<f32*>(&fSpecularPower), 1 );