Lightmap compression

syedhs

13-07-2007 12:43:44

Hi,

We are currently doing lightmapping in a big scene and now, the lightmap texture has grown very big which can be attributed to these:-

1) Many unused white space in the texture - add plugin/trick/tips to have them packed better?

2) Lightmap texture is currently encoded as A8R8G8B8 - is it possible to have it encoded in less channels?

This may come as noob questions - no doubt about it :lol: But please help us maybe by giving a few pointers of your own pipelines in this regard.

Khorram

13-07-2007 16:05:41

I had myself some problems with lightmaps, so I decided to use textureshadows to avoid those problems... :wink:

Evak

13-07-2007 16:05:43

Don't know, but I came across an interesting thread about normal map compression on the Lumonix shader FX forums.

http://lumonixsoftware.com/yabb/YaBB.pl?num=1183582117

Looks like they swap some of the normal map colors around (swizzle) for better quality and stuff.

Lioric

13-07-2007 17:06:52

What is the size of the lm texture(s)?
(You can use low res textures, a single or a pair of 512x512 should cover all of your scene level, tex filtering will compensate)

You can attach all of your level objects, create the LM (use the auto flatten uvs, this will create a single texture for the level), then detach the objects. With this you will create a single texture that can make good use of the texture space (space usage is optimized). This process can be automated with maxscript

Search this forum for LM generation, there are several threads with links to some good scripts and tricks for your issue

syedhs

14-07-2007 07:13:18

Lightmap size is yeah.. quite huge 2048x2048 but it is needed since anything lower than that will result in unacceptable blur of static shadow.

The first step will be better packing of lightmap (Right now, the packing is horrible - the texture can easily be packed so that it will be smaller (2048x2048 -> 2048x1024). The flow will be described as Lioric - however what do you mean by texture filtering - is it done thru Ogre or thru 3dsmax?

Second step would be the texture format - I think alpha channel is not needed right? Here is how the material look like (as exported by Ofusion):-

material mshBukit1/mshBukit1_1
{
technique
{
pass
{
ambient 0 0 0 1
specular 0 0 0 1 10
alpha_rejection greater 128

texture_unit
{
texture_alias 0
texture sanmap_LL.dds
}

texture_unit
{
texture_alias 1
texture mshBukit1LightingMap.dds
tex_coord_set 2
colour_op_ex modulate_x2 src_texture src_current
colour_op_multipass_fallback dest_colour zero
}
}

}

}

So this will trim down size by 25%.

Evak,

I actually have no need of normal map compression. But I found one in ShaderX2 book - Wolfang Enyel's :wink:

Evak

14-07-2007 08:00:09

Don't know if this is of any use to you. I wrote a few things about my experiences with lightmaps here.

http://www.ogre3d.org/phpBB2/viewtopic. ... 885#232885

syedhs

14-07-2007 08:57:56

Evak,

I did read the thread prior to posting this, but I found that Bakersfield is only for 3dsmax 5?

Anyway now the critical problem is clear - texture is not packed well, so this will reduce the size by two. I wouldn't post the texture here because it is embarrassingly horrible use of texture space :lol:

syedhs

14-07-2007 11:09:05

I believe texture filtering is already done in my code:-

MaterialManager::getSingleton().setDefaultTextureFiltering(TFO_ANISOTROPIC);
MaterialManager::getSingleton().setDefaultAnisotropy(8);

I believe it should be sufficient as it set global texture filtering - unless lightmap material override it I have no idea.

Evak

14-07-2007 16:25:45

I use bakersfield with max9, it works great. I just don't think they changed it since max 6 was around.

3dsmax autoUV tools are terrible BTW. I used to use a lightmapping tool called Gile just to do my autoUV's and somwtimes my lightmaps if I was in a hurry. Falagard wrote a better Giles exporter than the one in the ogre tools wiki. But I prefer to use the gile importer for 3dsmax.

http://www.scriptspot.com/scripts/web_u ... sfield.mcr

that link is to v1.24, the one on the web page is still 1.23 and wasn't updated from when the web page was created.

Paulov

14-07-2007 18:37:40

Hi.

I´m very interested in reducing the size of the lightmaps.

In my latest project the lightmaps where by-far, by VERY far the heavyest textures in the work. Textures, betwen 15kb to 250kb i.e. and the lightmaps starting at 256kb to 1MB.

Hope I can give a look in deep to this threat and get a way to optimice my lightmaps.

I used in my project the AutoUV from the render to texture, and yes, I noticed that these maps could use the space available in a better way.
May these ar modificable, dont know.

syedhs

15-07-2007 01:34:22

Paulov,

I have got it solved already. I am not sure about how you load the scene (programmer's job), but texture filtering does help a lot. Without texture filtering, you cannot have a low res lightmap texture as it is too blur. Texture filtering will help in resharpening it back. In other word, with a little extra processing you can have low res while maintaining the quality.

And another which is lightmap packing - this has been accomplished using the method Lioric mentioned above.

Maybe there are other methods - I would like to hear about it as well!

Evak,

I assume that bakersfield as in your link will work in 3dsmax8? Using bakersfield 1.23, we tried to install it - you know as per instruction (install that damn thing in the blah blah) but nothing got installed or displayed.

Evak

15-07-2007 03:10:45

once its installed you have to add it to your UI using the customize user interface option in the drop down menu. In customize UI its bakersfield under the render section.

Nelis

15-07-2007 10:13:15

I found this info very handy for keeping my lightmaps DXT1 without the compression errors:

http://www.gamasutra.com/features/20051 ... e_01.shtml

For good lightmap unwraps the 'pixelpack' and 'multiobjectsunwrap' scripts are essential! (especially if you use edge padding).

http://users.skynet.be/arketip/

Evak

15-07-2007 18:56:20

hey nice, I used multiple unwrap before, but didn't know about pixel pack :)