Tutorial *95*

All this code here LordHavoc's I just debugged some stuff and made it into a tutorial. This tutorial will make it so that your engine will use an external .lit file to apply colored lights to quake levels. I would not recommend using this tutorial if you already have BSP 30 support.

In cl_main.c
Find Cl_AllocDlight
And add this:


dl->color [0] = dl->color[1] = dl->color[2] = 1; //LordHavoc Lit. Support after every occurence of  dl->key = key;

In client.h
Find the dlight_t struct add add this to it


vec3_t color; //LordHavoc Lit. Support

In glmodel.c

Find Mod_LoadLighting
Replace that function with this one


void Mod_LoadLighting (lump_t *l)

{

	// LordHavoc: .lit support begin

	/* LordHavoc: original code

	if (!l->filelen)

	{

		loadmodel->lightdata = NULL;

		return;

	}

	loadmodel->lightdata = Hunk_AllocName ( l->filelen, loadname);

	memcpy (loadmodel->lightdata, mod_base + l->fileofs, l->filelen);

	*/

	int i;

	byte *in, *out, *data;

	byte d;

	char litfilename[1024];

	loadmodel->lightdata = NULL;

	// LordHavoc: check for a .lit file

	strcpy(litfilename, loadmodel->name);

	COM_StripExtension(litfilename, litfilename);

	strcat(litfilename, ".lit");

	data = (byte*) COM_LoadHunkFile (litfilename, false);

	if (data)

	{

		if (data[0] == 'Q' && data[1] == 'L' && data[2] == 'I' && data[3] == 'T')

		{

			i = LittleLong(((int *)data)[1]);

			if (i == 1)

			{

				Con_DPrintf("%s loaded", litfilename);

				loadmodel->lightdata = data + 8;

				return;

			}

			else

				Con_Printf("Unknown .lit file version (%d)\n", i);

		}

		else

			Con_Printf("Corrupt .lit file (old version?), ignoring\n");

	}

	// LordHavoc: no .lit found, expand the white lighting data to color

	if (!l->filelen)

		return;

	loadmodel->lightdata = Hunk_AllocName ( l->filelen*3, litfilename);

	in = loadmodel->lightdata + l->filelen*2; // place the file at the end, so it will not be overwritten until the very last write

	out = loadmodel->lightdata;

	memcpy (in, mod_base + l->fileofs, l->filelen);

	for (i = 0;i < l->filelen;i++)

	{

		d = *in++;

		*out++ = d;

		*out++ = d;

		*out++ = d;

	}

	// LordHavoc: .lit support end

}

Find Mod_LoadFaces Find this piece of code and comment it out


out->samples = loadmodel->lightdata + i; and add this after it out->samples = loadmodel->lightdata + (i * 3); // LordHavoc

In gl_rlight.c find R_MarkLights and replace the entire function with this one


/*

=============

R_MarkLights

=============

*/

void R_MarkLights (dlight_t *light, int bit, mnode_t *node)

{

	mplane_t	*splitplane;

	float		dist;

	msurface_t	*surf;

	int			i;

	// LordHavoc: .lit support begin (actually this is just a major lighting speedup, no relation to color :)

	float		l, maxdist;

	int			j, s, t;

	vec3_t		impact;

loc0:

	// LordHavoc: .lit support end



	if (node->contents < 0)

		return;



	splitplane = node->plane; // LordHavoc: original code

	// LordHavoc: .lit support (actually this is just a major lighting speedup, no relation to color :)

	if (splitplane->type < 3)

		dist = light->origin[splitplane->type] - splitplane->dist;

	else

		dist = DotProduct (light->origin, splitplane->normal) - splitplane->dist; // LordHavoc: original code

	// LordHavoc: .lit support end



	if (dist > light->radius)

	{

		// LordHavoc: .lit support begin (actually this is just a major lighting speedup, no relation to color :)

		//R_MarkLights (light, bit, node->children[0]); // LordHavoc: original code

		//return; // LordHavoc: original code

		node = node->children[0];

		goto loc0;

		// LordHavoc: .lit support end

	}

	if (dist < -light->radius)

	{

		// LordHavoc: .lit support begin (actually this is just a major lighting speedup, no relation to color :)

		//R_MarkLights (light, bit, node->children[1]); // LordHavoc: original code

		//return; // LordHavoc: original code

		node = node->children[1];

		goto loc0;

		// LordHavoc: .lit support end

	}



	maxdist = light->radius*light->radius; // LordHavoc: .lit support (actually this is just a major lighting speedup, no relation to color :)

// mark the polygons

	surf = cl.worldmodel->surfaces + node->firstsurface;

	for (i=0 ; inumsurfaces ; i++, surf++)

	{

		// LordHavoc: .lit support begin (actually this is just a major lighting speedup, no relation to color :)

		/* LordHavoc: original code

		if (surf->dlightframe != r_dlightframecount)

		{

			surf->dlightbits = 0;

			surf->dlightframe = r_dlightframecount;

		}

		surf->dlightbits |= bit;

		*/

		// LordHavoc: MAJOR dynamic light speedup here, eliminates marking of surfaces that are too far away from light, thus preventing unnecessary renders and uploads

		for (j=0 ; j<3 ; j++)

			impact[j] = light->origin[j] - surf->plane->normal[j]*dist;

		// clamp center of light to corner and check brightness

		l = DotProduct (impact, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3] - surf->texturemins[0];

		s = l+0.5;if (s < 0) s = 0;else if (s > surf->extents[0]) s = surf->extents[0];

		s = l - s;

		l = DotProduct (impact, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3] - surf->texturemins[1];

		t = l+0.5;if (t < 0) t = 0;else if (t > surf->extents[1]) t = surf->extents[1];

		t = l - t;

		// compare to minimum light

		if ((s*s+t*t+dist*dist) < maxdist)

		{

			if (surf->dlightframe != r_dlightframecount) // not dynamic until now

			{

				surf->dlightbits = bit;

				surf->dlightframe = r_dlightframecount;

			}

			else // already dynamic

				surf->dlightbits |= bit;

		}

		// LordHavoc: .lit support end

	}



	// LordHavoc: .lit support begin (actually this is just a major lighting speedup, no relation to color :)

	if (node->children[0]->contents >= 0)

		R_MarkLights (light, bit, node->children[0]); // LordHavoc: original code

	if (node->children[1]->contents >= 0)

		R_MarkLights (light, bit, node->children[1]); // LordHavoc: original code

	// LordHavoc: .lit support end

}

Still in gl_rlight.c find Light Sampling and replace the entire function with this one


/*

=============================================================================



LIGHT SAMPLING



=============================================================================

*/



mplane_t		*lightplane;

vec3_t			lightspot;

// LordHavoc: .lit support begin

// LordHavoc: original code replaced entirely

int RecursiveLightPoint (vec3_t color, mnode_t *node, vec3_t start, vec3_t end)

{

	float		front, back, frac;

	vec3_t		mid;

loc0:

	if (node->contents < 0)

		return false;		// didn't hit anything



// calculate mid point

	if (node->plane->type < 3)

	{

		front = start[node->plane->type] - node->plane->dist;

		back = end[node->plane->type] - node->plane->dist;

	}

	else

	{

		front = DotProduct(start, node->plane->normal) - node->plane->dist;

		back = DotProduct(end, node->plane->normal) - node->plane->dist;

	}

	// LordHavoc: optimized recursion

	if ((back < 0) == (front < 0))

//		return RecursiveLightPoint (color, node->children[front < 0], start, end);

	{

		node = node->children[front < 0];

		goto loc0;

	}



	frac = front / (front-back);

	mid[0] = start[0] + (end[0] - start[0])*frac;

	mid[1] = start[1] + (end[1] - start[1])*frac;

	mid[2] = start[2] + (end[2] - start[2])*frac;



// go down front side

	if (RecursiveLightPoint (color, node->children[front < 0], start, mid))

		return true;	// hit something

	else

	{

		int i, ds, dt;

		msurface_t *surf;

	// check for impact on this node

		VectorCopy (mid, lightspot);

		lightplane = node->plane;

		surf = cl.worldmodel->surfaces + node->firstsurface;

		for (i = 0;i < node->numsurfaces;i++, surf++)

		{

			if (surf->flags & SURF_DRAWTILED)

				continue;	// no lightmaps

			ds = (int) ((float) DotProduct (mid, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3]);

			dt = (int) ((float) DotProduct (mid, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3]);

			if (ds < surf->texturemins[0] || dt < surf->texturemins[1])

				continue;



			ds -= surf->texturemins[0];

			dt -= surf->texturemins[1];



			if (ds > surf->extents[0] || dt > surf->extents[1])

				continue;

			if (surf->samples)

			{

				// LordHavoc: enhanced to interpolate lighting

				byte *lightmap;

				int maps, line3, dsfrac = ds & 15, dtfrac = dt & 15, r00 = 0, g00 = 0, b00 = 0, r01 = 0, g01 = 0, b01 = 0, r10 = 0, g10 = 0, b10 = 0, r11 = 0, g11 = 0, b11 = 0;

				float scale;

				line3 = ((surf->extents[0]>>4)+1)*3;

				lightmap = surf->samples + ((dt>>4) * ((surf->extents[0]>>4)+1) + (ds>>4))*3; // LordHavoc: *3 for color

				for (maps = 0;maps < MAXLIGHTMAPS && surf->styles[maps] != 255;maps++)

				{

					scale = (float) d_lightstylevalue[surf->styles[maps]] * 1.0 / 256.0;

					r00 += (float) lightmap[      0] * scale;g00 += (float) lightmap[      1] * scale;b00 += (float) lightmap[2] * scale;

					r01 += (float) lightmap[      3] * scale;g01 += (float) lightmap[      4] * scale;b01 += (float) lightmap[5] * scale;

					r10 += (float) lightmap[line3+0] * scale;g10 += (float) lightmap[line3+1] * scale;b10 += (float) lightmap[line3+2] * scale;

					r11 += (float) lightmap[line3+3] * scale;g11 += (float) lightmap[line3+4] * scale;b11 += (float) lightmap[line3+5] * scale;

					lightmap += ((surf->extents[0]>>4)+1) * ((surf->extents[1]>>4)+1)*3; // LordHavoc: *3 for colored lighting

				}

				color[0] += (float) ((int) ((((((((r11-r10) * dsfrac) >> 4) + r10)-((((r01-r00) * dsfrac) >> 4) + r00)) * dtfrac) >> 4) + ((((r01-r00) * dsfrac) >> 4) + r00)));

				color[1] += (float) ((int) ((((((((g11-g10) * dsfrac) >> 4) + g10)-((((g01-g00) * dsfrac) >> 4) + g00)) * dtfrac) >> 4) + ((((g01-g00) * dsfrac) >> 4) + g00)));

				color[2] += (float) ((int) ((((((((b11-b10) * dsfrac) >> 4) + b10)-((((b01-b00) * dsfrac) >> 4) + b00)) * dtfrac) >> 4) + ((((b01-b00) * dsfrac) >> 4) + b00)));

			}

			return true; // success

		}

	// go down back side

		return RecursiveLightPoint (color, node->children[front >= 0], mid, end);

	}

}

vec3_t lightcolor; // LordHavoc: used by model rendering

int R_LightPoint (vec3_t p)

{

	vec3_t		end;



	if (r_fullbright.value || !cl.worldmodel->lightdata)

	{

		lightcolor[0] = lightcolor[1] = lightcolor[2] = 255;

		return 255;

	}



	end[0] = p[0];

	end[1] = p[1];

	end[2] = p[2] - 2048;

	lightcolor[0] = lightcolor[1] = lightcolor[2] = 0;

	RecursiveLightPoint (lightcolor, cl.worldmodel->nodes, p, end);

	return ((lightcolor[0] + lightcolor[1] + lightcolor[2]) * (1.0f / 3.0f));

}

// LordHavoc: .lit support end


In gl_rmain.c find Alias Models
Comment out


float	shadelight, ambientlight;

Now in Gl_DrawAliasFrame
Add


extern vec3_t lightcolor; // LordHavoc: .lit support to the definitions at the top

Comment out


l = shadedots[verts->lightnormalindex] * shadelight;

also comment out


glColor3f (l, l, l);

Now add this after the code that you commented out


l = shadedots[verts->lightnormalindex];

glColor3f (l * lightcolor[0], l * lightcolor[1], l * lightcolor[2]);


Now find R_DrawAliasModel
Replace the entire function with this one


void R_DrawAliasModel (entity_t *e)

{

	int			i, j;

	int			lnum;

	vec3_t		dist;

	float		add;

	model_t		*clmodel;

	vec3_t		mins, maxs;

	aliashdr_t	*paliashdr;

	trivertx_t	*verts, *v;

	int			index;

	float		s, t, an;

	int			anim;

	clmodel = currententity->model;

	VectorAdd (currententity->origin, clmodel->mins, mins);

	VectorAdd (currententity->origin, clmodel->maxs, maxs);

	if (R_CullBox (mins, maxs))

		return;



	VectorCopy (currententity->origin, r_entorigin);

	VectorSubtract (r_origin, r_entorigin, modelorg);

	//

	// get lighting information

	//

	// LordHavoc: .lit support begin

	//ambientlight = shadelight = R_LightPoint (currententity->origin); // LordHavoc: original code, removed shadelight and ambientlight

	R_LightPoint(currententity->origin); // LordHavoc: lightcolor is all that matters from this

	// LordHavoc: .lit support end

	// allways give the gun some light

	// LordHavoc: .lit support begin

	//if (e == &cl.viewent && ambientlight < 24) // LordHavoc: original code

	//	ambientlight = shadelight = 24; // LordHavoc: original code

	if (e == &cl.viewent)

	{

		if (lightcolor[0] < 24)

			lightcolor[0] = 24;

		if (lightcolor[1] < 24)

			lightcolor[1] = 24;

		if (lightcolor[2] < 24)

			lightcolor[2] = 24;

	}

	// LordHavoc: .lit support end

	for (lnum=0 ; lnum= cl.time)

		{

			VectorSubtract (currententity->origin,

							cl_dlights[lnum].origin,

							dist);

			add = cl_dlights[lnum].radius - Length(dist);

			// LordHavoc: .lit support begin

			/* LordHavoc: original code

			if (add > 0) {

				ambientlight += add;

				//ZOID models should be affected by dlights as well

				shadelight += add;

			}

			*/

			if (add > 0)

			{

				lightcolor[0] += add * cl_dlights[lnum].color[0];

				lightcolor[1] += add * cl_dlights[lnum].color[1];

				lightcolor[2] += add * cl_dlights[lnum].color[2];

			}

			// LordHavoc: .lit support end

 		}

	}

	// clamp lighting so it doesn't overbright as much

	// LordHavoc: .lit support begin

	/* LordHavoc: original code removed

	if (ambientlight > 128)

		ambientlight = 128;

	if (ambientlight + shadelight > 192)

		shadelight = 192 - ambientlight;

	*/

	// LordHavoc: .lit support end

	// ZOID: never allow players to go totally black

	i = currententity - cl_entities;

	if (i >= 1 && i<=cl.maxclients /* && !strcmp (currententity->model->name, "progs/player.mdl") */)

	// LordHavoc: .lit support begin

	//	if (ambientlight < 8) // LordHavoc: original code

	//		ambientlight = shadelight = 8; // LordHavoc: original code

	{

		if (lightcolor[0] < 8)

			lightcolor[0] = 8;

		if (lightcolor[1] < 8)

			lightcolor[1] = 8;

		if (lightcolor[2] < 8)

			lightcolor[2] = 8;

	}

	// LordHavoc: .lit support end

	// HACK HACK HACK -- no fullbright colors, so make torches full light

	if (!strcmp (clmodel->name, "progs/flame2.mdl")

		|| !strcmp (clmodel->name, "progs/flame.mdl") )

	// LordHavoc: .lit support begin

	//	ambientlight = shadelight = 256; // LordHavoc: original code

		lightcolor[0] = lightcolor[1] = lightcolor[2] = 256;

	// LordHavoc: .lit support end

	shadedots = r_avertexnormal_dots[((int)(e->angles[1] * (SHADEDOT_QUANT / 360.0))) & (SHADEDOT_QUANT - 1)];

	// LordHavoc: .lit support begin

	//shadelight = shadelight / 200.0; // LordHavoc: original code

	VectorScale(lightcolor, 1.0f / 200.0f, lightcolor);

	// LordHavoc: .lit support end



	an = e->angles[1]/180*M_PI;

	shadevector[0] = cos(-an);

	shadevector[1] = sin(-an);

	shadevector[2] = 1;

	VectorNormalize (shadevector);

	//

	// locate the proper data

	//

	paliashdr = (aliashdr_t *)Mod_Extradata (currententity->model);

	c_alias_polys += paliashdr->numtris;

	//

	// draw all the triangles

	//

	GL_DisableMultitexture();

    glPushMatrix ();

	R_RotateForEntity (e);

	if (!strcmp (clmodel->name, "progs/eyes.mdl") && gl_doubleeyes.value) {

		glTranslatef (paliashdr->scale_origin[0], paliashdr->scale_origin[1], paliashdr->scale_origin[2] - (22 + 8));

// double size of eyes, since they are really hard to see in gl

		glScalef (paliashdr->scale[0]*2, paliashdr->scale[1]*2, paliashdr->scale[2]*2);

	} else {

		glTranslatef (paliashdr->scale_origin[0], paliashdr->scale_origin[1], paliashdr->scale_origin[2]);

		glScalef (paliashdr->scale[0], paliashdr->scale[1], paliashdr->scale[2]);

	}

	anim = (int)(cl.time*10) & 3;

    GL_Bind(paliashdr->gl_texturenum[currententity->skinnum][anim]);

	// we can't dynamically colormap textures, so they are cached

	// seperately for the players.  Heads are just uncolored.

	if (currententity->colormap != vid.colormap && !gl_nocolors.value)

	{

		i = currententity - cl_entities;

		if (i >= 1 && i<=cl.maxclients /* && !strcmp (currententity->model->name, "progs/player.mdl") */)

		    GL_Bind(playertextures - 1 + i);

	}

	if (gl_smoothmodels.value)

		glShadeModel (GL_SMOOTH);

	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

	if (gl_affinemodels.value)

		glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);

	R_SetupAliasFrame (currententity->frame, paliashdr);

	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

	glShadeModel (GL_FLAT);

	if (gl_affinemodels.value)

		glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

	glPopMatrix ();

	if (r_shadows.value)

	{

		glPushMatrix ();

		R_RotateForEntity (e);

		glDisable (GL_TEXTURE_2D);

		glEnable (GL_BLEND);

		glColor4f (0,0,0,0.5);

		GL_DrawAliasShadow (paliashdr, lastposenum);

		glEnable (GL_TEXTURE_2D);

		glDisable (GL_BLEND);

		glColor4f (1,1,1,1);

		glPopMatrix ();

	}

}

Now find R_drawViewModel
Comment out this


    float		ambient[4], diffuse[4];

	int			j;

	int			lnum;

	vec3_t		dist;

	float		add;

	dlight_t	*dl;

	int			ambientlight, shadelight;

and also comment out this because all of thos code was useless


j = R_LightPoint (currententity->origin);

	if (j < 24)

		j = 24;		// allways give some light on gun

	ambientlight = j;

	shadelight = j;

// add dynamic lights

	for (lnum=0 ; lnumradius)

			continue;

		if (!dl->radius)

			continue;

		if (dl->die < cl.time)

			continue;

		VectorSubtract (currententity->origin, dl->origin, dist);

		add = dl->radius - Length(dist);

		if (add > 0)

			ambientlight += add;

	}

	ambient[0] = ambient[1] = ambient[2] = ambient[3] = (float)ambientlight / 128;

	diffuse[0] = diffuse[1] = diffuse[2] = diffuse[3] = (float)shadelight / 128;



Now in gl_rsurf.c
Add:


unsigned		blocklights[18*18*3]; // LordHavoc: .lit support (*3 for RGB) to the definitions at the top

Comment out


unsigned   blocklights[18*18];

Now find R_AddDynamicLights
And add this to the definitions at the top of the function


// LordHavoc: .lit support begin

	float		cred, cgreen, cblue, brightness;

	unsigned	*bl;

// LordHavoc: .lit support end

Add this code after


local[0] -= surf->texturemins[0];

		            local[1] -= surf->texturemins[1];

add this:


// LordHavoc: .lit support begin

		bl = blocklights;

		cred = cl_dlights[lnum].color[0] * 256.0f;

		cgreen = cl_dlights[lnum].color[1] * 256.0f;

		cblue = cl_dlights[lnum].color[2] * 256.0f;

// LordHavoc: .lit support end

Comment out


blocklights[t*smax + s] += (rad - dist)*256;

and add this after it


                {

					brightness = rad - dist;

					bl[0] += (int) (brightness * cred);

					bl[1] += (int) (brightness * cgreen);

					bl[2] += (int) (brightness * cblue);

				}

				bl += 3;

Now find R_BuildLightMap and replace the entire function with this one


void R_BuildLightMap (msurface_t *surf, byte *dest, int stride)

{

	int			smax, tmax;

	int			t;

	int			i, j, size;

	byte		*lightmap;

	unsigned	scale;

	int			maps;

	int			lightadj[4];

	unsigned	*bl;



	surf->cached_dlight = (surf->dlightframe == r_framecount);



	smax = (surf->extents[0]>>4)+1;

	tmax = (surf->extents[1]>>4)+1;

	size = smax*tmax;

	lightmap = surf->samples;



// set to full bright if no light data

	if (r_fullbright.value || !cl.worldmodel->lightdata)

	{

		// LordHavoc: .lit support begin

		bl = blocklights;

		for (i=0 ; i< MAXLIGHTMAPS && surf->styles[maps] != 255 ;

			 maps++)

		{

			scale = d_lightstylevalue[surf->styles[maps]];

			surf->cached_light[maps] = scale;	// 8.8 fraction

			// LordHavoc: .lit support begin

			bl = blocklights;

			for (i=0 ; idlightframe == r_framecount)

		R_AddDynamicLights (surf);



// bound, invert, and shift

store:

	switch (gl_lightmap_format)

	{

	case GL_RGBA:

		stride -= (smax<<2);

		bl = blocklights;

		for (i=0 ; i>= 7;

				if (t > 255)

					t = 255;

				dest[3] = 255-t;

				dest += 4;

				*/

				// LordHavoc: positive lighting (would be 255-t if it were inverse like glquake was)

				t = *bl++ >> 7;if (t > 255) t = 255;*dest++ = t;

				t = *bl++ >> 7;if (t > 255) t = 255;*dest++ = t;

				t = *bl++ >> 7;if (t > 255) t = 255;*dest++ = t;

				*dest++ = 255;

				// LordHavoc: .lit support end

			}

		}

		break;

	case GL_ALPHA:

	case GL_LUMINANCE:

	case GL_INTENSITY:

		bl = blocklights;

		for (i=0 ; i>= 7; // LordHavoc: original code

				t = ((bl[0] + bl[1] + bl[2]) * 85) >> 15; // LordHavoc: basically / 3, but faster and combined with >> 7 shift down, note: actual number would be 85.3333...

				bl += 3;

				// LordHavoc: .lit support end

				if (t > 255)

					t = 255;

				dest[j] = 255-t;

			}

		}

		break;

	default:

		Sys_Error ("Bad lightmap format");

	}

}

Now find R_DrawSequentialPoly
Comment out


glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);

add this after the 3rd if statement


// LordHavoc: .lit support begin

			if (gl_lightmap_format == GL_RGBA)

				glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // LordHavoc: not inverse lighting

			else

				glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND); // LordHavoc: original code

			// LordHavoc: .lit support end


Now find R_RenderDynamicLightMaps
And add this after the first if statement


       // LordHavoc: .lit support begin

		if (gl_lightmap_format == GL_RGBA)

			glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // LordHavoc: not inverse lighting

		else

			glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND); // LordHavoc: original code

		// LordHavoc: .lit support end

Now Find R_BlendLightMaps
And add this after the elseif statement


// LordHavoc: .lit support begin

	else if (gl_lightmap_format == GL_RGBA)

	{

		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

		glColor3f (1,1,1);

		glBlendFunc(GL_ZERO, GL_SRC_COLOR);

	}

	// LordHavoc: .lit support end

And add this after the last elseif statement in the function


// LordHavoc: .lit support begin

	else if (gl_lightmap_format == GL_RGBA)

		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

	// LordHavoc: .lit support end


Find Gl_BuildLightMaps
and comment out


gl_lightmap_format = GL_LUMINANCE;

if (isPermedia)

gl_lightmap_format = GL_RGBA;

and add


gl_lightmap_format = GL_RGBA;

after it

Ok thats it compile and run and you will have an engine that supports .lits Goto http://www.geocities.com/mh_quake and get a program called mh_light and use it on your existing quake maps to make them colored.

Any problems E-Mail at qghastlyq@hotmail.com


 
Sign up
Login:
Passwd:
[Remember Me]