[fixed] Ogre mesh Lightmap UV coordinates
-
- Posts: 219
- Joined: Fri Feb 19, 2010 4:03 pm
- Location: Estonia
[fixed] Ogre mesh Lightmap UV coordinates
Hi,
I'm trying to use a lightmap on a mesh where the diffuse textures are tiled many time over. Now, the lightmap can obviously not use the same UV coordinates, so my question is, does Irrlicht support a second set of UV coordinates? If yes, how do I create/use them?
At moment, if I change my material type to EMT_LIGHTMAP and provide a second texture which is lightmap, its simply replacing the diffuse texture.
Many thanks in advance!
/regards
I'm trying to use a lightmap on a mesh where the diffuse textures are tiled many time over. Now, the lightmap can obviously not use the same UV coordinates, so my question is, does Irrlicht support a second set of UV coordinates? If yes, how do I create/use them?
At moment, if I change my material type to EMT_LIGHTMAP and provide a second texture which is lightmap, its simply replacing the diffuse texture.
Many thanks in advance!
/regards
to live, is natural; to die, is not!
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
Hi. You need to create your model and set everything as you want it to be- diffuse in the first texture, lightmap in the second, set the correct UV channels (usually two), then export to format that supports second uv set- .b3d for sure and .x dunno about the others. Then you just load your mesh, IIRC Irrlicht sets the EMT_LIGHTMAP automatically when second uv set is found, then you disable the lighting for the node and that`s all I think. As a whole it`s more up to the modelling program scene setup/settings, than everything else.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
-
- Posts: 219
- Joined: Fri Feb 19, 2010 4:03 pm
- Location: Estonia
Hi shadowslair, thanks for your response.shadowslair wrote:Hi. You need to create your model and set everything as you want it to be- diffuse in the first texture, lightmap in the second, set the correct UV channels (usually two), then export to format that supports second uv set- .b3d for sure and .x dunno about the others. Then you just load your mesh, IIRC Irrlicht sets the EMT_LIGHTMAP automatically when second uv set is found, then you disable the lighting for the node and that`s all I think. As a whole it`s more up to the modelling program scene setup/settings, than everything else.
What you describe is exactly what I've been doing and it dont work.
Ok, I'm using the Ogre Mesh format, and so far as I know it supports a second UV set, this should not be a problem.
I have also explored the COgreMeshLoader.cpp a bit and found a method:
scene::SMeshBufferLightMap* composeMeshBufferLightMap(const core::array<s32>& indices, const OgreGeometry& geom);
which, if I'm not mistaken, means the loader should be able to load lightmaps.
I can also confirm the mesh and materials are erxported correctly from 3dsMax. I base this on the fact that the .material file contains both the diffuse as well as lightmap texture. Here's the material file:
Code: Select all
material Material#162_slave3
{
technique Map#12
{
pass Map#13
{
ambient 0.698039 0.698039 0.698039 1
diffuse 0.698039 0.698039 0.698039 1
specular 0.898039 0.898039 0.898039 1 20
texture_unit Map#14
{
texture 19.jpg
filtering linear linear linear
}
texture_unit Map#16
{
texture Plane01LightingMap.jpg
tex_coord_set 1
filtering linear linear linear
}
}
}
}
Any ideas what could be the problem? For lihhtmaps do we need to have a mesh with tangets (as for normalmaps)?
I'm really badly stuck with this and ANY help would be highly appreciated.
/regards
to live, is natural; to die, is not!
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
I think you`re digging too deeply. Again, if your your model is made correctly you will see the desired result even in the irrlicht meshviewer. You need to just load the model and it should appear correctly without touching any code. I`m 90% sure you`re doing sth wrong when baking/applying/setting up the channels/materials in Max, and 10% doubt in the export format (ogre mesh is of no interest for me). And no, you don`t need tangent mesh for the lightmapped model (not to mention that it`ll mess things even more).
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
-
- Posts: 219
- Joined: Fri Feb 19, 2010 4:03 pm
- Location: Estonia
Thanks for your response again, but I think you should stop saying it works it works because it does not! Have you tested using lightmaps with Ogre mesh format? If lightmaps are working in Irrlicht for one format it does not mean they would work automatically for every format. It all depends on the particular loader.shadowslair wrote:I`m 90% sure you`re doing sth wrong when baking/applying/setting up the channels/materials in Max, and 10% doubt in the export format (ogre mesh is of no interest for me). And no, you don`t need tangent mesh for the lightmapped model (not to mention that it`ll mess things even more).
If I was doing something wrong or the problem was in the mesh, it shouldn't work in Ogre's meshviewer either, right? But the exact same mesh work perfectly when loaded with Ogre meshviewer. The lightmaps are loaded and displayed correctly.
When the same mesh is loaded in Irrlicht, its loading ONLY one texture and applying it as EMT_SOLID map. Even changing the textures and material type manually does not help.
So the real question is, how the Ogre meshloader is actually reading the materials and applying them? Is it supposed to recognize a lightmap and apply it as Irrlicht lightmap?
Does anyone have experience with applying lightmaps to Ogre .mesh format? Or anyone knows the COgreMeshLoader a bit deeply?
Thanks for any help,
/regards
to live, is natural; to die, is not!
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
Just took a quick look at the Ogre mesh loader and I`m pretty sure it doesn`t support second set of texCoords. Of course some of the devs can freely confirm/reject this statement. And sorry if you`re bored of me repeating the same thing, but I`ve never stated that it works with the ogre format, because as I said I`ve never used it. All I wanted to say is that you don`t need to do sth more than loading your mesh, and that I`m sure the .b3d and the .x support it and work just fine, although there are some specific things in the model setup. Cannot understand why you cannot use another model format, unless your Max version is above 9 and there`s no b3d pipeline support. Even then, you can still use the .x format, which supports it either. Your last option may be to extend the ogre format loader.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
-
- Posts: 219
- Joined: Fri Feb 19, 2010 4:03 pm
- Location: Estonia
Yeps, I was afraid of that but ok, now we're getting somewhere.shadowslair wrote:Just took a quick look at the Ogre mesh loader and I`m pretty sure it doesn`t support second set of texCoords.
Yes, would be nice to have a second opinion. Anyone?shadowslair wrote:Of course some of the devs can freely confirm/reject this statement.
One, yes I'm using 3dsMax 2010 and seriously considering moving over t0 2011 soon.shadowslair wrote:And sorry if you`re bored of me repeating the same thing, but I`ve never stated that it works with the ogre format, because as I said I`ve never used it. All I wanted to say is that you don`t need to do sth more than loading your mesh, and that I`m sure the .b3d and the .x support it and work just fine, although there are some specific things in the model setup. Cannot understand why you cannot use another model format, unless your Max version is above 9 and there`s no b3d pipeline support. Even then, you can still use the .x format, which supports it either.
Two, the application I'm working on has very specific requirements, and I've been through testing pretty much ALL the other formats supported by Irrlicht. None works, except the Ogre .mesh format. As for .b3d and .x, both are out-dated formats, if you are building something based on either of these, I seriously advise you to reconsider.
In fact, the one thing I really hate about Irrlicht is lack of own fully maintained custom format, together with appropriate exporters and tools for popular 3d-modelling packages. Because of this, for any serious application, the proper way would be to create your own mesh/animation format but I just didn't have time for that, so settled for Ogre's .mesh
True! Either that or I just find a way to live without lightmaps, cause re-writing the 50,000+ lines of code with Ogre is not an option at this point. :Sshadowslair wrote:Your last option may be to extend the ogre format loader.
Many thanks for your input though. If you come across any more information on the topic, please do share.
/cheers!
to live, is natural; to die, is not!
-
- Posts: 219
- Joined: Fri Feb 19, 2010 4:03 pm
- Location: Estonia
hybrid wrote:Yes, the ogre mesh loader supports lightmap meshes.
Really? :O do you mean it will apply the lightmap to a second set of UVs? If you're really right and show me how to do this I'd vote for you in next elections
No problem! Here you go: http://www.2shared.com/file/ZkOnkarc/Test.htmlhybrid wrote:Please upload the mesh somewhere so I can test it here.
This is a zip archive called Test.zip which include the following:
box.mesh, box.material = the mesh and material files
brickwall01.jpg, grass1.jpg = the texure files used
Box01LightingMap.jpg = the lightmap texture
screenshotfromOgre.jpeg = shows the mesh correctly light-mapped when loaded with Ogre mesh viewer.
screenshotfromIrrlicht01.jpg = the same mesh when loaded into Irrlicht, the loader creates it with 2 materials of type EMT_SOLID with Box01LightingMap.jpg applied as tex(0) for both.
screenshotfromIrrlicht02.jpg = the same mesh again, after I manually apply the correct textures on tex(0) and the lightmap on tex(1).
to live, is natural; to die, is not!
-
- Posts: 219
- Joined: Fri Feb 19, 2010 4:03 pm
- Location: Estonia
-
- Posts: 219
- Joined: Fri Feb 19, 2010 4:03 pm
- Location: Estonia
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Ok, this has been fixed in SVN/trunk. Since Irrlicht 1.7 did not fully support the 2tcoords meshes, I won't backport it. Please use the SVN/trunk version or wait for Irrlicht 1.8 for this feature.
BTW: The ogre render shows a repeated texture, but the material does not have a texture matrix, and the tex coords seem to be all below 1. Is the ogre screenshot only an approximated version of the actual mesh?
And to someone who knows the ogre material format: How can we see which material is meant if simply two textures are defined in one material? It could also be a detail map or reflection map. Are there any additional properties for finding the correct material implementation?
BTW: The ogre render shows a repeated texture, but the material does not have a texture matrix, and the tex coords seem to be all below 1. Is the ogre screenshot only an approximated version of the actual mesh?
And to someone who knows the ogre material format: How can we see which material is meant if simply two textures are defined in one material? It could also be a detail map or reflection map. Are there any additional properties for finding the correct material implementation?
-
- Posts: 219
- Joined: Fri Feb 19, 2010 4:03 pm
- Location: Estonia
Thats it! I'll vote for you ever-after! Serious.hybrid wrote:Ok, this has been fixed in SVN/trunk. Since Irrlicht 1.7 did not fully support the 2tcoords meshes, I won't backport it. Please use the SVN/trunk version or wait for Irrlicht 1.8 for this feature.
BTW: The ogre render shows a repeated texture, but the material does not have a texture matrix, and the tex coords seem to be all below 1. Is the ogre screenshot only an approximated version of the actual mesh?
And to someone who knows the ogre material format: How can we see which material is meant if simply two textures are defined in one material? It could also be a detail map or reflection map. Are there any additional properties for finding the correct material implementation?
I'm quite a beginner with Ogre materials myself, but I can tell this much that usually, the common material properties are defined at the very top, which determines how one or more texture-units are to be interpreted.
In context of Irrlicht, though I'm no expert but I think its really not important how Ogre materials actually use texture_units, because obviously Irrlicht does not interpret and use Ogre's script files. I think what is important is that if a texture unit specifies a texture_coord_set, then it should be loaded to the right tex_coord_set in Irrlicht. Then how that texture would be used is upto you (the coder). if you wanna use it for detail_map you'd simply change the material type in Irrlicht to EMT_DETAILMAP and if you wanna use it for Lightmap then change type to EMT_LIGHTMAP.
My problem with lightmaps was only that the second texture, which was supposed to be loaded to tex_coord_set_1 was getting loaded to tex_coord_set_0 and that was messing up everything. If this is now corrected, it would be possible to use a second texture for either a lightmap or a detail_map etc.
I have no idea whether all this is any help, but just doing what I can =)
/cheers!
to live, is natural; to die, is not!
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Yes, I guess you're right. The textures should now load to the according places (well, not always correct, but in most cases). And since there's no simple flag which defines a common material, but all are broken down to the shader programs, we cannot easily deduce more information. For now we keep the lightmap material, and the rest needs to be done manually, or via .irr files.