LMGUI - another free lightmapper, with LMTS export
LMGUI - another free lightmapper, with LMTS export
Hello,
I have found pretty nice free application called LMGUI which is front end for Pulsar LMTools. So far i have pretty nice results with it:
here is screenshot of the app itself:
and here is lmts model loaded into Irrlicht:
I have to tweak lmts file though - it seems app write additional chunk of data into "MATI" block - so i just opened the file in HEX editor and deleted all from "MATI" untill "TEXT". Then file loaded just nice.
I modeled the scene in Blender, then exported to 3ds and opened it in LMGUI. Then added lights and created lightmaps.
I used the app from both original site
http://fig.emperion-empire.com/nav.php? ... cene/lmgui
and from
http://userlink.ru/glscene/download.php?view.58
and only last one is seems bugs-free to me...
Thank you, Fig for such great free tool!
Hope this could be usefull for Irr community as well...
I have found pretty nice free application called LMGUI which is front end for Pulsar LMTools. So far i have pretty nice results with it:
here is screenshot of the app itself:
and here is lmts model loaded into Irrlicht:
I have to tweak lmts file though - it seems app write additional chunk of data into "MATI" block - so i just opened the file in HEX editor and deleted all from "MATI" untill "TEXT". Then file loaded just nice.
I modeled the scene in Blender, then exported to 3ds and opened it in LMGUI. Then added lights and created lightmaps.
I used the app from both original site
http://fig.emperion-empire.com/nav.php? ... cene/lmgui
and from
http://userlink.ru/glscene/download.php?view.58
and only last one is seems bugs-free to me...
Thank you, Fig for such great free tool!
Hope this could be usefull for Irr community as well...
does it work when got transparency on my textures? can i still remain the transparent part and attach the light map?
My company: http://www.kloena.com
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info
-
- Posts: 83
- Joined: Fri Apr 11, 2008 3:06 am
- Location: Beaverton, Oregon, US
Virion wrote:does it work when got transparency on my textures? can i still remain the transparent part and attach the light map?
From LMGen.txt in "Pulsar LMTools\bin"+ Quality Settings
--------------------------------------------------------------------
A - Enable alpha channel
When you enable alpha channel processing; when a ray of light
colides against a polygon, LMGen checks the color of the
texel (texture's pixel) that the ray hits. If the alpha channel
of that texel has;
- 100% opacity, the ray stops. (a shadow is projected)
- 0% opacity, the ray passes trhough the polygon.
- otherwise, the ray color and intensity are modified
according to the texel values.
Only enable alpha channel if you need it.
F - Disable lightmap filtering.
The lightmaps are filtered using a 3x3 average filter.
Disabling this is always a bad idea; lightmaps are better
with it.
H - Enable hight quality shadows (oversample).
LMGen uses 4 rays for each lumel instead of one; so takes more
time, but the lightmaps are nicest.
Use this (at least) the last time that you create the lightmaps
for your maps.
S - Disable shadows.
The rays of light will not collide agains the 3D world.
Very fast, but lightmaps without shadows are very poor.
Note: alpha channel will not be used if shadow casting is
disabled.
EDIT: Oh, but if you mean in Irrlicht if it has built-in support for transparency + lightmap- the answer is no. There is no material type that can have transparency and lightmapping. But, it looks like someone made this material type for D3D9.
Modified CLMTSMeshFileLoader.cpp
To load lmts files generated in LMGUI you have to slightly modify 2 functions in CLMTSMeshFileLoader.cpp:
and
the last code is for loading any type of images, not only tga.
I think this could be added to IrrlichtSVN ?
Code: Select all
IAnimatedMesh* CLMTSMeshFileLoader::createMesh(io::IReadFile* file)
{
u32 i;
u32 id;
// HEADER
file->read(&Header, sizeof(SLMTSHeader));
if (Header.MagicID != 0x53544D4C) { // "LMTS"
os::Printer::log("LMTS ERROR: wrong header magic id!", ELL_ERROR);
return 0;
}
//Skip any User Data (this is caused by additional chunk of data called MATI)
s32 UserSize = Header.HeaderSize - sizeof(SLMTSHeader);
if (UserSize>0) {
file->seek(UserSize,true);
}
// TEXTURES
file->read(&id, sizeof(u32));
if (id != 0x54584554) { // "TEXT"
os::Printer::log("LMTS ERROR: wrong texture magic id!", ELL_ERROR);
return 0;
}
Textures = new SLMTSTextureInfoEntry[Header.TextureCount];
core::array<u32> textureIDs;
textureIDs.reallocate(Header.TextureCount);
u32 numLightMaps = 0;
u32 numTextures = 0;
for (i=0; i<Header.TextureCount; ++i)
{
file->read(&Textures[i], sizeof(SLMTSTextureInfoEntry));
if (Textures[i].Flags & 1)
textureIDs.push_back(numLightMaps++);
else
textureIDs.push_back(numTextures++);
}
// SUBSETS
file->read(&id, sizeof(u32));
if (id != 0x53425553) // "SUBS"
{
os::Printer::log("LMTS ERROR: wrong subset magic id!", ELL_ERROR);
cleanup();
return 0;
}
Subsets = new SLMTSSubsetInfoEntry[Header.SubsetCount];
for (i=0; i<Header.SubsetCount; ++i)
file->read(&Subsets[i], sizeof(SLMTSSubsetInfoEntry));
// TRIANGLES
file->read(&id, sizeof(u32));
if (id != 0x53495254) // "TRIS"
{
os::Printer::log("LMTS ERROR: wrong triangle magic id!", ELL_ERROR);
cleanup();
return 0;
}
Triangles = new SLMTSTriangleDataEntry[(Header.TriangleCount*3)];
for (i=0; i<(Header.TriangleCount*3); ++i)
file->read(&Triangles[i], sizeof(SLMTSTriangleDataEntry));
/////////////////////////////////////////////////////////////////
SMesh* mesh = new SMesh();
constructMesh(mesh);
loadTextures(mesh, numLightMaps, numTextures, textureIDs);
cleanup();
SAnimatedMesh* am = new SAnimatedMesh();
am->Type = EAMT_LMTS; // not unknown to irrlicht anymore
am->addMesh(mesh);
am->recalculateBoundingBox();
mesh->drop();
return am;
}
Code: Select all
void CLMTSMeshFileLoader::loadTextures(SMesh* mesh, u32 numTextures, u32 numLightMaps, const core::array<u32>& textureIDs)
{
if (!Driver || !FileSystem)
return;
core::stringc s;
// load textures
core::array<video::ITexture*> tex;
tex.set_used(numTextures);
core::array<video::ITexture*> lig;
lig.set_used(numLightMaps);
s32 tx_count = 0;
s32 lm_count = 0;
const core::stringc Path = Parameters->getAttributeAsString(LMTS_TEXTURE_PATH);
s32 extpos;
core::stringc fname,ext;
for (s32 t=0; t<Header.TextureCount; ++t)
{
video::ITexture* tmptex = 0;
fname =Textures[t].Filename;
extpos = fname.findLast('.');
fname =fname.subString(0,extpos);
for (s32 i=0; i<3; i++)
{
switch (i)
{
case 0: ext = ".png";break;
case 1: ext = ".jpg";break;
case 2: ext = ".tga";break;
//case 3: ext = ".bmp";break;
//case 4: ext = ".pcx";break;
//case 5: ext = ".psd";break;
}
s = Path;
s.append(fname);
s.append(ext);
//s.append(Textures[t].Filename);
if (FileSystem->existFile(s.c_str()))
break;
}
if (FileSystem->existFile(s.c_str()))
tmptex = Driver->getTexture(s.c_str());
else
{
char buf[512]; // filenames may be 256 bytes long
sprintf(buf, "LMTS WARNING: Texture does not exist: %s", s.c_str());
os::Printer::log(buf, ELL_WARNING);
}
if (Textures[t].Flags & 1)
lig[lm_count++] = tmptex;
else
tex[tx_count++] = tmptex;
}
// attach textures to materials.
for (s32 i=0; i<Header.SubsetCount; ++i)
{
if (Subsets[i].TextID1 < Header.TextureCount)
mesh->getMeshBuffer(i)->getMaterial().setTexture(0, tex[textureIDs[Subsets[i].TextID1]]);
if (Subsets[i].TextID2 < Header.TextureCount)
mesh->getMeshBuffer(i)->getMaterial().setTexture(1, lig[textureIDs[Subsets[i].TextID2]]);
if (!mesh->getMeshBuffer(i)->getMaterial().getTexture(1))
mesh->getMeshBuffer(i)->getMaterial().MaterialType = video::EMT_SOLID;
}
}
I think this could be added to IrrlichtSVN ?
EDITED: all links updated, now from googlepages
Thank you, hybrid and fmx
I want to add: LMGUI only exports all textures into tga, thats why Fig added the code for finding other extensions. Textures in tga are too huge for me, i always convert them to png/jpg (or simply use initial textures provided with 3ds file before importing to LMGUI)... Well, at first i changed final lmts files with hex-editor to change texture extension...
Anyway, right now i cant get any lmts file loaded into svn version of irrlicht. Anyone could confirm the problem? (i cant debug here, but noone renderer works - all crashed at the different points)
Please check Sample map.zip (1,516 KB), consists of 3 version:
1. map-orig.zip - initial map by Lord Trancos
2. lmgui-orig-map.zip - map exported from LMGUI
3. lmgui-map.zip - map exported from LMGUI but all textures converted from TGA to PNG/JPG (in case you want to check second code work)
And it seems Fig, original coder of LMGUI, is disappeared as well as his web-site, so i upload Fig's sent to me some time ago version of LMGUI v.0.2r1.1 (656 KB), where it is possible to select exported texture format (Bitmap, Targa, DDS, JPG) and other small fixes.
I want to mention, that official lmtools are not working with curved surfaces, but could work with alpha textures, as in this screenshot:
In last e-mail Fig wrote that he made his own lightmapper:
Thank you, hybrid and fmx
I want to add: LMGUI only exports all textures into tga, thats why Fig added the code for finding other extensions. Textures in tga are too huge for me, i always convert them to png/jpg (or simply use initial textures provided with 3ds file before importing to LMGUI)... Well, at first i changed final lmts files with hex-editor to change texture extension...
Anyway, right now i cant get any lmts file loaded into svn version of irrlicht. Anyone could confirm the problem? (i cant debug here, but noone renderer works - all crashed at the different points)
Please check Sample map.zip (1,516 KB), consists of 3 version:
1. map-orig.zip - initial map by Lord Trancos
2. lmgui-orig-map.zip - map exported from LMGUI
3. lmgui-map.zip - map exported from LMGUI but all textures converted from TGA to PNG/JPG (in case you want to check second code work)
And it seems Fig, original coder of LMGUI, is disappeared as well as his web-site, so i upload Fig's sent to me some time ago version of LMGUI v.0.2r1.1 (656 KB), where it is possible to select exported texture format (Bitmap, Targa, DDS, JPG) and other small fixes.
I want to mention, that official lmtools are not working with curved surfaces, but could work with alpha textures, as in this screenshot:
In last e-mail Fig wrote that he made his own lightmapper:
I still hope he will answer once and we could test his lighmapperI wrote my own lightmapper though that I planned to integrate into LMGUI, so there would be 3 supported lightmap engines. My lightmapper works pretty well as you can see from these images.
http://img264.imageshack.us/img264/2486/test2eq6.jpg
http://img125.imageshack.us/img125/5161/cartexqd2.jpg
http://img179.imageshack.us/img179/8875 ... xednk5.jpg
http://img167.imageshack.us/img167/7909/comparenm5.jpg
Last edited by puh on Sun Nov 09, 2008 8:13 am, edited 3 times in total.
i have uploaded it to rapidshare.hybrid wrote:Could you please upload your files somewhere else? I seem to be unable to download from 2shared...
http://rapidshare.com/files/162028960/S ... p.zip.html
try to download from rapidshare
-
- Posts: 66
- Joined: Wed Oct 04, 2006 2:07 pm