Bump mapping with several texture

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Shomaa
Posts: 15
Joined: Sat Mar 14, 2009 2:28 pm
Location: {Epitech.} Kremlin-Bicetre

Bump mapping with several texture

Post by Shomaa »

Hello ,

I try to do some Per-Pixel Lighting with a mesh and several textures...
but it's REALLY possible ?

with a mesh and one texture :

Code: Select all

        video::ITexture* normalMap =
            driver->getTexture("../../media/rockwall_height.bmp");
        if (normalMap)
            driver->makeNormalMapTexture(normalMap, 9.0f);
       scene::IMesh* tangentMesh = smgr->getMeshManipulator()->
                createMeshWithTangents(roomMesh->getMesh(0));
room = smgr->addMeshSceneNode(tangentMesh);
        room->setMaterialTexture(0,
                driver->getTexture("../../media/rockwall.jpg"));
        room->setMaterialTexture(1, normalMap);
Ok here, it's not complicated....

but if our mesh is generated by Sketchup with several texture ? (in dae format)
Like this, we obtain the wrong results...

Code: Select all

        video::ITexture* normalMapRockwall =
            driver->getTexture("../../media/rockwall_height.bmp");
video::ITexture* normalMapFencing =
            driver->getTexture("../../media/fencing_height.bmp");
 
        if (normalMap)
            driver->makeNormalMapTexture(normalMapRockwall, 9.0f);
        if (normalMapFencing)
            driver->makeNormalMapTexture(normalMapFencing, 14.0f);
       scene::IMesh* tangentMesh = smgr->getMeshManipulator()->
                createMeshWithTangents(roomMesh->getMesh(0));
room = smgr->addMeshSceneNode(tangentMesh);
        room->setMaterialTexture(0,
                driver->getTexture("../../media/rockwall.jpg"));
        room->setMaterialTexture(1,
                driver->getTexture("../../media/fencing.jpg"));
        room->setMaterialTexture(2, normalMapRockwall);
        room->setMaterialTexture(3, normalMapFencing);
 
normalMapFencing
 
why ??
--
Shomaa
Mel
Competition winner
Posts: 2293
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Bump mapping with several texture

Post by Mel »

There is another way to set the textures. Check the getMaterial(u32 i); method from the ISceneNode. Using setMaterialTexture() changes all the materials from the scene node at once, not only one.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Bump mapping with several texture

Post by hybrid »

If you use this material setting way, you're already using a different base material (maybe detail map or reflections material), so you have to write your own shader to provide the proper rendering with those textures. If you have multiple textures, you usually also have multiple mesh buffers, which need the different texture setting mechanism.
Shomaa
Posts: 15
Joined: Sat Mar 14, 2009 2:28 pm
Location: {Epitech.} Kremlin-Bicetre

Re: Bump mapping with several texture

Post by Shomaa »

I use .irr file ,most of the time, (with coppercube).
And nothing explains the method for matches the correct height map or detail map
and the right texture (or material).

the code snippet above is here, for illustrate my questions.

So I must use shaders (HLSL) for Bump mapping ?
--
Shomaa
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Bump mapping with several texture

Post by hybrid »

Yes, if you set the material to BUMP_MAP or PARALLAX_MAP Irrlicht uses a shader to render the effect. This shader only works for two lights, no light settings, and no other texture effects. If you want to change this behavior, you have to provide your own shader.
Shomaa
Posts: 15
Joined: Sat Mar 14, 2009 2:28 pm
Location: {Epitech.} Kremlin-Bicetre

Re: Bump mapping with several texture

Post by Shomaa »

ok thanks, i'll switch to the shaders then.
--
Shomaa
Post Reply