How to add normalmaps into animated mesh?

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
Noiecity
Posts: 163
Joined: Wed Aug 23, 2023 7:22 pm
Contact:

How to add normalmaps into animated mesh?

Post by Noiecity »

I plan soon to publish a robot rigged cc0 with animations in different formats, md2 and b3d, all good so far, but I do not know how to implement in normalsmaps code in animated geometry, has anyone experienced this? :cry:

I have seen that you can convert geometry to tangent using "MeshConverter", I tried converting a geometry and importing it to irrEdit, but the normalmaps do not load, I have not yet tried in code as I do not know how to start this task properly. :cry: :cry:

Image

At the moment I have it textured as follows, although I still have to change the red parts to make it look like the head.
**
If you are looking for people with whom to develop your game, even to try functionalities, I can help you, free. CC0 man.

Image
**
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to add normalmaps into animated mesh?

Post by CuteAlien »

If you are lucky the format already creates a meshbuffer with tangents (I think .X format does, not sure about others). Then you have to ensure the normalmap is in texture 1 slot (slot 0 has diffuse). And materialType is EMT_NORMAL_MAP_SOLID, EMT_PARALLAX_MAP_SOLID, EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA or EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA.

I'm not sure about options if the loader can't create tangents already. As long as it uses SSkinMeshBuffer internally you could create automatic tangents with SSkinMeshBuffer::convertToTangents, but it wouldn't really initialize the tangent and binormal. IMeshManipulator::recalculateTangents can calculate tangents, but not sure if it works with SSkinMeshBuffer (but I think it does). So maybe calling those 2 could get you tangents even when loaders do not support it.

What also might be useful is that you can also automatically create normal-map textures with driver->makeNormalMapTexture (it makes dark areas "low" and bright areas "high", but only regards red channel for 32-bit textures). Good for a first test. Thought for better normal-maps you usually create them in a tool.

There are other options to have normalmaps, but those are a bit more complicated and require writing your own shader. Thought they have the advantage that you can code shaders to generate the tangents/binormals so you can work with simpler meshbuffers.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Noiecity
Posts: 163
Joined: Wed Aug 23, 2023 7:22 pm
Contact:

Re: How to add normalmaps into animated mesh?

Post by Noiecity »

CuteAlien wrote: Tue Aug 13, 2024 7:25 pm If you are lucky the format already creates a meshbuffer with tangents (I think .X format does, not sure about others). Then you have to ensure the normalmap is in texture 1 slot (slot 0 has diffuse). And materialType is EMT_NORMAL_MAP_SOLID, EMT_PARALLAX_MAP_SOLID, EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA or EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA.

I'm not sure about options if the loader can't create tangents already. As long as it uses SSkinMeshBuffer internally you could create automatic tangents with SSkinMeshBuffer::convertToTangents, but it wouldn't really initialize the tangent and binormal. IMeshManipulator::recalculateTangents can calculate tangents, but not sure if it works with SSkinMeshBuffer (but I think it does). So maybe calling those 2 could get you tangents even when loaders do not support it.

What also might be useful is that you can also automatically create normal-map textures with driver->makeNormalMapTexture (it makes dark areas "low" and bright areas "high", but only regards red channel for 32-bit textures). Good for a first test. Thought for better normal-maps you usually create them in a tool.

There are other options to have normalmaps, but those are a bit more complicated and require writing your own shader. Thought they have the advantage that you can code shaders to generate the tangents/binormals so you can work with simpler meshbuffers.
thank you cutealien, I don't know what the forum would be without you
**
If you are looking for people with whom to develop your game, even to try functionalities, I can help you, free. CC0 man.

Image
**
Post Reply