Lightmapping and jME

Hi people,

I have been searching the forums for information about lightmapping.

I would like to have my scenario lightmapped. I guess I should write a lightmapper that calculates and adds the lightmap texture to meshes.

I have a very basic understanding of lightmapping so I would be very grateful if you can comment on:

  1. Is this a feasible project? Can it be done as a hobby?

  2. Are there any free lightmapping applications out there suitable for use with jME?

  3. As a curiosity, is lightmapping being used in current state-of-the-art games or are other techniques being used? (I can see that lots of current games are drawing realtime shadows from scenario on objects and from objects on scenario).

    Thank you in advance :slight_smile:

irrEdit and Blender3D are free and support lightmapping.

It's possible to get especially good results with blender if you're using a realistic renderer like yafray or radiosity calculation.

Thank you ninjaboyjohn for your comment. I have just been having a look at Crysis and while it really features realtime lighting, I wonder how much precalculation is involved in it.

However, that kind of work is far from my abilities. So sticking to lightmapping, I have been examining Blender capacity.

It seems to me that it has trouble with repeated textures (textures repeated over a triangle). Even if I could overcome that, resulting images need to be manually saved, and also the exported Collada model won't contain double uv coordinates. It doesn't seem to optimize the resulting amount of lightmaps.

  1. Do you know if Blender can really be used for this without making process painfully slow?

  2. Could this be done for jME (i.e. an application that generates lightmaps and adds texture coordinates to meshes?)? What problems do you think this approach could face?

    Again, thank you for your comments.

If you're looking for an automated solution then you could try writing a script for blender.

Mmm yep. Surely saving lightmaps to disk wouldn't be the hardest issue.

However I still need to assign textures and map them before generating lightmaps, because Blender is not assigning UV coordinates or lightmaps, but just rendering them.

The hardest part for me here is would be to walk the level checking for repeated textures to remap them so that the lightmap is not repeated too. If I did that I would be throwing a lot of texture space away.

The perfect solution would be a tool that takes each piece of geometry, decides the ideal lightmap size, unfolds or projects the texture on the geometry and then lets Blender generate the lightmap. And if the piece is not convex, then a simple cube projection won't work anyway. Choosing how to project is actually a big deal, since all faces need to be projected on the lightmap, and texels must belong to one and only one face.

Difficult thing. I guess that something has to exist out there, but I couldn't find it. I started writing my own simple lightmapper but I am basically facing the same problems described above. Once the mapping is done, generating the actual lightmap doesn't seem so difficult.

Your comments are very welcome. If someone has experience or thoughts about this (texture size selection, lightmap), please drop a line.

Blender can generate lightmap UV coordinates, map them to a new UVTexture, and allocate an image for all meshes.

The ideal blender lightmap generator script would do:

  1. Unwrap UV using lightmap projection
  2. Export the scene somewhere with the 2nd lightmap UV data
  3. Generate radiosity meshes and move them to a seperate layer
  4. Replace the radiosity materials to ones that just expose the radiosity data
  5. Generate a certain number of lightmap textures (depends on how big your scene is)
  6. Bake the render to the lightmap textures and export them

    All of those tasks can already be done by Blender, there's no need to write any unwrapper, baker or anything like that.

    If the script has access to all functions available to the user then making the script should be pretty straightforward.