Minor lighting cleanup, plus fix minor bug (loss of color on nearby dlights).

This commit is contained in:
Ragnvald Maartmann-Moe IV 2001-01-27 03:01:09 +00:00
parent 9b0cea79ed
commit 4717448bd6
8 changed files with 36 additions and 42 deletions

View file

@ -132,8 +132,7 @@ typedef struct
float die; // stop lighting after this time
float decay; // drop this each second
float minlight; // don't add when contributing less
float _color[3]; // Don't use alpha --KB
float *color;
float color[3]; // Don't use alpha --KB
} dlight_t;
typedef struct

View file

@ -212,8 +212,7 @@ typedef struct {
float size;
float die, decay; // duration settings
float minlight; // lighting threshold
float _color[3]; // RGBA
float *color;
float color[3]; // !RGBA
} fire_t;
void R_AddFire (vec3_t, vec3_t, entity_t *ent);

View file

@ -106,7 +106,6 @@ CL_AllocDlight (int key)
if (dl->key == key) {
memset (dl, 0, sizeof (*dl));
dl->key = key;
dl->color = dl->_color;
dl->color[0] = dl->color[1] = dl->color[2] = 1;
return dl;
}
@ -118,7 +117,6 @@ CL_AllocDlight (int key)
if (dl->die < cl.time) {
memset (dl, 0, sizeof (*dl));
dl->key = key;
dl->color = dl->_color;
dl->color[0] = dl->color[1] = dl->color[2] = 1;
return dl;
}
@ -127,7 +125,6 @@ CL_AllocDlight (int key)
dl = &cl_dlights[0];
memset (dl, 0, sizeof (*dl));
dl->key = key;
dl->color = dl->_color;
return dl;
}

View file

@ -91,7 +91,7 @@ int gl_lightmap_format = 4;
int gl_solid_format = 3;
int gl_alpha_format = 4;
static int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST;
static int gl_filter_min = GL_LINEAR_MIPMAP_LINEAR;
static int gl_filter_max = GL_LINEAR;
@ -476,8 +476,10 @@ Draw_Init (void)
cs_texture = GL_LoadTexture ("crosshair", 8, 8, cs_data, false, true, 1);
// char_texture = GL_LoadTexture ("charset", 128, 128, draw_chars, false, true, 1); // 1999-12-27 Conwidth/height charset fix by TcT
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
// glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
// glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // DESPAIR: If trilinear, crosshairs are blocks of solid color
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// save a texture slot for translated picture
translate_texture = texture_extension_number++;
@ -505,6 +507,7 @@ Draw_Init_Cvars (void)
// LordHavoc: lighting mode
gl_lightmode = Cvar_Get ("gl_lightmode", "1", CVAR_ARCHIVE,
"Lighting mode (0 = GLQuake style, 1 = new style)");
gl_max_size = Cvar_Get ("gl_max_size", "1024", CVAR_NONE, "Texture dimension");
gl_picmip = Cvar_Get ("gl_picmip", "0", CVAR_NONE, "Dimensions of displayed textures. 0 is normal, 1 is half, 2 is 1/4");

View file

@ -29,13 +29,13 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
#include <string.h>
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
# include <strings.h>
#endif
#include <stdlib.h>
#include "cl_main.h"
@ -78,7 +78,7 @@ R_AddFire (vec3_t start, vec3_t end, entity_t *ent)
f->size = 20;
f->die = cl.time + 0.5;
f->decay = -1;
f->color = r_firecolor->vec;
VectorCopy (r_firecolor->vec, f->color);
}
}
@ -101,7 +101,6 @@ R_AllocFire (int key)
if (f->key == key) {
memset (f, 0, sizeof (*f));
f->key = key;
f->color = f->_color;
return f;
}
}
@ -111,7 +110,6 @@ R_AllocFire (int key)
if (f->die < cl.time) {
memset (f, 0, sizeof (*f));
f->key = key;
f->color = f->_color;
return f;
}
}
@ -119,7 +117,6 @@ R_AllocFire (int key)
f = &r_fires[0];
memset (f, 0, sizeof (*f));
f->key = key;
f->color = f->_color;
return f;
}
@ -144,7 +141,7 @@ R_DrawFire (fire_t *f)
// figure out if we're inside the area of effect
VectorSubtract (f->origin, r_origin, vec);
if (Length (vec) < radius) {
AddLightBlend (1, 0.5, 0, f->size * 0.0003); // we are
AddLightBlend (f->color[0], f->color[1], f->color[2], f->size * 0.0003); // we are
return;
}
// we're not - draw it

View file

@ -51,7 +51,7 @@ GDT_Init (void)
static void
GDT_InitDotParticleTexture (void)
{
int x, y, dx, dy, d;
int x, y, dx2, dy, d;
byte data[16][16][2];
//
@ -61,13 +61,13 @@ GDT_InitDotParticleTexture (void)
glBindTexture (GL_TEXTURE_2D, part_tex_dot);
for (x = 0; x < 16; x++) {
dx2 = x - 8;
dx2 *= dx2;
for (y = 0; y < 16; y++) {
data[y][x][0] = 255;
dx = x - 8;
dy = y - 8;
d = 255 - 4 * (dx * dx + dy * dy);
d = 255 - 4 * (dx2 + dy * dy);
if (d<0) d = 0;
if (d>255) d = 255;
data[y][x][1] = (byte) d;
}
}
@ -82,30 +82,33 @@ static void
GDT_InitSmokeParticleTexture (void)
{
int i, x, y, d;
float dx, dy;
float dx, dy2;
byte data[32][32][2], noise1[32][32], noise2[32][32];
for (i = 0; i < 8; i++) {
fractalnoise (&noise1[0][0], 32);
fractalnoise (&noise2[0][0], 32);
for (y = 0; y < 32; y++)
{
dy2 = y - 16;
dy2 *= dy2;
for (x = 0; x < 32; x++) {
data[y][x][0] = (noise1[y][x] >> 1) + 128;
dx = x - 16;
dy = y - 16;
d = noise2[y][x] * 4 - 512;
if (d > 0) {
if (d > 255)
d = 255;
d = (d * (255 - (int) (dx * dx + dy * dy))) >> 8;
d = (d * (255 - (int) (dx * dx + dy2))) >> 8;
if (d < 0)
d = 0;
if (d > 255)
d = 255;
// if (d > 255)
// d = 255;
data[y][x][1] = (byte) d;
} else
data[y][x][1] = 0;
}
}
part_tex_smoke[i] = texture_extension_number++;
glBindTexture (GL_TEXTURE_2D, part_tex_smoke[i]);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

View file

@ -29,14 +29,14 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <math.h>
#ifdef HAVE_STRING_H
#include <string.h>
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
# include <strings.h>
#endif
#include <math.h>
#include <stdio.h>
#include "glquake.h"
@ -118,7 +118,6 @@ R_RenderDlight (dlight_t *light)
{
int i, j;
// float a;
vec3_t v;
float rad;
float *bub_sin, *bub_cos;
@ -129,7 +128,7 @@ R_RenderDlight (dlight_t *light)
VectorSubtract (light->origin, r_origin, v);
if (Length (v) < rad) { // view is inside the dlight
AddLightBlend (1, 0.5, 0, light->radius * 0.0003);
AddLightBlend (light->color[0], light->color[1], light->color[2], light->radius * 0.0003);
return;
}
@ -144,7 +143,6 @@ R_RenderDlight (dlight_t *light)
glVertex3fv (v);
glColor3f (0, 0, 0);
for (i = 16; i >= 0; i--) {
// a = i/16.0 * M_PI*2;
for (j = 0; j < 3; j++)
v[j] = light->origin[j] + (vright[j] * (*bub_cos) +
+vup[j] * (*bub_sin)) * rad;

View file

@ -29,14 +29,14 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <math.h>
#ifdef HAVE_STRING_H
#include <string.h>
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
# include <strings.h>
#endif
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
@ -68,9 +68,7 @@ mplane_t frustum[4];
int c_brush_polys, c_alias_polys;
qboolean envmap; // true during envmap command capture
//
qboolean envmap; // true during envmap command capture
int playertextures; // up to 16 color translated skins
@ -881,7 +879,7 @@ R_DrawAliasModel (entity_t *e)
}
if (gl_affinemodels->int_val)
glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_DONT_CARE); // DESPAIR: was GL_FASTEST
glPopMatrix ();