light problems with normal maps
Posted: Tue Sep 09, 2008 7:43 am
Hello,
I have a problem with lighting of an object using normal maps. I try to create a planet which got it's light from a star. When I use EMT_SOLID as material type, then everything is fine. I can rotate the planet and it looks as it should be. The picture below shows some following frames captured:
When I'm using normal or parallax mapping, the light seems to be fixed to a static point on the object surface. When I rotate the planet, the light is moving. When the planet rotates to 180°, the planet is black as I would look to the back side. Then it switches to completely enlighted at next frame. See the next picture:
I only rotate the planet. Camera and light is not moving!
The code is not difficult:
I tried this also with more smaller numbers (planet size of 200), but the effect is the same. What's wrong there?
I have a problem with lighting of an object using normal maps. I try to create a planet which got it's light from a star. When I use EMT_SOLID as material type, then everything is fine. I can rotate the planet and it looks as it should be. The picture below shows some following frames captured:
When I'm using normal or parallax mapping, the light seems to be fixed to a static point on the object surface. When I rotate the planet, the light is moving. When the planet rotates to 180°, the planet is black as I would look to the back side. Then it switches to completely enlighted at next frame. See the next picture:
I only rotate the planet. Camera and light is not moving!
The code is not difficult:
Code: Select all
vector3df vPPos = vector3df(-120000,102000,-100000);
ISceneNode *pEarth = smgr->addSphereSceneNode(71500,64,NULL,10,vPPos);
pEarth->setMaterialTexture(0, driver->getTexture("media/earthmap1k.jpg"));
video::ITexture* normalMap = driver->getTexture("media/earthbump1k.jpg");
driver->makeNormalMapTexture(normalMap, 20.0f);
pEarth->setMaterialTexture(1, normalMap);
pEarth->setMaterialType(video::EMT_NORMAL_MAP_SOLID);
scene::ISceneNodeAnimator* anim =
smgr->createRotationAnimator(core::vector3df(0,0.5f,0));
pEarth->addAnimator(anim);
anim->drop();
ICameraSceneNode *pCam = smgr->addCameraSceneNode(0, core::vector3df(0,0,0), vPPos, 3);
pCam->setFarValue(3000000);
scene::ILightSceneNode* light1 = smgr->addLightSceneNode(0, core::vector3df(4000000,0,0),video::SColorf(1.0f, 1.0f, 0.9f, 1.0f), 20000000.0f, 2);