Hi,
I tried to aplly a normal map to a model I exported in .x from blender but when I try to render the object with the normal map I obtain messed up results:
[img=http://img410.imageshack.us/img410/222/sanstitregs2.th.jpg]
When I move the camera, the normal information seems to slide over the mesh (you can see the eye below its actual place)
I saw somewhere that when a normal map is rendered with an inappropriate coordinate system, it can cause this kind of bug but in blender 2.45 there's only one way to bake normal map so I don't really know what it means.
since this normal map would greatly improve the visual quality of my model, any help or suggestion will be greatly appreciated
normal maps problem
normal maps problem
Irrlicht noob =p
Without seeing the code my best guess would be that you didn't generate tangents for the mesh, look at tutorial 11, like hybrid said, for a full example.
"Surely we don’t need to waste resources on pathfinding; they just need to walk along the shortest route from one place to another." - EA Producer
I did try to make a tangent mesh like the tutorial but the result is even worse :
[img=http://img129.imageshack.us/img129/5297/sanstitrehi8.th.jpg]
Here is the code (I removed some part of it, not important for normal mapping):
I'll try to do this with a very simple mesh, just in case...
[img=http://img129.imageshack.us/img129/5297/sanstitrehi8.th.jpg]
Here is the code (I removed some part of it, not important for normal mapping):
Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#pragma comment(lib, "Irrlicht.lib")
IMeshSceneNode* fixednode = 0;
IrrlichtDevice *device = 0;
int main(void)
{
device = createDevice(EDT_OPENGL,
dimension2d<s32>(1024, 768), 16, false, false, false, &receiver);
device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
guienv->addStaticText(L"test import .x", rect<int>(10,10,200,22), true);
IAnimatedMesh* mesh = smgr->getMesh("../model/mycharacter.x");
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
scene::IMesh* tangentMesh = smgr->getMeshManipulator()->createMeshWithTangents(mesh->getMesh(0));
fixednode = smgr->addMeshSceneNode(tangentMesh);
fixednode->setMaterialTexture(1, driver->getTexture("../model/normals2.png"));
if (fixednode)
{
fixednode->setMaterialFlag(EMF_LIGHTING, true);
fixednode->setMaterialFlag(EMF_BACK_FACE_CULLING, false);
fixednode->setMaterialType(video::EMT_PARALLAX_MAP_SOLID);
}
ILightSceneNode *light = smgr->addLightSceneNode(0, vector3df(0,0,50), SColorf(0.5f, 0.5f, 0.5f, 0.1f), 600.0f);
ISceneNodeAnimator* anim = smgr->createFlyCircleAnimator(vector3df(0,-40,50), 20.0f);
light->addAnimator(anim);
anim->drop();
light = smgr->addLightSceneNode(0, vector3df(0,40,0), SColorf(0.2f, 0.2f, 0.2f, 0.1f), 600.0f);
ICameraSceneNode *camera = smgr->addCameraSceneNodeMaya(NULL, -100.0f, 100.0f, 100.0f);
camera->setFOV(PI/10.0f);
while(device->run())
{
driver->beginScene(true, true, 0);
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
Irrlicht noob =p
Ok I managed to make the normal map work... almost
now all the normals seem to be inverted and only the "hidden faces are rendered
I thought it was a problem with the export from blender but since the model is normal mapped I find it a bit weird
And even with backfaceculling disabled it doesn't work
I'll keep testing and showing some results just in case, as always
now all the normals seem to be inverted and only the "hidden faces are rendered
I thought it was a problem with the export from blender but since the model is normal mapped I find it a bit weird
And even with backfaceculling disabled it doesn't work
I'll keep testing and showing some results just in case, as always
Irrlicht noob =p
Are you sure your normals are right in Blender? You might want to jump back into the UV editor to see, or try an automated process: Ctrl+N (Recalculate normals outside). Be warned, that process doesn't work for everything, especially if your triangles weren't edited "cleanly". So your best bet is to flip the normals you need to manually. It is somewhere in the special menu: W. I think it might be W, 9 but I forget.TeTine wrote:Ok I managed to make the normal map work... almost
now all the normals seem to be inverted and only the "hidden faces are rendered
I thought it was a problem with the export from blender but since the model is normal mapped I find it a bit weird
And even with backfaceculling disabled it doesn't work
I'll keep testing and showing some results just in case, as always
TheQuestion = 2B || !2B