Lightmapping levels

From OniGalore
Revision as of 19:31, 4 October 2010 by Geyser (talk | contribs) (→‎Radiosity: meh)
Jump to navigation Jump to search

Information is subject to change. The time of writing is 14:54, 4 October 2010 (UTC).

Lightmaps and Oni

Oni doesn't really support light maps, but we like to pretend that it does. See HERE for why we do and HERE for why we shouldn't.

In these screenshots, the lightmaps are part of the environment. They form a second layer of quads over the notmally textured ones, but they have their own texture coordinates, and they have their own unique texture. This shadow texture has a much lower resolution than the regular textures, but that is not a problem because of the blur effect. The only problem is that right now this texture is transparent, but doesn't have a BSP tree (supposed to be used for sorting when rendering particles etc, see ABNA). Apparently these shadows are always rendered in front of the opaque environment (which is good), but particles are always rendered behind the shadows (i.e., between the opaque environment and the shadow), and this is quite noticeable, unless the shadows are very subtle.

At the time of writing (14:54, 4 October 2010 (UTC)), OniSplit can import level geometry from several COLLADA files. For example, there could be one file for geometry and furniture, another file for the lightmaps of all that, another file with invisiwalls and invisiramps, another with a pathfinding mesh, etc.

Our options

Lightmaps can be generated in several ways. On my left, DelEd and IrrEdit are two lightweight tools that allow basic lightmapping, although it is far from optimal. On my right, (formerly "XSI") Mod Tool can generate much more sophisticated maps, but only for one mesh at a time, and with one texture file per mesh, which sucks.

In the middle, we have Blender, for which there apparently are a lot of scripts, enough to do what we need. It's fast to preview and to render, it's reasonably good-looking even with low quality settings, and it supports radiosity (see below) rather flawlessly. We like radiosity because Oni designers used area lights.

Radiosity

IrrEdit supports "radiosity" in the sense that every surface acts as a secondary light source. However, oddly enough, IrrEdit does not allow primary light sources to be area lights. The interface allows you to set up an emissive material and to assign it to polygons, but these materials and polygons are not taken into account when rendering lightmaps. Only regular lights contribute as primary light sources (point, spot, infinite, whatever), but the surfaces act only as secondary emitters. DelEd doesn't support radiosity at all. (formerly "XSI") Mod Tool supports it, but perhaps in a much too complicated way, apparently intended more for character authoring and complex renders than for moderately realistic lightmapping on a large scale (which is what we need for levels).

Oni was designed to be lit by area lights, in fact in most of Oni's environments the supposed light sources are clearly visible, with textures originally meant to be emissive, such as LIGHT_GRID. This means that the original levels can be lit relatively painlessly, in a tool that supports area lights. We don't need to place any light sources manually, instead we just assign an emissive material to polygons textured with LIGHT_GRID and other such textures. Then, ideally, the tool allows us to compute the lighting everywhere, as generated by these area lights.

The tool that does all that is Blender. The task is not exactly "mainstream", so there is not much support for it, but the ingredients are there. Here they are:

  1. A tutorial for the "Lightmap UV Pack" script. The good thing about this script is that it can batch-process several meshes at once. The bad thing is that for every mesh, it packs the UVs into a single texture, so for large or detailed meshes meshes either the lightmap will be pixellated, or you need to make the texture's resolution huge.
  2. An alternative Multi Lightmapper script, which generates new textures as needed, but can only process one mesh at a time.
  3. Some more scripts for the batch processing of many meshes (e.g. for saving the generated textures to files; neither of the above scripts save the baked lightmaps, and since there can be hundreds of them, automatic saving is badly needed).

No tutotial of our own, for now, but if you want to experiment with this, you can.