light: read _mincolor from .texinfo file
This commit is contained in:
parent
986aad52c2
commit
fbeba25bd1
|
|
@ -216,6 +216,12 @@ typedef struct texinfo_s {
|
|||
#define TEX_PHONG_ANGLE_MASK (255U << TEX_PHONG_ANGLE_SHIFT) /* 8 bit value. if non zero, enables phong shading and gives the angle threshold to use. */
|
||||
#define TEX_MINLIGHT_SHIFT 12
|
||||
#define TEX_MINLIGHT_MASK (255U << TEX_MINLIGHT_SHIFT) /* 8 bit value, minlight value for this face. */
|
||||
#define TEX_MINLIGHT_COLOR_R_SHIFT 20
|
||||
#define TEX_MINLIGHT_COLOR_R_MASK (255ULL << TEX_MINLIGHT_COLOR_R_SHIFT) /* 8 bit value, red minlight color for this face. */
|
||||
#define TEX_MINLIGHT_COLOR_G_SHIFT 28
|
||||
#define TEX_MINLIGHT_COLOR_G_MASK (255ULL << TEX_MINLIGHT_COLOR_G_SHIFT) /* 8 bit value, green minlight color for this face. */
|
||||
#define TEX_MINLIGHT_COLOR_B_SHIFT 36
|
||||
#define TEX_MINLIGHT_COLOR_B_MASK (255ULL << TEX_MINLIGHT_COLOR_B_SHIFT) /* 8 bit value, blue minlight color for this face. */
|
||||
|
||||
/*
|
||||
* Note that edge 0 is never used, because negative edge nums are used for
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ backend_t rtbackend = backend_embree;
|
|||
debugmode_t debugmode = debugmode_none;
|
||||
bool verbose_log = false;
|
||||
|
||||
uint32_t *extended_texinfo_flags = NULL;
|
||||
uint64_t *extended_texinfo_flags = NULL;
|
||||
|
||||
char mapfilename[1024];
|
||||
|
||||
|
|
@ -725,7 +725,7 @@ LoadExtendedTexinfoFlags(const char *sourcefilename, const bsp2_t *bsp)
|
|||
logprint("Loaded extended texinfo flags from %s\n", filename);
|
||||
|
||||
for (int i = 0; i < bsp->numtexinfo; i++) {
|
||||
int cnt = fscanf(texinfofile, "%u\n", &extended_texinfo_flags[i]);
|
||||
int cnt = fscanf(texinfofile, "%llu\n", &extended_texinfo_flags[i]);
|
||||
if (cnt != 1) {
|
||||
logprint("WARNING: Extended texinfo flags in %s does not match bsp, ignoring\n", filename);
|
||||
fclose(texinfofile);
|
||||
|
|
|
|||
|
|
@ -726,13 +726,22 @@ Lightsurf_Init(const modelinfo_t *modelinfo, const bsp2_dface_t *face,
|
|||
lightsurf->lightmapscale = modelinfo->lightmapscale;
|
||||
|
||||
// FIXME: is modelinfo used?!?
|
||||
lightsurf->curved = !!(extended_texinfo_flags[face->texinfo] & TEX_PHONG_ANGLE_MASK);
|
||||
lightsurf->nodirt = !!(extended_texinfo_flags[face->texinfo] & TEX_NODIRT);
|
||||
VectorCopy(*modelinfo->minlight_color.vec3Value(), lightsurf->minlight_color);
|
||||
lightsurf->minlight = (extended_texinfo_flags[face->texinfo] & TEX_MINLIGHT_MASK) >> TEX_MINLIGHT_SHIFT;
|
||||
/* fixup minlight color */
|
||||
if (lightsurf->minlight > 0 && VectorCompare(lightsurf->minlight_color, vec3_origin)) {
|
||||
VectorSet(lightsurf->minlight_color, 255, 255, 255);
|
||||
const uint64_t extended_flags = extended_texinfo_flags[face->texinfo];
|
||||
lightsurf->curved = !!(extended_flags & TEX_PHONG_ANGLE_MASK);
|
||||
lightsurf->nodirt = !!(extended_flags & TEX_NODIRT);
|
||||
lightsurf->minlight = (extended_flags & TEX_MINLIGHT_MASK) >> TEX_MINLIGHT_SHIFT;
|
||||
if (modelinfo->minlight_color.isChanged()) {
|
||||
VectorCopy(*modelinfo->minlight_color.vec3Value(), lightsurf->minlight_color);
|
||||
} else {
|
||||
// if modelinfo mincolor not set, use the one from the .texinfo file
|
||||
vec3_t extended_mincolor {
|
||||
static_cast<float>((extended_flags & TEX_MINLIGHT_COLOR_R_MASK) >> TEX_MINLIGHT_COLOR_R_SHIFT),
|
||||
static_cast<float>((extended_flags & TEX_MINLIGHT_COLOR_G_MASK) >> TEX_MINLIGHT_COLOR_G_SHIFT),
|
||||
static_cast<float>((extended_flags & TEX_MINLIGHT_COLOR_B_MASK) >> TEX_MINLIGHT_COLOR_B_SHIFT)};
|
||||
if (lightsurf->minlight > 0 && VectorCompare(extended_mincolor, vec3_origin)) {
|
||||
VectorSet(extended_mincolor, 255, 255, 255);
|
||||
}
|
||||
VectorCopy(extended_mincolor, lightsurf->minlight_color);
|
||||
}
|
||||
|
||||
/* never receive dirtmapping on lit liquids */
|
||||
|
|
|
|||
Loading…
Reference in New Issue