Lightmaps generated by q3map2 (for quake 3)


(ziomber) #1

Hello :o

I have a trouble with loading and indexing lightmaps generated by q3map2.

I am writing a game and I use GTK Radiant 1.2.1.1 for designing maps. The problem occurs when I want to load lightmaps for a bigger maps - no one can understand now what i am describing now but look at screenshots:
When I build map in ex. One room or something ‘bigger’ but not huge at all my lightmaps load correctly.

But when i want to compile a bigger map (than that on screenshot nr 1 or 2)
my lightmaps are not properly indexed or the vertices of the map have wrong LIGHTMAP coordinates.
This screenshot shows RTCW game and lightmaps how they should look like:

But I get this:

And I don’t know whats the problem, when i compile small maps everythings looks OK, but for larger maps everything (lightmaps only) SUX :0 :S :X :C :Y

Now I will show you how I extract a lightmap to my game:

This is a source code written in Delphi :x
For all face’s in bsp file do

for i:=0 to high(faces) do begin

typ.INDEX_INFO[i] := faces[i].lightmapID; //now I get Lightmap index for each face
                   
setlength(typ.lightcoord[i],faces[i].numofVerts);
cnt := -1;
//and now I save lightmaps coords to file
for j:=faces[i].startVertIndex to faces[i].startVertIndex+faces[i].numofVerts-1 do  begin
cnt:=cnt+1;
typ.lightcoord[i][cnt].x := Vertices[j].LightmapCoord.X;
typ.lightcoord[i][cnt].y :=Vertices[j].LightmapCoord.y;
end;

end;

saveLIGHTMAPFILE(typ,'C:\TEMP\LIGHTMAP.C'); and save the file

  type TBSPVertex = Record
    Position      : TVector3f;             // (x, y, z) position.
    TextureCoord  : TVector2f;             // (u, v) texture coordinate
    LightmapCoord : TVector2f;             // (u, v) lightmap coordinate
    Normal        : TVector3f;             // (x, y, z) normal vector
    Color         : Array[0..3] of Byte    // RGBA color for the vertex
  end;


  type TBSPLightmap = Record
    imageBits : Array[0..127, 0..127, 0..2] of Byte;   // The RGB data in a 128x128 image
  end;

I know that not all face’s have lightmaps in ex. TEXTURES>COMMON>CLIPWEAP or CAULK or CLIP etc.

But i don’t think there’s a problem with it because all faces that are lightmapped have their own info about lightmap ID or coordinates
And i just load them and this sic problem occurs on larger maps, whats wrong. How q3map2 stores those lightmaps for those larger maps? Help me :stuck_out_tongue:

And there is one screenshot out of game ;d;d;d
http://img519.imageshack.us/my.php?image=qq3d2007032719063287da7.gif


(Loffy) #2

Hi

That shot lightmapsdontworkqz9.jpg really looks messed up. I wonder what causes the compiler to do that? I have no idea, sorry.

What version of q3map2 do you use?

//Loffy


(ziomber) #3

2.3.32

[i have tested on 4 versions of q3map2 and some versions of q3map]
But the problem is still the same > too big map LIGHTMAPS CRACKED :S

The ‘compiler’ does something that we don’t know but what :d


(ACROBAT) #4

This is probably no help, but I’ve had light maps for jko and jka that load like that when i try to compile on too low of lightmapscale for a large map. I end up raising it and eventually get a number that looks ok.


(ziomber) #5

But did you use your own 3D engine or q3 or rtcw game?
ID games load properly lightmaps but my game dosen’t (or don’t :v)


(carnage) #6

maby you can compile and get q3map2 to compile external lightmaps so we can see when you render a larger map if it is actually the lightmaps that are not being rendered correctly or if the fault lies in your gamecode

i have very little to no idea of what this pretty complex code means and does but one thing that came to mind is that when compiling a small(ish) map all the light data fits onto one lightmap image. When compiling a larger map it sometimes needs several lightmap images, perhaps your game is having problems when there are more than one lightmap image


(ziomber) #7

maby you can compile and get q3map2 to compile external lightmaps so we can see when you render a larger map if it is actually the lightmaps that are not being rendered correctly or if the fault lies in your gamecode

My steps: Compile map by q3map2, then I export bsp to NGAS (my type of file) + I save every lightmap to a file (they are savet correctly :])

Have a look at the first image in my first post (Scene use 7 Lightmaps), Last image with white fog is using 57 lightmaps.

i have very little to no idea of what this pretty complex code means and does but one thing that came to mind is that when compiling a small(ish) map all the light data fits onto one lightmap image. When compiling a larger map it sometimes needs several lightmap images, perhaps your game is having problems when there are more than one lightmap image

Of course no way.

Have no idea why those lightmaps are messed up :S

Everything works fine if it’s small map, no idea why but…

have a look at this:

  type TBSPFace = Record
    textureID : Integer;                   // The index into the texture array
    effect    : Integer;                   // The index for the effects (or -1 = n/a)
    FaceType  : Integer;                   // 1=polygon, 2=patch, 3=mesh, 4=billboard
    startVertIndex : Integer;              // The starting index into this face's first vertex
    numOfVerts     : Integer;              // The number of vertices for this face
    meshVertIndex  : Integer;              // The index into the first meshvertex
    numMeshVerts   : Integer;              // The number of mesh vertices
    lightmapID     : Integer;              // The texture index for the lightmap
    lMapCorner : Array[0..1] of Integer;   // The face's lightmap corner in the image
    lMapSize   : Array[0..1] of Integer;   // The size of the lightmap section
    lMapPos  : TVector3f;                  // The 3D origin of lightmap.
    lMapVecs : Array[0..1] of TVector3f;   // The 3D space for s and t unit vectors.
    vNormal  : t3dpoint;                  // The face normal.
    Size : Array[0..1] of Integer;         // The bezier patch dimensions. 
  end;
    lightmapID     : Integer;              // The texture index for the lightmap
    lMapCorner : Array[0..1] of Integer;   // The face's lightmap corner in the image
    lMapSize   : Array[0..1] of Integer;   // The size of the lightmap section
    lMapPos  : TVector3f;                  // The 3D origin of lightmap.
    lMapVecs : Array[0..1] of TVector3f;   // The 3D space for s and t unit vectors.

I use only one thing from this: lightmapID because i have no idea how can I use rest of data, I also use one static lMapCorner for every lightmap so there’s seems to be a problem somewhere there but what types of info are stored in BSP FACE


(obsidian) #8

Are you sure it’s a lightmap issue? Looks to me like the texture coordinates in general are out of whack. Hard to judge from the screenshots, though.


(ziomber) #9

have no idea, but i believie in this code:

lightmapID : Integer; // The texture index for the lightmap
lMapCorner : Array[0…1] of Integer; // The face’s lightmap corner in the image
lMapSize : Array[0…1] of Integer; // The size of the lightmap section
lMapPos : TVector3f; // The 3D origin of lightmap.
lMapVecs : Array[0…1] of TVector3f; // The 3D space for s and t unit vectors.

And it’s not mine i searched over internet and it looks like it’s ok everyone has it :stuck_out_tongue:


(obsidian) #10

Write a shader that doesn’t use lightmaps and compile a map using it. See if you get the same problems.

Unless you can narrow it down a little it’s anyones guess as to what the problem is.