Jump to content
  • Advertisement
Sign in to follow this  
Sigurd Lerstad

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
Quote:
Original post by Captain P
Hmm, 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

--
Sigurd Lerstad

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!