Public Group

quake 2 lightmaps

This topic is 3646 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello, I'm trying to display a quake 2 bsp map, and I'm currently having problems with lightmaps. The article on flipcode.com says that to get the width/height of the lightmap for a face, you use:
lightmap_width  = ceil(max_u / 16) - floor(min_u / 16) + 1
lightmap_height = ceil(max_v / 16) - floor(min_v / 16) + 1

These seem odd to me. Something that seems more correct to me:
lightmap_width  = ((int)(ceil(max_u) - floor(min_u))+15) / 16;
lightmap_height = ((int)(ceil(max_v) - floor(min_v))+15) / 16;

However, either both are wrong or the error is somewhere else. I'm preallocating a texture the size 2048,1024, lightmap_offset_x/y are pixel offsets into the texture that I update as I add more lightmaps to the texture. I calculate the u/v lightmap texture coordinates like this. I'm not sure this is correct either.
lightmap_u = (lightmap_offset_x + ((int)(floor(u)-(int)floor(min_u)) / 16)) / 2048.0;

lightmap_v = (lightmap_offset_y + ((int)(floor(v)-(int)floor(min_v)) / 16)) / 1024.0;

What puzzles me though is that the resulting lightmap that I'm getting is extremely dark, even with wrong width/height/texture coordinates, the rgb colors that that I'm retreiving from the lightmap lump should've been much brighter, I'm assuming 0=dark, 255=bright ? thanks, -- Sigurd Lerstad

Share on other sites
Hmm, Quake 2... that's an old game. What formats are the lightmaps in? Perhaps they're using palettes rather than direct color information?

Share on other sites
Quote:
 Original post by Captain PHmm, Quake 2... that's an old game. What formats are the lightmaps in? Perhaps they're using palettes rather than direct color information?

No, it says that lightmaps are 24-bit rgb:

http://www.flipcode.com/archives/Quake_2_BSP_File_Format.shtml

--

• 18
• 11
• 16
• 9
• 49
• Forum Statistics

• Total Topics
631397
• Total Posts
2999783
×