[fixed]normalmaps...

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

[fixed]normalmaps...

Post by zillion42 »

see:

http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=30257
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=25596
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=24334

and some modified example 11 to illustrate....

Code: Select all

#include <irrlicht.h>
#include <iostream>

using namespace irr;

#pragma comment(lib, "Irrlicht.lib")

IrrlichtDevice* device = 0;

bool UseHighLevelShaders = true;
scene::ICameraSceneNode* camera;
scene::ISceneNode* light2;

/*
Now for the real fun. We create an Irrlicht Device and start to setup the scene.
*/
int main()
{
   // let user select driver type

   video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;

   // create device

   //IrrlichtDevice*
   device = createDevice(driverType, core::dimension2d<u32>(800, 600));

   if (device == 0)
      return 1; // could not create selected driver.


   video::IVideoDriver* driver = device->getVideoDriver();
   scene::ISceneManager* smgr = device->getSceneManager();
   gui::IGUIEnvironment* env = device->getGUIEnvironment();

   driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);

   // add irrlicht logo
   env->addImage(driver->getTexture("../../media/irrlichtlogo2.png"),
      core::position2d<s32>(10,10));

   // add camera
   //scene::ICameraSceneNode* camera =
   camera =   smgr->addCameraSceneNodeFPS(0,100.0f,0.1f);
   camera->setPosition(core::vector3df(-270,200,-200));

   // disable mouse cursor
   device->getCursorControl()->setVisible(false);


   driver->setFog(video::SColor(0,138,125,81), true, 250, 1000, 0, true);

   scene::IAnimatedMesh* roomMesh = smgr->getMesh(
      "../../media/room.3ds");
   scene::ISceneNode* room = 0;

   if (roomMesh)
   {
      smgr->getMeshManipulator()->makePlanarTextureMapping(
         roomMesh->getMesh(0), 0.003f);

      video::ITexture* colorMap = driver->getTexture("../../media/rockwall.bmp");
      video::ITexture* normalMap = driver->getTexture("../../media/rockwall_normalmap.bmp");

      driver->makeNormalMapTexture(normalMap, 9.0f);

      scene::IMesh* tangentMesh = smgr->getMeshManipulator()->createMeshWithTangents(
         roomMesh->getMesh(0));

      room = smgr->addMeshSceneNode(tangentMesh);
      room->setMaterialTexture(0, colorMap);
      room->setMaterialTexture(1, normalMap);
      
      //room->getMaterial(0).setTexture(0, colorMap);
      //room->getMaterial(0).setTexture(1, normalMap2);

      room->getMaterial(0).SpecularColor.set(0,0,0,0);

      room->setMaterialFlag(video::EMF_FOG_ENABLE, true);
      room->setMaterialType(video::EMT_NORMAL_MAP_SOLID);

      // drop mesh because we created it with a create.. call.
      tangentMesh->drop();
   }

   // add earth sphere

   scene::IAnimatedMesh* earthMesh = smgr->getMesh("../../media/earth.x");
   if (earthMesh)
   {
      //perform various task with the mesh manipulator
      scene::IMeshManipulator *manipulator = smgr->getMeshManipulator();

      // create mesh copy with tangent informations from original earth.x mesh
      scene::IMesh* tangentSphereMesh =
         manipulator->createMeshWithTangents(earthMesh->getMesh(0));

      // scale the mesh by factor 50
      core::matrix4 m;
      m.setScale ( core::vector3df(50,50,50) );
      manipulator->transformMesh( tangentSphereMesh, m );

      scene::ISceneNode *sphere = smgr->addMeshSceneNode(tangentSphereMesh);

      sphere->setPosition(core::vector3df(-70,130,45));

      // load heightmap, create normal map from it and set it
      video::ITexture* earthNormalMap = driver->getTexture("../../media/earthbump.bmp");
      driver->makeNormalMapTexture(earthNormalMap, 20.0f);
      sphere->setMaterialTexture(1, earthNormalMap);

      // adjust material settings
      sphere->setMaterialFlag(video::EMF_FOG_ENABLE, true);
      sphere->setMaterialType(video::EMT_NORMAL_MAP_SOLID);

      // add rotation animator
      scene::ISceneNodeAnimator* anim =
         smgr->createRotationAnimator(core::vector3df(0,0.8f,0));
      sphere->addAnimator(anim);
      anim->drop();

      // drop mesh because we created it with a create.. call.
      tangentSphereMesh->drop();
   }

   // add light 1 (nearly red)
   scene::ILightSceneNode* light1 =
      smgr->addLightSceneNode(0, core::vector3df(50,190,0),
      video::SColorf(1.0f, 1.0f, 1.0f, 0.0f), 800.0f);

   // attach billboard to the light
   scene::ISceneNode* bill =
      smgr->addBillboardSceneNode(light1, core::dimension2d<f32>(60, 60));

   bill->setMaterialFlag(video::EMF_LIGHTING, false);
   bill->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
   bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
   bill->setMaterialTexture(0, driver->getTexture("../../media/particlered.bmp"));

   /*
   Finally, draw everything. That's it.
   */

   int lastFPS = -1;

   while(device->run())
      if (device->isWindowActive())
      {
         driver->beginScene(true, true, 0);

         smgr->drawAll();
         env->drawAll();

         driver->endScene();

         int fps = driver->getFPS();

         if (lastFPS != fps)
         {
            core::stringw str = L"Per pixel lighting example - Irrlicht Engine [";
            str += driver->getName();
            str += "] FPS:";
            str += fps;

            device->setWindowCaption(str.c_str());
            lastFPS = fps;
         }
      }

      device->drop();

      return 0;
} 
any news ?

EDIT:
btw, I know earth is supposedly smoother than a snooker ball, unfortunatetly I was never out there to see if sunset purple mountain caps and the shadows they cast are visible from space...
Last edited by zillion42 on Sat Jun 20, 2009 1:29 pm, edited 1 time in total.
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

Post by zillion42 »

sorry... but... bump !?
Image
back in the days...
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

what are you asking? This thread makes no sense. Rather ask stuff in a logical, clear way. By saying "any news" and having no background of wtf you mean means noone can answer ;)
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

Post by zillion42 »

my god, I nearly logged in with omg.
no seriously i linked three threads here and fact is that normalmaps, that is the oldschool (for compatibility reasons) shader model shader used in video::EMT_NORMAL_MAP_SOLID doesn't react on local rotation.

paste my example and see...
Last edited by zillion42 on Sun Jun 21, 2009 10:51 pm, edited 1 time in total.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Yes I was already aware of this problem to some degree. A quick look at the shader code shows that it SHOULD be performing correctly, so there must be some bug in passing in the correct constants.

Will be looked into shortly.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

Post by zillion42 »

:shock:
wow, that is good news indeed...
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

Blindside wrote:Yes I was already aware of this problem to some degree.
No robot point for not quoting the source of such awareness :P
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

:cry:
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

Awww, but 5 robot pieces for being an official member of irr's dev team? How does that sound?

And 25 more if you fix that nuisance ^^
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

Post by zillion42 »

anyone feels like tackling that problem sooner or later ?
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Post a bug on the bug tracker and include a test case: the smallest code possible to reproduce the bug.
With a good test case and description it will be really easy for anyone to pick it up and try to solve it, and because it's in the bugs list it can't get forgotten about or buried here in the forums.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

Post by zillion42 »

I filed a bug on the tracker... I hope the example is ok like that.

thx a lot in advance and hopefully someone will be able to fix that.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Wow I nearly forgot about this, hopefully we'll get around to fixing it soon.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Post Reply