q3map lightmap question..

Started by
1 comment, last by eviltwigflipper 18 years, 6 months ago
If anyone has a couple seconds I am having a very wierd problem with lightmaps. In my quake3 BSP loader, I have a compiled map I made. Its either not generating any lightmaps, or theres something wrong with my code(which is probley the case). It says its generating one lightmap(for 4 different lights, with different colors?). Heres part of the log... reading C:/projects/DarkLight/bin/base/maps/justin/boxtest.bsp 50 drawSurfaces 1 lightmaps 58 light emitting surfaces When ever I try to load in a lightmap it says it has a size of one lightmap, but most of is just NULLS. When I upload it to GL it uploads the prevous texture. Heres the code for my lightmap loader...

/*
================================
Purpose: Creates world lights. 
================================
*/

void RenderSystem::GenerateWorldLights( WorldModel_t *WorldModel, byte *lightmap  ) {
	unsigned int lMapHandle = -1;

	glGenTextures(1, &lMapHandle);
	glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
	glBindTexture(GL_TEXTURE_2D, lMapHandle);

	ChangeGamma( (byte *)lightmap, 128*128*3, 10 );

	gluBuild2DMipmaps(GL_TEXTURE_2D,3,128,128, GL_RGB, GL_UNSIGNED_BYTE, lightmap);

	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);	
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	WorldModel->lightmaps.push_back(lMapHandle);
}

byte lightmap starts with 0 which doesn't seem right. Also the LightVolume lump is completelly null, even though there is allocated room for it. If anyone has a few minutes to help me it would be apprietcated. Thank You ; ).
Advertisement
I can't answer your question because it does not contain enough information. Please perform some more debugging or clarify some of the questions I have below.

Quote:Original post by eviltwigflipper
If anyone has a couple seconds I am having a very wierd problem with lightmaps. In my quake3 BSP loader, I have a compiled map I made. Its either not generating any lightmaps, or theres something wrong with my code(which is probley the case).

You forget to specify what's wrong. Is your program crashing? Do the lightmaps fail to show up? Does your program work properly with BSPs from Quake3 itself?

Quote:Original post by eviltwigflipper
It says its generating one lightmap(for 4 different lights, with different colors?).

Heres part of the log...
reading C:/projects/DarkLight/bin/base/maps/justin/boxtest.bsp
50 drawSurfaces
1 lightmaps
58 light emitting surfaces

Did you copy the code from somewhere? I ask this because your own log should mean much more to you than it would to anyone else...


Quote:Original post by eviltwigflipper
When ever I try to load in a lightmap it says it has a size of one lightmap, but most of is just NULLS. When I upload it to GL it uploads the prevous texture.

With NULL people normally refer to a pointer, do you get NULL pointers? Or is part of the color data zeros? The latter could be quite ok, because part of the lightmap will not be lit and therefore black.

Quote:Original post by eviltwigflipper

Heres the code for my lightmap loader...

*** Source Snippet Removed ***


Did you test the return value of gluBuild2DMipMap()? Does ChangeGamma() work properly? Did you test the OpenGL error value to check if something went wrong? Also the error need not be in this piece of code.

Quote:Original post by eviltwigflipper
byte lightmap starts with 0 which doesn't seem right.

That would mean that the first byte of the first pixel is 0. In other words that it has no red component, which is possible. Or do you mean that the pointer is NULL?

Quote:Original post by eviltwigflipper
Also the LightVolume lump is completelly null, even though there is allocated room for it. If anyone has a few minutes to help me it would be apprietcated.

The code you posted does not contain a variable or object called 'LightVolume' so it's impossible to tell what's wrong with it.

Tom
1) The log I posted was from q3map in the Q3Radiant log window.

2) The lightmap value is filled with 90% nulls(or zero's) in the BSP file.

3) I used a OpenGL Debugger(I forgot the name im at school right now), and the tex unit that represents the lightmap is filled with the last texture it loaded.

4) LightVolume im not doing anything specfic with besides loading it. Those values are also all incorrect...there all zeros as well. There is no valid light data in the map(atleast according to my code), even though I did full light on the map.

This topic is closed to new replies.

Advertisement