Making lightmapped geometry for Lightfeather in Blender
You can download blend file and all textures of this tutorial here.
You can discuss this tutorial here
- Open
Blender 2.43. If you use default settings, blank document will contain a
cube in the middle of the screen, light and camera. (Note that now you
look at the scene from Top. For fast switch between views press Numpad: 1
– Front, 3 – Right, 7 – Top, or simply rotate view by pressing MMB).
OK, let this cube be a room we want to make for Lightfeather.

- Next
let’s scale the cube so that room walls became a rectangles. Enter into
edit mode by pressing [Tab], press S for scaling and [Shift]+Z to keep
Z-scale. Next you can drag your mouse a bit (if you want snap to the grid
just press [Ctrl]) until you satisfied:

- By
default there is material assigned already to the cube. Switch to Material
properties [F5] and rename the material to “Walls” for example.

Lucky you – default material also contains texture, so switch to Texture
properties [F6] and rename texture also to “Walls”, then change type to
Image, press Load button and load texture file (better use standard
rectangular textures with size 128x128, 256x256, 128x512 etc., avoid
nonstandard sizes).

If you think that you can right now see textured cube in Blender – you
wrong. Don’t forget that primary goal of that fantastic software is
Rendering. Not real-time rendering. For this we have to assign texture
coordinates and switch to Textured shading, but first…
- Wait
a minute, you’d say; I don’t want my floor would be from bricks. OK, lets
assign another material for floor and ceiling. Change selection mode to
Face selecting ([Ctrl]+[Tab]->Faces or simply press the small triangle
icon in bottom right corner of 3D-view), rotate a view slightly so that
you can easy select the dots which represent top and bottom faces (Note –
selection in Blender is made with Right Mouse Button! Not Left one! Keep
it in mind forever! Pressing Left Mouse Button will cause the 3D-cursor of
the application move to the click place. If you did this unintentionally
go to the menu View->View Properties… and change coordinates of
3D-cursor back to 0,0,0):

With those two faces selected press small button New for adding new
material, then press Assign. But that’s not all. Next switch to Material
properties again [F5] and click on small spin-button in the Material name,
in popped menu select ADD NEW. Hm, newly created material have all the
same properties.

You only need rename it to “FloorCeiling” for example and assign another
texture. Do you think it’s easy? Don’t hurry – the texture you see in new
material is linked to the first one, so if you change it, your walls also
change their texture. You have to break this link (which also mean make
single-user copy) by clicking the number button from right of the texture
name:

Then rename the texture to “FloorCeiling” and load another texture file.
For better visual splitting you can also change colors of the materials –
for example make walls brighter and floor/ceiling brownier. Press [F5] and
return to material properties. Click on one of the color dockers and
change colors. For switch to 1st material use small arrows near
the material number:

- Let’s
make some columns for our room. Press Numpad 7 to switch to Top view. Next
press [Space] and from popped menu select Add->Cylinder, change
vertices number to 12 and viola! Newly added cylinder has all its faces
selected. We don’t need extra geometry in scene so we have to remove cylinder
caps. For that you can slightly rotate your view and press [Shift]+[Alt] +
RMB click on any vertical edge of the cylinder. Holding [Shift] means that
we want keep selection, but [Alt] means that we want to select all
connected faces. Simple, isn’t it? Intuitive? Ha-ha…

Now press X to delete selected. The right answer is “Faces” btw.
Hm, it seems this column is too huge for such small room, eh? So select it
again with [Alt] + clicking on any vertical edge, and scale it keeping Z
coordinate unchanged (S; [Shift]+Z; [Ctrl] for snapping).
Now you have to check which material this column is assigned? By default
it uses currently active material. If you want to add another material for
columns – you are welcome. But I just leave it with my FloorCeiling.
Further I want to add another columns to this scene, just duplicating this
one. Would be better to duplicate already UV-mapped columns, so keep it in
mind. Right now you just move it a bit in X or Y direction so we could
make duplication by rotating around center. Use those small RGB arrows for
it. I personally move it in -Y direction by 2 snaps:

- Time
for UV-mapping.
You can read this cool tutorial first if you wish: http://wiki.blender.org/index.php/Manual/Unwrapping_a_Mesh
or this for example: http://marginal.org.uk/x-planescenery/hangar_tutorial/3-textures.html
For easy navigating between UV-editor and 3D-view lets split current
viewport into 2. Move your cursor to the bottom split-line:

Then press MMB and select Split areas, point in to the top view and press
LMB to accept. Now select window type as UV/Image Editor:

If something is selected press A twice – this is for Select/Unselect all.
Let’s start from Walls – in Editing properties [F9] switch to 1st
material “Walls” and press small Select button. Next select UV Face Select
mode from drop-down menu:

Now in 3D-view press U and select Unwrap. Now look at the result in right
viewport. This is how Blender tried to unwrap our walls onto UV-space. OK,
at least he did it.

But this uv-mapping is not correct – the walls texture is bricks, and they
should be tiled all over the walls. Press on spin-button on the bottom of
the right viewport and select the walls texture file name – in my case
this was brick.tga:

Wow, realtime rendering in Blender! Nice. But uv-mapping still wrong. You
have to add a split, or so-called Seam, in the 4 walls so they could
correctly unwrapped into the rectangle. For this simply hold down [Alt]
and press edge of one corner with RMB. Repeat U->Unwrap and be happy
with result:

For dynamic uv-map change in 3D-view in right viewport go to menu
View->Update Automatically. You just have to scale a little bit the
uv-map. While mouse is under right viewport press A for Select All (twice
in case there were some selection – you’ll notice all pink points became
yellow). Now as usual press S for scale and move mouse to get best
results. You can also press G for moving the selected map. I prefer to
make uv-map be scaled exactly to height of texture and positioned at
center:

Ok, walls are ready, time to map floor and ceiling. Press [Tab] to enter
Edit mode and press A to unselect all selected faces. Now simply pick on
top and bottom faces and switch back to UV Face Select mode (you can press
[Tab] again for that). That’s all – at right viewport you could see the
square uv-map, that’s how Blender “unwraps” simple faces automaticaly. (Of
couse if your room is not squared then to avoid texture distortion you
could make simple project uv-coordinates from view by hand. In 3D-view
press Numpad 7 to switch to Top view and press U->Project From View).
If you want your texture tile – just scale your uv-map untill you satisfy.
Now again press small spin-button and change texture to floor/ceiling
texture filename – in my case this is concrete.jpg:

(For fast maximazind/demaximazing Viewport use shortkey [Shift]+[Space]).
Now you can rotate yor room in textured mode and observe the uv-mapping.
Don’t think that Blender uses double-sided rendering method – no, we just
forget about normal flipping for the cube. So let’s flip them now.
Press [Tab] for Edit mode, while floor and ceiling still selected change
material to Walls and press Select button (or you can select directly from
view). Check that now all walls and floor with ceiling are selected at
once. Note: column normals are ok, so don’t select it.
Now find small button “Flip Norm” in Mesh Tools palette:

One more to go: let’s unwrap the column. So while you are still in Editing
mode let’s add split seam from here, and later use it for uv-unwrapping.
Change selection mode to Edge selection ([Ctrl]+[Tab]->Edges or simply
press the small line icon in bottom right corner of 3D-view), zoom view to
look column closer and select one of the vertical edges with RMB. Next
press [Ctrl]+E->Mark Seam:

Go back to Face selection mode. Finally select column with [Alt] +
clicking on any vertical edge. Now go back to UV Face Select [Tab] and
notice that now you can freely see the column (aha, wall normals are
flipped!), and its still untextured, so let’s unwrap her.
Press U->Unwrap, and assign texture to uv-map – in my case it’s again
concrete.jpg.

Hm, I don’t like my uv-map is scewed. So just box-select all top vertices
(by pressing B and drawing virtual box with LMB), then move them a bit to
the left. Scale and move whole uv-map if you wish. Now it’s perfect:

We finished with uv-mapping for textures. Next step will be making new
uv-coordinates for lightmapping. But first lets duplicate the column so in
future lightning became more interesting.
- Return
to Edit mode with [Tab] and switch to Top view with Numpad 7. Pres Z to
switch to Wireframe. Make sure that 3D-cursor is located in the center of
the room. Now find small button Spin Dup, and below it change Degr: to 360
and Steps: to 4 and press Spin Dup. You will see that 3 additional columns
are added to scene and initial column still selected.

We have to delete the initial column with X now because it was duplicated
also.
(For some odd reason by default newly added columns are not smooth, but I
want all columns to be beautifully round, so please select all 4 columns,
and press W->Set Smooth)
- Ok,
now lets making new uv-set, which will store uv-coordinates for our
lightmaps. Find a small button New near the UV Texture in Mesh palette:

Press it and you’ve got second uv-map set. Rename it to Lightmap, and
first one to Diffusemap if you wish. But this new uv-map is empty now, and
I don’t think that repeat all same uv-operations from the beginning is the
best way to fill it. So let’s make a trick. We’ll copy the room object and
using special script copy uv-map from one object to another.
Switch to Object Mode. For copying the room – select it with RMB, press
[Shift]+D, and move your cursor, LMB for accept. Now while second object
still selected check that currently active is first uv-set with name
Diffusemap. Next click on initial room with LMB to select it. Check that
now active is Lightmap uv-set. Press [Shift] and click on copied room so
now both object are selected, but second one is active. Next switch the
right viewport to Scripts Window, and from menu select
Scripts->Object->UV Copy from Active.

It’s done. Now select and delete that extra object with X.
- Next
we will make a uv-map for lightmap. You have to take in mind that lightmap
is a standard texture except it should never be tiled. All faces in the
scene should have their uv-coordinates separatly. That’s why we could not
use identical uv-set for lightmaps. Now we will modify our uv-coordinates
so that they fit into 1 huge lightmap. And we will split uv’s of our 4
columns so that they will not be on top of each other as they are now.
Select the room and enter into Edit mode again with [Tab]. Select all
faces with A and switch to UV Face Select mode. In right viewport from
menu select Image->New… and set size to 1024x1024.

Rename the default Untitled to Lightmap. Now return to Edit mode [Tab] and
deselect all with A. Now we will modify uv-sets, so first select Walls and
switch back to UV Face Select [Tab]. Select all uv-coords by pressing A on
right viewport. Now scale S and move G it so that it fits into our texture
as follows (use [Shift]+[Space] to maximaze uv-window):

Next is FloorCeiling separatly this time – return to Edit mode and select
top face. Switch back to UV-mode. Scale and move until it fit. Repeat for
bottom face. Now if you select in Edit mode both walls and floor with
ceiling then back in UV-mode you can see something like this:

Now columns. We have to select each column separatly, so in Edit mode
switch to top view (Numpad 7) and use Box-select (B) of columns:

Scale and move each column so they fit in our Lightmap. My final map is
looks like that:

It’s not perfect, and I’ve got a lot of unused space, but you’ve got the idea
– now you can control all your lightmapping coordinates by hand (unlike in
gile[s] or FSRAD for example).
Oh, I could eliminate a lot of unused space by using another texture size
– 1024x512 for example. For this simply add another Image (rename it again
to Lightmap), but Blender will scale the uv-map nonuniformly to fit this
new size, so you have to scale it back. Use S for scale, press Y for scale
in Y direction only, and press 2 as scale factor. Now its perfect:

Note: for correct export to Lightfeather of cylindrical (or any unwrapped)
surfaces you have to keep in mind that split seams should be in same
places for both uv-maps – Lightmaps and Diffusemaps.
- Next
step – adding lights so that they could project nice shadows all over the
room. Change right viewport to 3D-view also and switch to Front view
(Numpad 1). Select with RMB those small circle means spot light and move
it to inside our room:

Press [F5] to get light properties and increase light Energy to 2 for
example.
Now change right viewport back to UV-window, in 3D-view select our room
and press magic shortcut: [Ctrl]+[Alt]+B means Bake Selected
Meshes->Full Render. After a while you could see something like that
(if you switch rendering mode to Textured):

That’s close to what we’re waiting for except that diffuse textures are
rendered also. So we have to switch them off for a while and also change
material color to full white.
I found that Ambient Occlusion is not rendered because of size of our room –
it's simply too small for default AO settings. To change them switch to Material
properties [F5] and next to World properties (small button with blue globe).
Change Dist to 0.10 and Energy to 0.50 or even less.

Switch to Material properties [F5] and
uncheck the texture using box in Texture palette. Then change material
color to full white. Make the same operation for second material also.
Repeat [Ctrl]+[Alt]+B for Bake Selected Meshes. Ok, now it’s looks fine
for lightmap:

You have to save this newly created image to disc and reassign it as a
texture. Go to menu Image->Save As… and save it as Lightmap.tga for example.
Next select next free texture slot below Walls (or FloorCeiling) and press
small Add New button:

Go to Texture settings [F6] and change Texture name to Lightmap, type to
Image and select Lightmap.tga as texture file (you can select it from
small spin-button as it’s already loaded in Blender). Make same operations
for second material.
- Exporting
the lightmapped geometry into obj format. Make sure you have uncheck first
texture block and checked second with Lightmap for both materials [F5],
and that cuurently active uv-set is still Lightmap [F9]. Now export the
room to obj format with menu File->Export->Wavefront (.obj)… Use
name LFroom_lmap.obj for example. Export settings I used are follows:

Now invert texture switches to be on for Walls and FloorCeiling and off
for Lightmap to export only diffuse textures this time, and switch the
current uv-set to Diffusemap:

Export again but this time with name LFroom.obj.
- Tweak
the obj files so they will merge into one lfm file in future. For the
correct merging we need to have same material name in both obj files. I
assume you know that obj file format is plain text format, so just open
exported files – LFroom.mtl, LFroom_lmap.mtl and LFroom_lmap.obj in
Notepad. In file LFroom.mtl find first material name, in my case it was
line:
newmtl Walls_brick.tga
Find similar material in file LFroom_lmap.mtl, in my case it was line:
newmtl Walls_Lightmap.tga
so we have to replace all occurencies of Walls_Lightmap.tga to
Walls_brick.tga in both LFroom_lmap.mtl and LFroom_lmap.obj.
Repeat for second material.
- Now
we are ready to import this room into Lightfeather. Use modelconverter.exe
which located in lightfeather\tools\modelconverter folder as following:
modelconverter LFroom.obj LFroom.lfm LFroom -2nduvLFroom_lmap.obj
Now you can also tweak an exported LFroom.lfm a little bit. Open it in
Notepad also and change all occurencies of lines:
feature=ERPF_LIGHTMAP
to
feature=ERPF_LIGHTMAP4 or feature=ERPF_LIGHTMAP2
and for some odd reason exported file have all ambient colors as pure
black, so please change following lines:
ambient=0,0,0, 255
to
ambient=255,255,255, 255
Now you can open your lightmapped file in Lightfeather:

Note: because of different coordinate systemes between Blender and
Lightfeather all exported files are mirrored. So if you want your geometry
will be exactly the same prior exporting from Blender you must Mirror all
your meshes with [Ctrl]+M->X Local. Then you have to flip all normals
as well.
Happy modeling with Blender and happy playing with Lightfeather! Thank
you.