diff --git a/common/gl_rlight.c b/common/gl_rlight.c index 13e56e3..3f427ee 100644 --- a/common/gl_rlight.c +++ b/common/gl_rlight.c @@ -1,4 +1,5 @@ /* +r_light.c Copyright (C) 1996-1997 Id Software, Inc. Copyright (C) 1999,2000 contributors of the QuakeForge project 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. */ -// r_light.c -#include "qtypes.h" -#include "quakedef.h" -#include "glquake.h" -#include "client.h" -#include "mathlib.h" -#include "view.h" +#include +#include +#include +#include +#include +#include int r_dlightframecount; @@ -118,13 +118,12 @@ void R_RenderDlight (dlight_t *light) } glBegin (GL_TRIANGLE_FAN); -#if UQUAKE - glColor3f (0.2,0.1,0.0); // uquake had this (taniwha) - glColor3f (0.2,0.1,0.05); // changed dimlight effect -#else - glColor4f (light->color[0], light->color[1], light->color[2], - light->color[3]); -#endif + if (light->color[0] || light->color[1] || light->color[2] + || light->color[3]) // is there a color? + glColor4f (light->color[0], light->color[1], + light->color[2], light->color[3]); + else + glColor3f (0.2,0.1,0.05); // nope, use default for (i=0 ; i<3 ; i++) v[i] = light->origin[i] - vpn[i]*rad; glVertex3fv (v); diff --git a/common/gl_rsurf.c b/common/gl_rsurf.c index 9b7d46e..fd9babb 100644 --- a/common/gl_rsurf.c +++ b/common/gl_rsurf.c @@ -38,7 +38,8 @@ int lightmap_bytes; // 1, 2, or 4 int lightmap_textures; -unsigned blocklights[18*18]; +unsigned blocklights[18*18]; +unsigned cblocklights[3][18*18]; #define BLOCK_WIDTH 128 #define BLOCK_HEIGHT 128 @@ -73,14 +74,15 @@ R_AddDynamicLights */ void R_AddDynamicLights (msurface_t *surf) { - int lnum; - int sd, td; + int lnum; + int sd, td; float dist, rad, minlight; vec3_t impact, local; - int s, t; - int i; - int smax, tmax; + int s, t; + int i; + int smax, tmax; mtexinfo_t *tex; + dlight_t *dl; smax = (surf->extents[0]>>4)+1; tmax = (surf->extents[1]>>4)+1; @@ -92,8 +94,8 @@ void R_AddDynamicLights (msurface_t *surf) continue; // not lit by this light rad = cl_dlights[lnum].radius; - dist = DotProduct (cl_dlights[lnum].origin, surf->plane->normal) - - surf->plane->dist; + dist = DotProduct (cl_dlights[lnum].origin, + surf->plane->normal) - surf->plane->dist; rad -= fabs(dist); minlight = cl_dlights[lnum].minlight; if (rad < minlight) @@ -126,8 +128,21 @@ void R_AddDynamicLights (msurface_t *surf) dist = sd + (td>>1); else dist = td + (sd>>1); - if (dist < minlight) - blocklights[t*smax + s] += (rad - dist)*256; + if (dist < minlight) { + 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; unsigned scale; int maps; - unsigned *bl; + unsigned *bl, *rbl, *gbl, *bbl; surf->cached_dlight = (surf->dlightframe == r_framecount); @@ -159,15 +174,21 @@ void R_BuildLightMap (msurface_t *surf, byte *dest, int stride) lightmap = surf->samples; // 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 ; istyles[maps]]; surf->cached_light[maps] = scale; // 8.8 fraction for (i=0 ; i> 7, 255); + t = *gbl++; + dest[1] = 255 - min(t >> 7, 255); + t = *bbl++; + dest[2] = 255 - min(t >> 7, 255); t = *bl++; - t >>= 7; - if (t > 255) - t = 255; - dest[3] = 255-t; + dest[3] = 255 - min(t >> 7, 255); dest += 4; } } @@ -685,7 +717,9 @@ void R_BlendLightmaps (void) 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); else if (gl_lightmap_format == GL_INTENSITY) { @@ -751,7 +785,9 @@ void R_BlendLightmaps (void) } 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); else if (gl_lightmap_format == GL_INTENSITY) { @@ -1593,7 +1629,7 @@ void GL_BuildLightmaps (void) texture_extension_number += MAX_LIGHTMAPS; } - gl_lightmap_format = GL_LUMINANCE; + gl_lightmap_format = GL_RGBA; if (COM_CheckParm ("-lm_1")) gl_lightmap_format = GL_LUMINANCE; if (COM_CheckParm ("-lm_a"))