mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
Merge pull request #788 from 0lvin/softlightmap
soft: add r_lightmap implementation
This commit is contained in:
commit
b68910905b
12 changed files with 150 additions and 88 deletions
|
@ -664,7 +664,7 @@ cheatvar_t cheatvars[] = {
|
||||||
{"paused", "0"},
|
{"paused", "0"},
|
||||||
{"fixedtime", "0"},
|
{"fixedtime", "0"},
|
||||||
{"sw_draworder", "0"},
|
{"sw_draworder", "0"},
|
||||||
{"gl_lightmap", "0"},
|
{"r_lightmap", "0"},
|
||||||
{"gl_saturatelighting", "0"},
|
{"gl_saturatelighting", "0"},
|
||||||
{"cl_kickangles", "1"},
|
{"cl_kickangles", "1"},
|
||||||
{"g_footsteps", "1"},
|
{"g_footsteps", "1"},
|
||||||
|
|
|
@ -303,17 +303,20 @@ R_RecursiveLightPoint(mnode_t *node, vec3_t start, vec3_t end)
|
||||||
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255;
|
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255;
|
||||||
maps++)
|
maps++)
|
||||||
{
|
{
|
||||||
|
const float *rgb;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
|
rgb = r_newrefdef.lightstyles[surf->styles[maps]].rgb;
|
||||||
|
|
||||||
|
/* Apply light level to models */
|
||||||
for (j = 0; j < 3; j++)
|
for (j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
scale[j] = r_modulate->value *
|
float scale;
|
||||||
r_newrefdef.lightstyles[surf->styles[maps]].rgb[j];
|
|
||||||
|
scale = rgb[j] * r_modulate->value;
|
||||||
|
pointcolor[j] += lightmap[j] * scale * (1.0 / 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
pointcolor[0] += lightmap[0] * scale[0] * (1.0 / 255);
|
|
||||||
pointcolor[1] += lightmap[1] * scale[1] * (1.0 / 255);
|
|
||||||
pointcolor[2] += lightmap[2] * scale[2] * (1.0 / 255);
|
|
||||||
lightmap += 3 * ((surf->extents[0] >> 4) + 1) *
|
lightmap += 3 * ((surf->extents[0] >> 4) + 1) *
|
||||||
((surf->extents[1] >> 4) + 1);
|
((surf->extents[1] >> 4) + 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1223,7 +1223,7 @@ R_Register(void)
|
||||||
|
|
||||||
r_modulate = ri.Cvar_Get("r_modulate", "1", CVAR_ARCHIVE);
|
r_modulate = ri.Cvar_Get("r_modulate", "1", CVAR_ARCHIVE);
|
||||||
r_mode = ri.Cvar_Get("r_mode", "4", CVAR_ARCHIVE);
|
r_mode = ri.Cvar_Get("r_mode", "4", CVAR_ARCHIVE);
|
||||||
gl_lightmap = ri.Cvar_Get("gl_lightmap", "0", 0);
|
gl_lightmap = ri.Cvar_Get("r_lightmap", "0", 0);
|
||||||
gl_shadows = ri.Cvar_Get("r_shadows", "0", CVAR_ARCHIVE);
|
gl_shadows = ri.Cvar_Get("r_shadows", "0", CVAR_ARCHIVE);
|
||||||
gl1_stencilshadow = ri.Cvar_Get("gl1_stencilshadow", "0", CVAR_ARCHIVE);
|
gl1_stencilshadow = ri.Cvar_Get("gl1_stencilshadow", "0", CVAR_ARCHIVE);
|
||||||
gl1_dynamic = ri.Cvar_Get("gl1_dynamic", "1", 0);
|
gl1_dynamic = ri.Cvar_Get("gl1_dynamic", "1", 0);
|
||||||
|
|
|
@ -231,15 +231,20 @@ RecursiveLightPoint(mnode_t *node, vec3_t start, vec3_t end)
|
||||||
for (maps = 0; maps < MAX_LIGHTMAPS_PER_SURFACE && surf->styles[maps] != 255;
|
for (maps = 0; maps < MAX_LIGHTMAPS_PER_SURFACE && surf->styles[maps] != 255;
|
||||||
maps++)
|
maps++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 3; j++)
|
const float *rgb;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
rgb = gl3_newrefdef.lightstyles[surf->styles[maps]].rgb;
|
||||||
|
|
||||||
|
/* Apply light level to models */
|
||||||
|
for (j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
scale[j] = r_modulate->value *
|
float scale;
|
||||||
gl3_newrefdef.lightstyles[surf->styles[maps]].rgb[j];
|
|
||||||
|
scale = rgb[j] * r_modulate->value;
|
||||||
|
pointcolor[j] += lightmap[j] * scale * (1.0 / 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
pointcolor[0] += lightmap[0] * scale[0] * (1.0 / 255);
|
|
||||||
pointcolor[1] += lightmap[1] * scale[1] * (1.0 / 255);
|
|
||||||
pointcolor[2] += lightmap[2] * scale[2] * (1.0 / 255);
|
|
||||||
lightmap += 3 * ((surf->extents[0] >> 4) + 1) *
|
lightmap += 3 * ((surf->extents[0] >> 4) + 1) *
|
||||||
((surf->extents[1] >> 4) + 1);
|
((surf->extents[1] >> 4) + 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,7 +237,7 @@ GL3_Register(void)
|
||||||
r_lightlevel = ri.Cvar_Get("r_lightlevel", "0", 0);
|
r_lightlevel = ri.Cvar_Get("r_lightlevel", "0", 0);
|
||||||
gl3_overbrightbits = ri.Cvar_Get("gl3_overbrightbits", "1.3", CVAR_ARCHIVE);
|
gl3_overbrightbits = ri.Cvar_Get("gl3_overbrightbits", "1.3", CVAR_ARCHIVE);
|
||||||
|
|
||||||
gl_lightmap = ri.Cvar_Get("gl_lightmap", "0", 0);
|
gl_lightmap = ri.Cvar_Get("r_lightmap", "0", 0);
|
||||||
gl_shadows = ri.Cvar_Get("r_shadows", "0", CVAR_ARCHIVE);
|
gl_shadows = ri.Cvar_Get("r_shadows", "0", CVAR_ARCHIVE);
|
||||||
|
|
||||||
r_modulate = ri.Cvar_Get("r_modulate", "1", CVAR_ARCHIVE);
|
r_modulate = ri.Cvar_Get("r_modulate", "1", CVAR_ARCHIVE);
|
||||||
|
@ -272,7 +272,7 @@ GL3_Register(void)
|
||||||
|
|
||||||
//gl_modulate = ri.Cvar_Get("gl_modulate", "1", CVAR_ARCHIVE);
|
//gl_modulate = ri.Cvar_Get("gl_modulate", "1", CVAR_ARCHIVE);
|
||||||
//r_mode = ri.Cvar_Get("r_mode", "4", CVAR_ARCHIVE);
|
//r_mode = ri.Cvar_Get("r_mode", "4", CVAR_ARCHIVE);
|
||||||
//gl_lightmap = ri.Cvar_Get("gl_lightmap", "0", 0);
|
//gl_lightmap = ri.Cvar_Get("r_lightmap", "0", 0);
|
||||||
//gl_shadows = ri.Cvar_Get("r_shadows", "0", CVAR_ARCHIVE);
|
//gl_shadows = ri.Cvar_Get("r_shadows", "0", CVAR_ARCHIVE);
|
||||||
//gl_nobind = ri.Cvar_Get("gl_nobind", "0", 0);
|
//gl_nobind = ri.Cvar_Get("gl_nobind", "0", 0);
|
||||||
gl_showtris = ri.Cvar_Get("gl_showtris", "0", 0);
|
gl_showtris = ri.Cvar_Get("gl_showtris", "0", 0);
|
||||||
|
|
|
@ -211,7 +211,7 @@ typedef struct finalvert_s {
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
void *pskin;
|
pixel_t *pskin;
|
||||||
int skinwidth;
|
int skinwidth;
|
||||||
int skinheight;
|
int skinheight;
|
||||||
} affinetridesc_t;
|
} affinetridesc_t;
|
||||||
|
@ -431,6 +431,7 @@ extern cvar_t *r_fullbright;
|
||||||
extern cvar_t *r_lefthand;
|
extern cvar_t *r_lefthand;
|
||||||
extern cvar_t *r_gunfov;
|
extern cvar_t *r_gunfov;
|
||||||
extern cvar_t *r_farsee;
|
extern cvar_t *r_farsee;
|
||||||
|
extern cvar_t *r_lightmap;
|
||||||
extern cvar_t *r_drawworld;
|
extern cvar_t *r_drawworld;
|
||||||
extern cvar_t *r_lerpmodels;
|
extern cvar_t *r_lerpmodels;
|
||||||
extern cvar_t *r_lightlevel;
|
extern cvar_t *r_lightlevel;
|
||||||
|
|
|
@ -578,7 +578,7 @@ R_AliasSetupLighting(entity_t *currententity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
j = (light[0] + light[1] + light[2])*0.3333*255;
|
j = (light[0] + light[1] + light[2]) * 0.3333 * 255;
|
||||||
|
|
||||||
lighting.ambientlight = j;
|
lighting.ambientlight = j;
|
||||||
lighting.shadelight = j;
|
lighting.shadelight = j;
|
||||||
|
|
|
@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#include "header/local.h"
|
#include "header/local.h"
|
||||||
|
|
||||||
#define MAX_RIMAGES 1024
|
#define MAX_RIMAGES 1024
|
||||||
|
static image_t *r_whitetexture_mip = NULL;
|
||||||
static image_t r_images[MAX_RIMAGES];
|
static image_t r_images[MAX_RIMAGES];
|
||||||
static int numr_images;
|
static int numr_images;
|
||||||
static int image_max = 0;
|
static int image_max = 0;
|
||||||
|
@ -210,12 +211,15 @@ R_LoadPic
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
static image_t *
|
static image_t *
|
||||||
R_LoadPic (char *name, byte *pic, int width, int realwidth, int height, int realheight, imagetype_t type)
|
R_LoadPic (char *name, byte *pic, int width, int realwidth, int height, int realheight,
|
||||||
|
size_t data_size, imagetype_t type)
|
||||||
{
|
{
|
||||||
image_t *image;
|
image_t *image;
|
||||||
size_t i, size, full_size;
|
size_t i, size, full_size;
|
||||||
|
|
||||||
if (!pic)
|
size = width * height;
|
||||||
|
|
||||||
|
if (!pic || data_size <= 0 || width <= 0 || height <= 0 || size <= 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
image = R_FindFreeImage();
|
image = R_FindFreeImage();
|
||||||
|
@ -230,7 +234,6 @@ R_LoadPic (char *name, byte *pic, int width, int realwidth, int height, int real
|
||||||
image->asset_height = realheight;
|
image->asset_height = realheight;
|
||||||
image->type = type;
|
image->type = type;
|
||||||
|
|
||||||
size = width * height;
|
|
||||||
full_size = R_GetImageMipsSize(size);
|
full_size = R_GetImageMipsSize(size);
|
||||||
image->pixels[0] = malloc(full_size);
|
image->pixels[0] = malloc(full_size);
|
||||||
if (!image->pixels[0])
|
if (!image->pixels[0])
|
||||||
|
@ -239,7 +242,10 @@ R_LoadPic (char *name, byte *pic, int width, int realwidth, int height, int real
|
||||||
// code never returns after ERR_FATAL
|
// code never returns after ERR_FATAL
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
image->transparent = false;
|
image->transparent = false;
|
||||||
|
if (type != it_wall)
|
||||||
|
{
|
||||||
for (i=0 ; i<size ; i++)
|
for (i=0 ; i<size ; i++)
|
||||||
{
|
{
|
||||||
if (pic[i] == 255)
|
if (pic[i] == 255)
|
||||||
|
@ -248,12 +254,23 @@ R_LoadPic (char *name, byte *pic, int width, int realwidth, int height, int real
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data_size > full_size)
|
||||||
|
{
|
||||||
|
data_size = full_size;
|
||||||
|
}
|
||||||
|
memcpy(image->pixels[0], pic, data_size);
|
||||||
|
|
||||||
memcpy(image->pixels[0], pic, size);
|
|
||||||
// restore mips
|
// restore mips
|
||||||
R_RestoreImagePointers(image, 0);
|
R_RestoreImagePointers(image, 0);
|
||||||
// restore everything from first image
|
|
||||||
|
if (full_size > data_size)
|
||||||
|
{
|
||||||
|
// looks short, restore everything from first image
|
||||||
R_RestoreMips(image, 0);
|
R_RestoreMips(image, 0);
|
||||||
|
}
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +285,7 @@ R_LoadWal (char *name, imagetype_t type)
|
||||||
miptex_t *mt;
|
miptex_t *mt;
|
||||||
int ofs;
|
int ofs;
|
||||||
image_t *image;
|
image_t *image;
|
||||||
size_t size, file_size;
|
size_t file_size, width, height;
|
||||||
|
|
||||||
file_size = ri.FS_LoadFile (name, (void **)&mt);
|
file_size = ri.FS_LoadFile (name, (void **)&mt);
|
||||||
if (!mt)
|
if (!mt)
|
||||||
|
@ -284,72 +301,57 @@ R_LoadWal (char *name, imagetype_t type)
|
||||||
return r_notexture_mip;
|
return r_notexture_mip;
|
||||||
}
|
}
|
||||||
|
|
||||||
image = R_FindFreeImage ();
|
width = LittleLong (mt->width);
|
||||||
strcpy (image->name, name);
|
height = LittleLong (mt->height);
|
||||||
image->width = LittleLong (mt->width);
|
|
||||||
image->height = LittleLong (mt->height);
|
|
||||||
image->asset_width = image->width;
|
|
||||||
image->asset_height = image->height;
|
|
||||||
image->type = type;
|
|
||||||
image->registration_sequence = registration_sequence;
|
|
||||||
ofs = LittleLong(mt->offsets[0]);
|
ofs = LittleLong(mt->offsets[0]);
|
||||||
size = R_GetImageMipsSize(image->width * image->height);
|
|
||||||
|
|
||||||
if ((ofs <= 0) || (image->width <= 0) || (image->height <= 0) ||
|
if ((ofs <= 0) || (width <= 0) || (height <= 0) ||
|
||||||
((file_size - ofs) / image->width < image->height))
|
((file_size - ofs) / width < height))
|
||||||
{
|
{
|
||||||
R_Printf(PRINT_ALL, "%s: can't load %s, small body\n", __func__, name);
|
R_Printf(PRINT_ALL, "%s: can't load %s, small body\n", __func__, name);
|
||||||
ri.FS_FreeFile((void *)mt);
|
ri.FS_FreeFile((void *)mt);
|
||||||
return r_notexture_mip;
|
return r_notexture_mip;
|
||||||
}
|
}
|
||||||
|
|
||||||
image->pixels[0] = malloc (size);
|
image = R_LoadPic(name, (byte *)mt + ofs,
|
||||||
R_RestoreImagePointers(image, 0);
|
width, width,
|
||||||
|
height, height,
|
||||||
if (size > (file_size - ofs))
|
(file_size - ofs), type);
|
||||||
{
|
|
||||||
memcpy(image->pixels[0], (byte *)mt + ofs, file_size - ofs);
|
|
||||||
// looks short, restore everything from first image
|
|
||||||
R_RestoreMips(image, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memcpy(image->pixels[0], (byte *)mt + ofs, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
ri.FS_FreeFile((void *)mt);
|
ri.FS_FreeFile((void *)mt);
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char *d_16to8table; // 16 to 8 bit conversion table
|
static unsigned char *d_16to8table = NULL; // 16 to 8 bit conversion table
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_Convert32To8bit(const unsigned char* pic_in, unsigned char* pic_out, size_t size)
|
R_Convert32To8bit(const unsigned char* pic_in, pixel_t* pic_out, size_t size)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!d_16to8table)
|
if (!d_16to8table)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(i=0; i<size; i++)
|
for(i=0; i < size; i++)
|
||||||
{
|
{
|
||||||
unsigned int r, g, b, c;
|
unsigned int r, g, b, c;
|
||||||
|
|
||||||
r = ( pic_in[i * 4 + 0] >> 3 ) & 31;
|
r = ( pic_in[0] >> 3 ) & 31;
|
||||||
g = ( pic_in[i * 4 + 1] >> 2 ) & 63;
|
g = ( pic_in[1] >> 2 ) & 63;
|
||||||
b = ( pic_in[i * 4 + 2] >> 3 ) & 31;
|
b = ( pic_in[2] >> 3 ) & 31;
|
||||||
|
|
||||||
c = r | ( g << 5 ) | ( b << 11 );
|
c = r | ( g << 5 ) | ( b << 11 );
|
||||||
|
|
||||||
pic_out[i] = d_16to8table[c & 0xFFFF];
|
pic_out[i] = d_16to8table[c & 0xFFFF];
|
||||||
|
pic_in += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_FixPalette(unsigned char* pixels, size_t size, rgb_t* pallette)
|
R_FixPalette(pixel_t* pixels, size_t size, const rgb_t* pallette)
|
||||||
{
|
{
|
||||||
unsigned char* convert = malloc(256);
|
pixel_t* convert = malloc(256);
|
||||||
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
@ -554,14 +556,20 @@ R_LoadHiColorImage(char *name, const char* namewe, const char *ext, imagetype_t
|
||||||
pic32, uploadwidth, uploadheight))
|
pic32, uploadwidth, uploadheight))
|
||||||
{
|
{
|
||||||
R_Convert32To8bit(pic32, pic8, uploadwidth * uploadheight);
|
R_Convert32To8bit(pic32, pic8, uploadwidth * uploadheight);
|
||||||
image = R_LoadPic(name, pic8, uploadwidth, realwidth, uploadheight, realheight, type);
|
image = R_LoadPic(name, pic8,
|
||||||
|
uploadwidth, realwidth,
|
||||||
|
uploadheight, realheight,
|
||||||
|
uploadwidth * uploadheight, type);
|
||||||
}
|
}
|
||||||
free(pic32);
|
free(pic32);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
R_Convert32To8bit(pic, pic8, width * height);
|
R_Convert32To8bit(pic, pic8, width * height);
|
||||||
image = R_LoadPic(name, pic8, width, width, height, height, type);
|
image = R_LoadPic(name, pic8,
|
||||||
|
width, width,
|
||||||
|
height, height,
|
||||||
|
width * height, type);
|
||||||
}
|
}
|
||||||
free(pic8);
|
free(pic8);
|
||||||
}
|
}
|
||||||
|
@ -614,12 +622,18 @@ R_LoadImage(char *name, const char* namewe, const char *ext, imagetype_t type)
|
||||||
scale2x(pic, scaled, width, height);
|
scale2x(pic, scaled, width, height);
|
||||||
width *= 2;
|
width *= 2;
|
||||||
height *= 2;
|
height *= 2;
|
||||||
image = R_LoadPic(name, scaled, width, realwidth, height, realheight, type);
|
image = R_LoadPic(name, scaled,
|
||||||
|
width, realwidth,
|
||||||
|
height, realheight,
|
||||||
|
width * height, type);
|
||||||
free(scaled);
|
free(scaled);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
image = R_LoadPic(name, pic, width, width, height, height, type);
|
image = R_LoadPic(name, pic,
|
||||||
|
width, width,
|
||||||
|
height, height,
|
||||||
|
width * height, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (palette)
|
if (palette)
|
||||||
|
@ -662,6 +676,12 @@ R_FindImage(char *name, imagetype_t type)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* just return white image if show lighmap only */
|
||||||
|
if (type == it_wall && r_lightmap->value)
|
||||||
|
{
|
||||||
|
return r_whitetexture_mip;
|
||||||
|
}
|
||||||
|
|
||||||
ext = COM_FileExtension(name);
|
ext = COM_FileExtension(name);
|
||||||
if(!ext[0])
|
if(!ext[0])
|
||||||
{
|
{
|
||||||
|
@ -762,17 +782,12 @@ R_ImageHasFreeSpace(void)
|
||||||
static struct texture_buffer {
|
static struct texture_buffer {
|
||||||
image_t image;
|
image_t image;
|
||||||
byte buffer[4096];
|
byte buffer[4096];
|
||||||
} r_notexture_buffer;
|
} r_notexture_buffer, r_whitetexture_buffer;
|
||||||
|
|
||||||
/*
|
|
||||||
==================
|
|
||||||
R_InitTextures
|
|
||||||
==================
|
|
||||||
*/
|
|
||||||
static void
|
static void
|
||||||
R_InitTextures (void)
|
R_InitNoTexture(void)
|
||||||
{
|
{
|
||||||
int x,y, m;
|
int m;
|
||||||
|
|
||||||
// create a simple checkerboard texture for the default
|
// create a simple checkerboard texture for the default
|
||||||
r_notexture_mip = &r_notexture_buffer.image;
|
r_notexture_mip = &r_notexture_buffer.image;
|
||||||
|
@ -785,6 +800,7 @@ R_InitTextures (void)
|
||||||
|
|
||||||
for (m=0 ; m<NUM_MIPS ; m++)
|
for (m=0 ; m<NUM_MIPS ; m++)
|
||||||
{
|
{
|
||||||
|
int x, y;
|
||||||
byte *dest;
|
byte *dest;
|
||||||
|
|
||||||
dest = r_notexture_mip->pixels[m];
|
dest = r_notexture_mip->pixels[m];
|
||||||
|
@ -793,13 +809,42 @@ R_InitTextures (void)
|
||||||
{
|
{
|
||||||
if ( (y< (8>>m) ) ^ (x< (8>>m) ) )
|
if ( (y< (8>>m) ) ^ (x< (8>>m) ) )
|
||||||
|
|
||||||
*dest++ = 0;
|
*dest++ = d_16to8table[0x0000];
|
||||||
else
|
else
|
||||||
*dest++ = 0xff;
|
*dest++ = d_16to8table[0xFFFF];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
R_InitWhiteTexture(void)
|
||||||
|
{
|
||||||
|
// create a simple white texture for the default
|
||||||
|
r_whitetexture_mip = &r_whitetexture_buffer.image;
|
||||||
|
|
||||||
|
r_whitetexture_mip->width = r_whitetexture_mip->height = 16;
|
||||||
|
r_whitetexture_mip->asset_width = r_whitetexture_mip->asset_height = 16;
|
||||||
|
|
||||||
|
r_whitetexture_mip->pixels[0] = r_whitetexture_buffer.buffer;
|
||||||
|
R_RestoreImagePointers(r_whitetexture_mip, 0);
|
||||||
|
|
||||||
|
memset(r_whitetexture_buffer.buffer, d_16to8table[0xFFFF],
|
||||||
|
sizeof(r_whitetexture_buffer.buffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
==================
|
||||||
|
R_InitTextures
|
||||||
|
==================
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
R_InitTextures (void)
|
||||||
|
{
|
||||||
|
R_InitNoTexture();
|
||||||
|
/* empty white texture for r_lightmap = 1*/
|
||||||
|
R_InitWhiteTexture();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
R_InitImages
|
R_InitImages
|
||||||
|
|
|
@ -134,6 +134,7 @@ float se_time1, se_time2, de_time1, de_time2;
|
||||||
cvar_t *r_lefthand;
|
cvar_t *r_lefthand;
|
||||||
cvar_t *r_gunfov;
|
cvar_t *r_gunfov;
|
||||||
cvar_t *r_farsee;
|
cvar_t *r_farsee;
|
||||||
|
cvar_t *r_lightmap;
|
||||||
static cvar_t *sw_aliasstats;
|
static cvar_t *sw_aliasstats;
|
||||||
cvar_t *sw_clearcolor;
|
cvar_t *sw_clearcolor;
|
||||||
cvar_t *sw_drawflat;
|
cvar_t *sw_drawflat;
|
||||||
|
@ -394,6 +395,7 @@ R_RegisterVariables (void)
|
||||||
r_lefthand = ri.Cvar_Get( "hand", "0", CVAR_USERINFO | CVAR_ARCHIVE );
|
r_lefthand = ri.Cvar_Get( "hand", "0", CVAR_USERINFO | CVAR_ARCHIVE );
|
||||||
r_gunfov = ri.Cvar_Get( "r_gunfov", "80", CVAR_ARCHIVE );
|
r_gunfov = ri.Cvar_Get( "r_gunfov", "80", CVAR_ARCHIVE );
|
||||||
r_farsee = ri.Cvar_Get("r_farsee", "0", CVAR_LATCH | CVAR_ARCHIVE);
|
r_farsee = ri.Cvar_Get("r_farsee", "0", CVAR_LATCH | CVAR_ARCHIVE);
|
||||||
|
r_lightmap = ri.Cvar_Get("r_lightmap", "0", 0);
|
||||||
r_speeds = ri.Cvar_Get ("r_speeds", "0", 0);
|
r_speeds = ri.Cvar_Get ("r_speeds", "0", 0);
|
||||||
r_fullbright = ri.Cvar_Get ("r_fullbright", "0", 0);
|
r_fullbright = ri.Cvar_Get ("r_fullbright", "0", 0);
|
||||||
r_drawentities = ri.Cvar_Get ("r_drawentities", "1", 0);
|
r_drawentities = ri.Cvar_Get ("r_drawentities", "1", 0);
|
||||||
|
@ -1341,7 +1343,7 @@ RE_RenderFrame (refdef_t *fd)
|
||||||
// For each dlight_t* passed via r_newrefdef.dlights, mark polygons affected by a light.
|
// For each dlight_t* passed via r_newrefdef.dlights, mark polygons affected by a light.
|
||||||
R_PushDlights (r_worldmodel);
|
R_PushDlights (r_worldmodel);
|
||||||
|
|
||||||
// TODO: rearange code same as in GL*_DrawWorld?
|
// TODO: rearrange code same as in GL*_DrawWorld?
|
||||||
/* auto cycle the world frame for texture animation */
|
/* auto cycle the world frame for texture animation */
|
||||||
memset(&ent, 0, sizeof(ent));
|
memset(&ent, 0, sizeof(ent));
|
||||||
ent.frame = (int)(r_newrefdef.time * 2);
|
ent.frame = (int)(r_newrefdef.time * 2);
|
||||||
|
|
|
@ -258,16 +258,17 @@ static void
|
||||||
Mod_LoadLighting (model_t *loadmodel, byte *mod_base, lump_t *l)
|
Mod_LoadLighting (model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||||
{
|
{
|
||||||
int i, size;
|
int i, size;
|
||||||
byte *in;
|
pixel_t *in;
|
||||||
|
|
||||||
if (!l->filelen)
|
if (!l->filelen)
|
||||||
{
|
{
|
||||||
loadmodel->lightdata = NULL;
|
loadmodel->lightdata = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = l->filelen/3;
|
size = l->filelen/3;
|
||||||
loadmodel->lightdata = Hunk_Alloc(size);
|
loadmodel->lightdata = Hunk_Alloc(size);
|
||||||
in = (void *)(mod_base + l->fileofs);
|
in = mod_base + l->fileofs;
|
||||||
for (i=0 ; i<size ; i++, in+=3)
|
for (i=0 ; i<size ; i++, in+=3)
|
||||||
{
|
{
|
||||||
if (in[0] > in[1] && in[0] > in[2])
|
if (in[0] > in[1] && in[0] > in[2])
|
||||||
|
@ -1008,7 +1009,8 @@ Mod_LoadBrushModel(model_t *mod, void *buffer, int modfilelen)
|
||||||
if(surfEdgeCount < MAX_MAP_SURFEDGES) // else it errors out later anyway
|
if(surfEdgeCount < MAX_MAP_SURFEDGES) // else it errors out later anyway
|
||||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_SURFEDGES], sizeof(int), sizeof(int), 24);
|
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_SURFEDGES], sizeof(int), sizeof(int), 24);
|
||||||
|
|
||||||
// lighting is a special case, because we keep only 1 byte out of 3 (=> no colored lighting in soft renderer)
|
// lighting is a special case, because we keep only 1 byte out of 3
|
||||||
|
// (=> no colored lighting in soft renderer by default)
|
||||||
{
|
{
|
||||||
int size = header->lumps[LUMP_LIGHTING].filelen/3;
|
int size = header->lumps[LUMP_LIGHTING].filelen/3;
|
||||||
size = (size + 31) & ~31;
|
size = (size + 31) & ~31;
|
||||||
|
|
|
@ -78,7 +78,7 @@ static zvalue_t d_ziextrastep, d_zibasestep;
|
||||||
|
|
||||||
static byte *skintable[MAX_LBM_HEIGHT];
|
static byte *skintable[MAX_LBM_HEIGHT];
|
||||||
int skinwidth;
|
int skinwidth;
|
||||||
static byte *skinstart;
|
static pixel_t *skinstart;
|
||||||
|
|
||||||
void (*d_pdrawspans)(const entity_t *currententity, spanpackage_t *pspanpackage);
|
void (*d_pdrawspans)(const entity_t *currententity, spanpackage_t *pspanpackage);
|
||||||
|
|
||||||
|
@ -429,8 +429,8 @@ R_PolysetDrawSpans8
|
||||||
void
|
void
|
||||||
R_PolysetDrawSpans8_33(const entity_t *currententity, spanpackage_t *pspanpackage)
|
R_PolysetDrawSpans8_33(const entity_t *currententity, spanpackage_t *pspanpackage)
|
||||||
{
|
{
|
||||||
byte *lpdest;
|
pixel_t *lpdest;
|
||||||
byte *lptex;
|
pixel_t *lptex;
|
||||||
int lsfrac, ltfrac;
|
int lsfrac, ltfrac;
|
||||||
int llight;
|
int llight;
|
||||||
zvalue_t lzi;
|
zvalue_t lzi;
|
||||||
|
@ -470,7 +470,7 @@ R_PolysetDrawSpans8_33(const entity_t *currententity, spanpackage_t *pspanpackag
|
||||||
{
|
{
|
||||||
int temp = vid_colormap[*lptex + ( llight & 0xFF00 )];
|
int temp = vid_colormap[*lptex + ( llight & 0xFF00 )];
|
||||||
|
|
||||||
*lpdest = vid_alphamap[temp+ *lpdest*256];
|
*lpdest = vid_alphamap[temp + *lpdest*256];
|
||||||
}
|
}
|
||||||
lpdest++;
|
lpdest++;
|
||||||
lzi += r_zistepx;
|
lzi += r_zistepx;
|
||||||
|
@ -719,11 +719,14 @@ R_PolysetDrawSpans8_Opaque (const entity_t *currententity, spanpackage_t *pspanp
|
||||||
{
|
{
|
||||||
if ((lzi >> SHIFT16XYZ) >= *lpz)
|
if ((lzi >> SHIFT16XYZ) >= *lpz)
|
||||||
{
|
{
|
||||||
if(r_newrefdef.rdflags & RDF_IRGOGGLES && currententity->flags & RF_IR_VISIBLE)
|
int color_value;
|
||||||
*lpdest = ((byte *)vid_colormap)[irtable[*lptex]];
|
|
||||||
else
|
|
||||||
*lpdest = ((byte *)vid_colormap)[*lptex + (llight & 0xFF00)];
|
|
||||||
|
|
||||||
|
if(r_newrefdef.rdflags & RDF_IRGOGGLES && currententity->flags & RF_IR_VISIBLE)
|
||||||
|
color_value = irtable[*lptex];
|
||||||
|
else
|
||||||
|
color_value = *lptex + (llight & 0xFF00);
|
||||||
|
|
||||||
|
*lpdest = vid_colormap[color_value];
|
||||||
*lpz = lzi >> SHIFT16XYZ;
|
*lpz = lzi >> SHIFT16XYZ;
|
||||||
zdamaged = true;
|
zdamaged = true;
|
||||||
}
|
}
|
||||||
|
@ -798,7 +801,7 @@ R_RasterizeAliasPolySmooth(const entity_t *currententity)
|
||||||
v = plefttop[1];
|
v = plefttop[1];
|
||||||
d_aspancount = plefttop[0] - prighttop[0];
|
d_aspancount = plefttop[0] - prighttop[0];
|
||||||
|
|
||||||
d_ptex = (byte *)r_affinetridesc.pskin + (plefttop[2] >> SHIFT16XYZ) +
|
d_ptex = r_affinetridesc.pskin + (plefttop[2] >> SHIFT16XYZ) +
|
||||||
(plefttop[3] >> SHIFT16XYZ) * r_affinetridesc.skinwidth;
|
(plefttop[3] >> SHIFT16XYZ) * r_affinetridesc.skinwidth;
|
||||||
{
|
{
|
||||||
d_sfrac = plefttop[2] & 0xFFFF;
|
d_sfrac = plefttop[2] & 0xFFFF;
|
||||||
|
@ -866,7 +869,7 @@ R_RasterizeAliasPolySmooth(const entity_t *currententity)
|
||||||
u = plefttop[0];
|
u = plefttop[0];
|
||||||
v = plefttop[1];
|
v = plefttop[1];
|
||||||
d_aspancount = plefttop[0] - prighttop[0];
|
d_aspancount = plefttop[0] - prighttop[0];
|
||||||
d_ptex = (byte *)r_affinetridesc.pskin + (plefttop[2] >> SHIFT16XYZ) +
|
d_ptex = r_affinetridesc.pskin + (plefttop[2] >> SHIFT16XYZ) +
|
||||||
(plefttop[3] >> SHIFT16XYZ) * r_affinetridesc.skinwidth;
|
(plefttop[3] >> SHIFT16XYZ) * r_affinetridesc.skinwidth;
|
||||||
d_sfrac = 0;
|
d_sfrac = 0;
|
||||||
d_tfrac = 0;
|
d_tfrac = 0;
|
||||||
|
|
|
@ -88,6 +88,7 @@ replacement_t replacements[] = {
|
||||||
{"gl_retexturing", "r_retexturing"},
|
{"gl_retexturing", "r_retexturing"},
|
||||||
{"gl_shadows", "r_shadows"},
|
{"gl_shadows", "r_shadows"},
|
||||||
{"gl_anisotropic", "r_anisotropic"},
|
{"gl_anisotropic", "r_anisotropic"},
|
||||||
|
{"gl_lightmap", "r_lighmap"},
|
||||||
{"intensity", "gl1_intensity"}
|
{"intensity", "gl1_intensity"}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue