separate UV-mappings for Color and Normal maps?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
mikeee
Posts: 9
Joined: Tue Feb 14, 2006 3:15 pm
Location: Germany

separate UV-mappings for Color and Normal maps?

Post by mikeee »

Hi,
I need some help with Color and Normal maps...

For better quality i'm using multiple materials on one mesh,
the problem is: I need to get it to work together with Perpixel-lighting,
Im applying my normal map like this:

Code: Select all

normalMap =driver->getTexture("media/norm1.bmp");
driver->makeNormalMapTexture(normalMap,1.50f);
//.... 
Node->setMaterialTexture(1, normalMap ); 
It's one global texute for the whole mesh (it's ok, because the quality of normal map is not so important as the quality of color-maps).
This mean, I have multiple materials (with their own UV-mappings) and only one single normal map for one mesh.
Is it possible, to adjust manually (in Blender or Max) the UV-mapping of this single Normal map (separately from Color-mappings) and load so prepared mesh in Irrlicht?

I'v tried to do it by applying UV-maps to another Map-channel (2nd, 3rd and 4th) and export so prepared model as .b3d (which supports multiple UVs/channels ).
But it seems, that for normal-mapping Irricht always takes the UVs from the 1st Channel (from the Color-one), what makes the whole per-pixel mapping messed up.

I other words:
Is it possible to have multiple UV-mappings for many materials (1st channel /color-maps), + one separate and global UV-mapping for normal-map (e.g. in the 2nd channel) ?
or alternatively: Is it possible to apply multiple normal-map textures to one mesh in Irrlicht? (if yes, then I would have no problems with separate UV-mappings more).

Thank you
-mike
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: separate UV-mappings for Color and Normal maps?

Post by hybrid »

Multiple texture coords are only possible if you calculate the binormals and tangents in the shader. Otherwise, there's only one texture coord in combination with binormals.
But of course you can have multiple normal maps per mesh, but it has to be combined with just one color map each, i.e. each mesh buffer can have exactly one color map and one normal map with this combination.
A third option, which might help in some situations, are texture matrices. You can specify a texture matrix for each texture layer.
mikeee
Posts: 9
Joined: Tue Feb 14, 2006 3:15 pm
Location: Germany

Re: separate UV-mappings for Color and Normal maps?

Post by mikeee »

Thank you very much,

You said, I can have multiple normal maps per mesh, but how can I easy combine 'em together with color maps and their UVs ?
For tests, I did already something like this:

In my 3d-modeler I've added textures and UV-mapping: to Map-Channel 1 (Color-map) and exactly same mapping to Map-Channel 2 (Normal-map),
then, in Irrlicht, after the model is loaded, im going throught the whole model , looking every texture1 (Map-Channel 2) and generate Normal-map "on the fly" for it:

Code: Select all

 
for (u32 i=0; i < Node->getMaterialCount(); ++i) 
{ 
   if (Node->getMaterial(i).getTexture(1))   //is there any Texture in slot1 ?
   {
        video::ITexture* normal_tmp; 
        normal_tmp = Node->getMaterial(i).getTexture(1);       //get "orginal" black-white,  normal-texture (assigned in Map-Channel 2 erarlier)
        driver->makeNormalMapTexture(normal_tmp ,2.00f);      //generate "true" normal-map from it
        Node->getMaterial(i).setTexture(1, normal_tmp);       //apply
   }
}
 
This works, although, it's not very elegnce.

Am I doing it right?
or is there any other and simpler way to get color-maps + normal-maps with common UV-mappings together?

-mike
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: separate UV-mappings for Color and Normal maps?

Post by hybrid »

Only .3ds and .obj have an automatic normal map loading mechanism. Maybe .irrmesh also has, but I'm not sure how far this was implemented. Otherwise you will indeed have to do the conversion manually, most mesh formats don't have support for this feature.
mikeee
Posts: 9
Joined: Tue Feb 14, 2006 3:15 pm
Location: Germany

Re: separate UV-mappings for Color and Normal maps?

Post by mikeee »

Im using now only one UV (common for Color and Normal maps) for one mesh buffer
and it works even with ready-made normal map textures in Map-channel 2 very well
(I don't need to load and generate 'em in Irrlicht any more).


Thank you.


-mike
Post Reply