Quake3 Overbright & Lightmap

I try to render Q3 .BSP files and something seems to be strange.
my rendering procedure is:
vertexcolor * tex0 * lightmap
I use GL_MODULATE environment for Tex0 & Tex1
But everything is really dark (assuming vertexcolor<1.0 texcolor<1.0 and lightmap<1.0.
So my question is:
How to do a Quake3-Like Brightness method that allows RGB color scaling with factor greater than 1?
Thanks.

there are 2 things i can think of.
The main thing is probably you should use Vertex color, OR lightmap. I think i recall quake3 still had the option to use vertex colors calculated from the lightmaps as a really low-quality fast option.

The other thing could be the gamma ramp overbrightening that q3 used for a 0-2 dynamic range. You can use win32 Get/SetDeviceGammaRamp to change the gamma ramp to make everything double in brightness like they did. Then the lightmaps or vertex colors need to be adjusted accordingly.

M.

from memory quake3 actually changed the brightness of the textures when u loaded them in, the poormans gamma, but guaranteed to work!

Yeah like everyone said, you need to boost the brightness of the lightmaps. Here is a function from the DXQuake3 open source engine that does this:

DWORD c_BSP::BrightenColour(U8 r, U8 g, U8 b)
{
	int ir, ig, ib, Gamma, imax;
	float Factor;
	Gamma = 2-DQConsole.OverbrightBits;

	ir = ((int)r)<<Gamma;
	ig = ((int)g)<<Gamma;
	ib = ((int)b)<<Gamma;

	imax = max( ir, max( ig, ib ) );
	if(imax>255) {
		Factor = 255.0f/(float)imax;
		ir = (int)((float)ir*Factor);
		ig = (int)((float)ig*Factor);
		ib = (int)((float)ib*Factor);
	}

	return D3DCOLOR_RGBA( ir, ig, ib, 255 );
}

For more info, google for DXQuake3 and get the source.

-SirKnight

You know what, I may as well post a snippet from the function that calls the BrightenColor.

for(i=0;i<NumLightmaps;++i) {

		d3dcheckOK( TempTexture->GetLevelDesc( 0, &desc ) );
		d3dcheckOK( TempTexture->LockRect( 0, &LockedRect, NULL, 0 ) );

		for(u=0;u<128;++u) {
			pixel = (DWORD*)( (BYTE*)LockedRect.pBits+u*LockedRect.Pitch );
			for(v=0;v<128;++v,++pixel) {
				//BGRA (LSB first)
				*pixel = BrightenColour( Lightmap[i].map[u][v][0], Lightmap[i].map[u][v][1], Lightmap[i].map[u][v][2]);
			}
		}

		TempTexture->UnlockRect(0);

		LightmapTextureBuffer[i] = (c_Texture*) DQNewVoid( c_Texture );
		LightmapTextureBuffer[i]->LoadTextureFromSysmemTexture( TempTexture, FALSE, 0 );
	}

I hope that is self explanitory enough.

-SirKnight

Thanks everybody :slight_smile:
It’s great.
Boosting brightness of lightmaps is perfect.
And the SetDeviceGammaRamp function allows me to modulate brightness in realtime.
:smiley: