Create normal map in 3D Max and import to Irrlicht

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
Dronchik
Posts: 36
Joined: Sun Feb 17, 2008 1:30 pm
Location: Kazahstan::Astana
Contact:

Create normal map in 3D Max and import to Irrlicht

Post by Dronchik »

Hi. I saw example about PerPixelLighting. In code, i saw, so bump texture added from code:

Code: Select all

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_height.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).SpecularColor.set(0,0,0,0);

		room->setMaterialFlag(video::EMF_FOG_ENABLE, true);
		room->setMaterialType(video::EMT_PARALLAX_MAP_SOLID);
		room->getMaterial(0).MaterialTypeParam = 0.035f; // adjust height for parallax effect

		// drop mesh because we created it with a create.. call.
		tangentMesh->drop();
	}
But I added bump texture to model in 3D Max. And How can I render bump mapping in Irrlicht if I added bump texture to model in 3d max???
Adler1337
Posts: 471
Joined: Sat Aug 09, 2008 6:10 pm
Location: In your base.

Post by Adler1337 »

I don't understand what you are asking. If you are asking what i think you are asking, then you answered your own question with the code. :?
multum in parvo
Dronchik
Posts: 36
Joined: Sun Feb 17, 2008 1:30 pm
Location: Kazahstan::Astana
Contact:

Post by Dronchik »

Ok. In perpixellighting example, bump added by code. But I'm adding bump map to model in 3D Max. But in my application, my model doesn't have bump. Why? And How I can fix it?
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

Firstly, take note of this :

Code: Select all

 driver->makeNormalMapTexture(normalMap, 9.0f);      
This generates a "purple" normal map, from a greyscale image (its a feature being demonstrated). YOU DONT NEED THIS TO SHOW NORMAL MAPS.

Secondly, there are only 3 things needed to use a normal map on a mesh. First :

Code: Select all

Mesh->setMaterialType(video::EMT_NORMALMAP_SOLID)
Sounds logical, doesnt it :)

Secondly, The textures. textures work in "slots" on a mesh. slot 0, is the color (the diffuse texture), and slot 1 will be used as the normal map itself.

Thirdly, the tangent vertex types. Its easier to see code below.

Code: Select all


//Loading the mesh like this will respect slot 0 (color) only if it can find the textures
scene::IMeshSceneNode* MainMesh = smgr->addMeshSceneNode(smgr->getMesh("myMeshFile.obj));

//create the tangent EVT_TANGENTS type, so that it can render properly
scene::IMesh* tangentMesh = smgr->getMeshManipulator()->createMeshWithTangents(MainMesh->getMesh());

//Assign the vertex types into the original meshSceneNode
MainMesh->setMesh(tangentMesh);

//Note the slot 1 below (thats where the normal map needs to be)
MainMesh->setMaterialTexture(1, driver->getTexture("normalmap.jpg"));

MainMesh->setMaterialType(video::EMT_NORMAL_MAP_SOLID);


This is all thats needed to see normal maps. There are other considerations such as material specular color, shininess etc.


Also, DONT turn OFF lighting, lighting MUST be enabled, and the light must be close enough to the object to see stuff.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

3DS files (as well as .obj files) do support normal map loading from files. You have to match the proper settings, though. And be sure to use Irrlicht from SVN/trunk.
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

oh awesome, thats good to hear hybrid.
Dronchik
Posts: 36
Joined: Sun Feb 17, 2008 1:30 pm
Location: Kazahstan::Astana
Contact:

Post by Dronchik »

Thanks for answer! It helped me :)
Hybrid, personality thnks :)
But I have also answer, on subj and irredit. If will I load mesh with bump to irrEdit scene, set to this model's material type properties variable "EMT_NORMALMAP_SOLID" or "EMT_PARALAXMAP_SOLID", when I loading this scene to my application, will I see normal or paralax on my model of it scene?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, you won't. Because most meshes will not load into Tangent meshes, but usual standard type. You'd have to change the vertex types, calculate tangents, and maybe also work with the texture. Well, wait, if you see the bump map effect in irrEdit it might already work immediately, though I don't know what Niko does with the meshes in between...
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

There is also a tool in the SDK folders, that is a meshConverter. You can give it a mesh and it will output one with tangents (i saw it in my svn folders). Doing this and then trying to see it in irrEdit might help
Post Reply