mirror of
https://git.code.sf.net/p/quake/quakeforge-old
synced 2024-11-25 13:21:04 +00:00
Colored dlights. We already had them if you had gl_flashblend 1, but they
looked kinda silly IMO. Turn off the stupid bubbles, we have real colored dlight now! I may put up some of the "outtake" screenshots of the broken lightmap code as I was writing the support. Some of them look cool. =>
This commit is contained in:
parent
5707c81f3a
commit
271fbb4c8a
2 changed files with 68 additions and 33 deletions
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/*
|
||||||
|
r_light.c
|
||||||
Copyright (C) 1996-1997 Id Software, Inc.
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
Copyright (C) 1999,2000 contributors of the QuakeForge project
|
Copyright (C) 1999,2000 contributors of the QuakeForge project
|
||||||
Please see the file "AUTHORS" for a list of contributors
|
Please see the file "AUTHORS" for a list of contributors
|
||||||
|
@ -19,14 +20,13 @@ along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
// r_light.c
|
|
||||||
|
|
||||||
#include "qtypes.h"
|
#include <qtypes.h>
|
||||||
#include "quakedef.h"
|
#include <quakedef.h>
|
||||||
#include "glquake.h"
|
#include <glquake.h>
|
||||||
#include "client.h"
|
#include <client.h>
|
||||||
#include "mathlib.h"
|
#include <mathlib.h>
|
||||||
#include "view.h"
|
#include <view.h>
|
||||||
|
|
||||||
int r_dlightframecount;
|
int r_dlightframecount;
|
||||||
|
|
||||||
|
@ -118,13 +118,12 @@ void R_RenderDlight (dlight_t *light)
|
||||||
}
|
}
|
||||||
|
|
||||||
glBegin (GL_TRIANGLE_FAN);
|
glBegin (GL_TRIANGLE_FAN);
|
||||||
#if UQUAKE
|
if (light->color[0] || light->color[1] || light->color[2]
|
||||||
glColor3f (0.2,0.1,0.0); // uquake had this (taniwha)
|
|| light->color[3]) // is there a color?
|
||||||
glColor3f (0.2,0.1,0.05); // changed dimlight effect
|
glColor4f (light->color[0], light->color[1],
|
||||||
#else
|
light->color[2], light->color[3]);
|
||||||
glColor4f (light->color[0], light->color[1], light->color[2],
|
else
|
||||||
light->color[3]);
|
glColor3f (0.2,0.1,0.05); // nope, use default
|
||||||
#endif
|
|
||||||
for (i=0 ; i<3 ; i++)
|
for (i=0 ; i<3 ; i++)
|
||||||
v[i] = light->origin[i] - vpn[i]*rad;
|
v[i] = light->origin[i] - vpn[i]*rad;
|
||||||
glVertex3fv (v);
|
glVertex3fv (v);
|
||||||
|
|
|
@ -38,7 +38,8 @@ int lightmap_bytes; // 1, 2, or 4
|
||||||
|
|
||||||
int lightmap_textures;
|
int lightmap_textures;
|
||||||
|
|
||||||
unsigned blocklights[18*18];
|
unsigned blocklights[18*18];
|
||||||
|
unsigned cblocklights[3][18*18];
|
||||||
|
|
||||||
#define BLOCK_WIDTH 128
|
#define BLOCK_WIDTH 128
|
||||||
#define BLOCK_HEIGHT 128
|
#define BLOCK_HEIGHT 128
|
||||||
|
@ -73,14 +74,15 @@ R_AddDynamicLights
|
||||||
*/
|
*/
|
||||||
void R_AddDynamicLights (msurface_t *surf)
|
void R_AddDynamicLights (msurface_t *surf)
|
||||||
{
|
{
|
||||||
int lnum;
|
int lnum;
|
||||||
int sd, td;
|
int sd, td;
|
||||||
float dist, rad, minlight;
|
float dist, rad, minlight;
|
||||||
vec3_t impact, local;
|
vec3_t impact, local;
|
||||||
int s, t;
|
int s, t;
|
||||||
int i;
|
int i;
|
||||||
int smax, tmax;
|
int smax, tmax;
|
||||||
mtexinfo_t *tex;
|
mtexinfo_t *tex;
|
||||||
|
dlight_t *dl;
|
||||||
|
|
||||||
smax = (surf->extents[0]>>4)+1;
|
smax = (surf->extents[0]>>4)+1;
|
||||||
tmax = (surf->extents[1]>>4)+1;
|
tmax = (surf->extents[1]>>4)+1;
|
||||||
|
@ -92,8 +94,8 @@ void R_AddDynamicLights (msurface_t *surf)
|
||||||
continue; // not lit by this light
|
continue; // not lit by this light
|
||||||
|
|
||||||
rad = cl_dlights[lnum].radius;
|
rad = cl_dlights[lnum].radius;
|
||||||
dist = DotProduct (cl_dlights[lnum].origin, surf->plane->normal) -
|
dist = DotProduct (cl_dlights[lnum].origin,
|
||||||
surf->plane->dist;
|
surf->plane->normal) - surf->plane->dist;
|
||||||
rad -= fabs(dist);
|
rad -= fabs(dist);
|
||||||
minlight = cl_dlights[lnum].minlight;
|
minlight = cl_dlights[lnum].minlight;
|
||||||
if (rad < minlight)
|
if (rad < minlight)
|
||||||
|
@ -126,8 +128,21 @@ void R_AddDynamicLights (msurface_t *surf)
|
||||||
dist = sd + (td>>1);
|
dist = sd + (td>>1);
|
||||||
else
|
else
|
||||||
dist = td + (sd>>1);
|
dist = td + (sd>>1);
|
||||||
if (dist < minlight)
|
if (dist < minlight) {
|
||||||
blocklights[t*smax + s] += (rad - dist)*256;
|
dl = &cl_dlights[lnum];
|
||||||
|
cblocklights[0][t*smax + s] +=
|
||||||
|
(rad - dist)
|
||||||
|
*(dl->color[0]*256);
|
||||||
|
cblocklights[1][t*smax + s] +=
|
||||||
|
(rad - dist)
|
||||||
|
*(dl->color[1]*256);
|
||||||
|
cblocklights[2][t*smax + s] +=
|
||||||
|
(rad - dist)
|
||||||
|
*(dl->color[2]*256);
|
||||||
|
blocklights[t*smax +s] +=
|
||||||
|
(rad - dist)
|
||||||
|
*(dl->color[3]*256);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,7 +164,7 @@ void R_BuildLightMap (msurface_t *surf, byte *dest, int stride)
|
||||||
byte *lightmap;
|
byte *lightmap;
|
||||||
unsigned scale;
|
unsigned scale;
|
||||||
int maps;
|
int maps;
|
||||||
unsigned *bl;
|
unsigned *bl, *rbl, *gbl, *bbl;
|
||||||
|
|
||||||
surf->cached_dlight = (surf->dlightframe == r_framecount);
|
surf->cached_dlight = (surf->dlightframe == r_framecount);
|
||||||
|
|
||||||
|
@ -159,15 +174,21 @@ void R_BuildLightMap (msurface_t *surf, byte *dest, int stride)
|
||||||
lightmap = surf->samples;
|
lightmap = surf->samples;
|
||||||
|
|
||||||
// set to full bright if no light data
|
// set to full bright if no light data
|
||||||
if (/* r_fullbright->value || */ !cl.worldmodel->lightdata)
|
if (r_fullbright->value || !cl.worldmodel->lightdata)
|
||||||
{
|
{
|
||||||
for (i=0 ; i<size ; i++)
|
for (i=0 ; i<size ; i++)
|
||||||
|
cblocklights[0][i] =
|
||||||
|
cblocklights[1][i] =
|
||||||
|
cblocklights[2][i] =
|
||||||
blocklights[i] = 255*256;
|
blocklights[i] = 255*256;
|
||||||
goto store;
|
goto store;
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear to no light
|
// clear to no light
|
||||||
for (i=0 ; i<size ; i++)
|
for (i=0 ; i<size ; i++)
|
||||||
|
cblocklights[0][i] =
|
||||||
|
cblocklights[1][i] =
|
||||||
|
cblocklights[2][i] =
|
||||||
blocklights[i] = 0;
|
blocklights[i] = 0;
|
||||||
|
|
||||||
// add all the lightmaps
|
// add all the lightmaps
|
||||||
|
@ -178,7 +199,12 @@ void R_BuildLightMap (msurface_t *surf, byte *dest, int stride)
|
||||||
scale = d_lightstylevalue[surf->styles[maps]];
|
scale = d_lightstylevalue[surf->styles[maps]];
|
||||||
surf->cached_light[maps] = scale; // 8.8 fraction
|
surf->cached_light[maps] = scale; // 8.8 fraction
|
||||||
for (i=0 ; i<size ; i++)
|
for (i=0 ; i<size ; i++)
|
||||||
|
{
|
||||||
|
cblocklights[0][i] += lightmap[i] * scale;
|
||||||
|
cblocklights[1][i] += lightmap[i] * scale;
|
||||||
|
cblocklights[2][i] += lightmap[i] * scale;
|
||||||
blocklights[i] += lightmap[i] * scale;
|
blocklights[i] += lightmap[i] * scale;
|
||||||
|
}
|
||||||
lightmap += size; // skip to next lightmap
|
lightmap += size; // skip to next lightmap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,16 +218,22 @@ store:
|
||||||
{
|
{
|
||||||
case GL_RGBA:
|
case GL_RGBA:
|
||||||
stride -= (smax<<2);
|
stride -= (smax<<2);
|
||||||
|
rbl = cblocklights[0];
|
||||||
|
gbl = cblocklights[1];
|
||||||
|
bbl = cblocklights[2];
|
||||||
bl = blocklights;
|
bl = blocklights;
|
||||||
for (i=0 ; i<tmax ; i++, dest += stride)
|
for (i=0 ; i<tmax ; i++, dest += stride)
|
||||||
{
|
{
|
||||||
for (j=0 ; j<smax ; j++)
|
for (j=0 ; j<smax ; j++)
|
||||||
{
|
{
|
||||||
|
t = *rbl++;
|
||||||
|
dest[0] = 255 - min(t >> 7, 255);
|
||||||
|
t = *gbl++;
|
||||||
|
dest[1] = 255 - min(t >> 7, 255);
|
||||||
|
t = *bbl++;
|
||||||
|
dest[2] = 255 - min(t >> 7, 255);
|
||||||
t = *bl++;
|
t = *bl++;
|
||||||
t >>= 7;
|
dest[3] = 255 - min(t >> 7, 255);
|
||||||
if (t > 255)
|
|
||||||
t = 255;
|
|
||||||
dest[3] = 255-t;
|
|
||||||
dest += 4;
|
dest += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -685,7 +717,9 @@ void R_BlendLightmaps (void)
|
||||||
|
|
||||||
glDepthMask (0); // don't bother writing Z
|
glDepthMask (0); // don't bother writing Z
|
||||||
|
|
||||||
if (gl_lightmap_format == GL_LUMINANCE)
|
if (gl_lightmap_format == GL_RGBA)
|
||||||
|
glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
|
||||||
|
else if (gl_lightmap_format == GL_LUMINANCE)
|
||||||
glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
|
glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
|
||||||
else if (gl_lightmap_format == GL_INTENSITY)
|
else if (gl_lightmap_format == GL_INTENSITY)
|
||||||
{
|
{
|
||||||
|
@ -751,7 +785,9 @@ void R_BlendLightmaps (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisable (GL_BLEND);
|
glDisable (GL_BLEND);
|
||||||
if (gl_lightmap_format == GL_LUMINANCE)
|
if (gl_lightmap_format == GL_RGBA)
|
||||||
|
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
else if (gl_lightmap_format == GL_LUMINANCE)
|
||||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
else if (gl_lightmap_format == GL_INTENSITY)
|
else if (gl_lightmap_format == GL_INTENSITY)
|
||||||
{
|
{
|
||||||
|
@ -1593,7 +1629,7 @@ void GL_BuildLightmaps (void)
|
||||||
texture_extension_number += MAX_LIGHTMAPS;
|
texture_extension_number += MAX_LIGHTMAPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_lightmap_format = GL_LUMINANCE;
|
gl_lightmap_format = GL_RGBA;
|
||||||
if (COM_CheckParm ("-lm_1"))
|
if (COM_CheckParm ("-lm_1"))
|
||||||
gl_lightmap_format = GL_LUMINANCE;
|
gl_lightmap_format = GL_LUMINANCE;
|
||||||
if (COM_CheckParm ("-lm_a"))
|
if (COM_CheckParm ("-lm_a"))
|
||||||
|
|
Loading…
Reference in a new issue