Texturing bug with the 0.8 new mapping feature

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
CyberP1708

Texturing bug with the 0.8 new mapping feature

Post by CyberP1708 »

This is with mapping
Image

This is with no mapping
Image

I think this is a texture rotation bug (a thing you can't see on a wall or on a sphere for example)
These two screenshots were made in DirectX 9 mode but it is the same in other modes

Here is my code if you want to be sure :

textn is the texture filename
texthn is the mapping texture filename
meshn is the model filename

Code: Select all

irr::scene::IAnimatedMesh* mesh;
irr::scene::ISceneNode* node;

#ifndef _NO_MAPPING

irr::video::ITexture* normalMap = device->getVideoDriver()->getTexture(texthn);
device->getVideoDriver()->makeNormalMapTexture(normalMap, 20.0f);
mesh = device->getSceneManager()->getMesh(meshn);
device->getSceneManager()->getMeshManipulator()->makePlanarTextureMapping(mesh->getMesh(0), 0.003f);
node = device->getSceneManager()->addMeshSceneNode(device->getSceneManager()->getMeshManipulator()->createMeshWithTangents(mesh->getMesh(0)));
node->setMaterialTexture(0,	device->getVideoDriver()->getTexture(textn));
node->setMaterialTexture(1,	normalMap);
node->getMaterial(0).EmissiveColor.set(0, 0, 0, 0);
node->setMaterialType(irr::video::EMT_NORMAL_MAP_SOLID);

#else

mesh = device->getSceneManager()->getMesh(meshn);
node = device->getSceneManager()->addMeshSceneNode(mesh->getMesh(0));
node->setMaterialTexture(0, device->getVideoDriver()->getTexture(textn));
#endif

node->setMaterialFlag(irr::video::EMF_FOG_ENABLE, true);

node->setPosition(irr::core::vector3df(0, 0, 0));
node->setRotation(irr::core::vector3df(0, 0, 0));
The second screenshot was made with
#define _NO_MAPPING
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Hm, interesting. And strange.
Why do you thing it is a rotation bug? Are you changing the rotation of your node and it only happens then?
CyberP1708
Posts: 10
Joined: Sat Feb 19, 2005 6:37 pm

Post by CyberP1708 »

No I thought it because the brown thing is on the right with mapping and it should be on the bottom and the gray thing is on the left and it should it on the top
But I tried to rotate the texture and it still doesn't work
As I don't really know how a texture is placed on a model I can't be more precise
Murphy
Posts: 290
Joined: Mon Dec 13, 2004 12:06 am
Location: United States
Contact:

Post by Murphy »

I haven't looked into how the new materials work. Is there any possibility that the texture coordinates are being swapped? It also looks like the vertex normals may be wrong...

If it were me, CyberP1708, I'd try swapping the U and the V coordinates of the texture mapping and see if the texture then fits again. It seems remote, but worth a shot. If you need help with this, ask.
CyberP1708
Posts: 10
Joined: Sat Feb 19, 2005 6:37 pm

Post by CyberP1708 »

I haven't made these textures but I know the guy who made them so I will tell him
I have noticed that it is this line that made the texture not to work :
device->getSceneManager()->getMeshManipulator()->makePlanarTextureMapping(mesh->getMesh(0), 0.003f);
Murphy
Posts: 290
Joined: Mon Dec 13, 2004 12:06 am
Location: United States
Contact:

Post by Murphy »

CyberP1708 wrote:I have noticed that it is this line that made the texture not to work :
device->getSceneManager()->getMeshManipulator()->makePlanarTextureMapping(mesh->getMesh(0), 0.003f);
Oh right. Now it all makes sense. That line re-does the texture coordinates! Not a bug...

I think a first step in the right direction is removing that line. ;)

I didn't read the code well enough the first time through. :D
CyberP1708
Posts: 10
Joined: Sat Feb 19, 2005 6:37 pm

Post by CyberP1708 »

But without this line there is no bump mapping
Murphy
Posts: 290
Joined: Mon Dec 13, 2004 12:06 am
Location: United States
Contact:

Post by Murphy »

CyberP1708 wrote:But without this line there is no bump mapping
Are you sure? That function just sets the texture coordinates as far as I can figure. It may effect how the bump map is applied if the textures aren't the same size (not sure about that), but I don't see how it'd stop bump mapping to remove it.

I mean... you can remove that line from the per pixel lighting demo, and the bump mapping still works (though it's pretty screwy since the texture coordinates in the 3ds mesh don't make a lot of sense).
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

I suspect the problem is that there is a bug in the createMeshWithTangents() method. It creates the normal, binormal and tangent vectors dependent on the texture mapping. And it looks like it generates crap with the original texture mapping of your model. This would explain the symptoms.
CyberP1708
Posts: 10
Joined: Sat Feb 19, 2005 6:37 pm

Post by CyberP1708 »

I also have a house with its texture that has the same problem and with it you can better see the effects of bump mapping as it is just a kind of box and I am sure: there is no bump mapping if I remove this line
Post Reply