cvar_t gl_lightmaprgba = {"gl_lightmaprgba", "1"};
cvar_t gl_nosubimagefragments = {"gl_nosubimagefragments", "0"};
cvar_t gl_nosubimage = {"gl_nosubimage", "0"};
+cvar_t r_ambient = {"r_ambient", "0"};
qboolean lightmaprgba, nosubimagefragments, nosubimage;
int lightmapbytes;
Cvar_RegisterVariable(&gl_lightmaprgba);
Cvar_RegisterVariable(&gl_nosubimagefragments);
Cvar_RegisterVariable(&gl_nosubimage);
+ Cvar_RegisterVariable(&r_ambient);
// check if it's the glquake minigl driver
if (strncasecmp(gl_vendor,"3Dfx",4)==0)
if (!gl_arrays)
{
- Cvar_SetValue("gl_nosubimagefragments", 1);
+// Cvar_SetValue("gl_nosubimagefragments", 1);
// Cvar_SetValue("gl_nosubimage", 1);
Cvar_SetValue("gl_lightmode", 0);
}
surf->cached_dlight = (surf->dlightframe == r_framecount);
surf->cached_lighthalf = lighthalf;
+ surf->cached_ambient = r_ambient.value;
smax = (surf->extents[0]>>4)+1;
tmax = (surf->extents[1]>>4)+1;
{
// clear to no light
bl = blocklights;
+ j = r_ambient.value * 512.0f; // would be 256.0f logically, but using 512.0f to match winquake style
for (i=0 ; i<size ; i++)
{
- *bl++ = 0;
- *bl++ = 0;
- *bl++ = 0;
+ *bl++ = j;
+ *bl++ = j;
+ *bl++ = j;
}
// add all the lightmaps
if (nosubimage)
{
if (lightmaprgba)
- glTexImage2D(GL_TEXTURE_2D, 0, 4, BLOCK_WIDTH, BLOCK_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, lightmaps[i]);
+ glTexImage2D(GL_TEXTURE_2D, 0, 3, BLOCK_WIDTH, BLOCK_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, lightmaps[i]);
else
glTexImage2D(GL_TEXTURE_2D, 0, 3, BLOCK_WIDTH, BLOCK_HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, lightmaps[i]);
}
{
cl.worldmodel->textures[j]->texturechain = NULL;
t = R_TextureAnimation (cl.worldmodel->textures[j]);
- c_brush_polys++;
for (;s;s = s->texturechain)
{
if (currentwallpoly < MAX_WALLPOLYS && currentwallvert < MAX_WALLVERTS && (currentwallvert + s->polys->numverts) <= MAX_WALLVERTS)
{
// check for lightmap modification
-// if (r_dynamic.value)
-// {
- if (s->dlightframe == r_framecount || s->cached_dlight || lighthalf != s->cached_lighthalf) // dynamic this frame or previously, or lighthalf changed
+ if (r_dynamic.value)
+ {
+ if (s->dlightframe == r_framecount || s->cached_dlight || r_ambient.value != s->cached_ambient || lighthalf != s->cached_lighthalf) // dynamic this frame or previously, or lighthalf changed, or r_ambient changed
R_UpdateLightmap(s, s->lightmaptexturenum);
else
for (maps = 0 ; maps < MAXLIGHTMAPS && s->styles[maps] != 255 ; maps++)
R_UpdateLightmap(s, s->lightmaptexturenum);
break;
}
-// }
+ }
wallpoly[currentwallpoly].texnum = (unsigned short) t->gl_texturenum;
wallpoly[currentwallpoly].lighttexnum = (unsigned short) lightmap_textures + s->lightmaptexturenum;
wallpoly[currentwallpoly].glowtexnum = (unsigned short) t->gl_glowtexturenum;
light = false;
if (s->flags & SURF_DRAWFULLBRIGHT)
r = g = b = lighthalf ? 128 : 255;
- else if (s->dlightframe == r_dlightframecount/* && r_dynamicwater.value*/)
+ else if (s->dlightframe == r_dlightframecount && r_dynamic.value)
light = true;
else
- r = g = b = lighthalf ? 64 : 128;
+ r = g = b = (lighthalf ? 64 : 128) + (int) (r_ambient.value * 2.0f);
if (r_waterripple.value)
{
if (lighthalf)
nv[0] = v[0];
nv[1] = v[1];
nv[2] = v[2] + r_waterripple.value * turbsin[(int)((v[3]*0.125f+realtime) * TURBSCALE) & 255] * turbsin[(int)((v[4]*0.125f+realtime) * TURBSCALE) & 255] * (1.0f / 64.0f);
- shadecolor[0] = shadecolor[1] = shadecolor[2] = 128;
+ shadecolor[0] = shadecolor[1] = shadecolor[2] = 128 + (int) (r_ambient.value * 2.0f);
R_DynamicLightPoint(shadecolor, nv, s->dlightbits);
transpolyvert(nv[0], nv[1], nv[2], (v[3] + os) * (1.0f/64.0f), (v[4] + ot) * (1.0f/64.0f), (int) shadecolor[0] >> 1,(int) shadecolor[1] >> 1,(int) shadecolor[2] >> 1,alpha);
}
nv[0] = v[0];
nv[1] = v[1];
nv[2] = v[2] + r_waterripple.value * turbsin[(int)((v[3]*0.125f+realtime) * TURBSCALE) & 255] * turbsin[(int)((v[4]*0.125f+realtime) * TURBSCALE) & 255] * (1.0f / 64.0f);
- shadecolor[0] = shadecolor[1] = shadecolor[2] = 128;
+ shadecolor[0] = shadecolor[1] = shadecolor[2] = 128 + (int) (r_ambient.value * 2.0f);
R_DynamicLightPoint(shadecolor, nv, s->dlightbits);
transpolyvert(nv[0], nv[1], nv[2], (v[3] + os) * (1.0f/64.0f), (v[4] + ot) * (1.0f/64.0f), shadecolor[0],shadecolor[1],shadecolor[2],alpha);
}
transpolybegin(s->texinfo->texture->gl_texturenum, s->texinfo->texture->gl_glowtexturenum, 0, TPOLYTYPE_ALPHA);
for (i = 0,v = p->verts[0];i < p->numverts;i++, v += VERTEXSIZE)
{
- shadecolor[0] = shadecolor[1] = shadecolor[2] = 128;
+ shadecolor[0] = shadecolor[1] = shadecolor[2] = 128 + (int) (r_ambient.value * 2.0f);
R_DynamicLightPoint(shadecolor, v, s->dlightbits);
transpolyvert(v[0], v[1], v[2], (v[3] + os) * (1.0f/64.0f), (v[4] + ot) * (1.0f/64.0f), (int) shadecolor[0] >> 1,(int) shadecolor[1] >> 1,(int) shadecolor[2] >> 1,alpha);
}
transpolybegin(s->texinfo->texture->gl_texturenum, s->texinfo->texture->gl_glowtexturenum, 0, TPOLYTYPE_ALPHA);
for (i = 0,v = p->verts[0];i < p->numverts;i++, v += VERTEXSIZE)
{
- shadecolor[0] = shadecolor[1] = shadecolor[2] = 128;
+ shadecolor[0] = shadecolor[1] = shadecolor[2] = 128 + (int) (r_ambient.value * 2.0f);
R_DynamicLightPoint(shadecolor, v, s->dlightbits);
transpolyvert(v[0], v[1], v[2], (v[3] + os) * (1.0f/64.0f), (v[4] + ot) * (1.0f/64.0f), shadecolor[0],shadecolor[1],shadecolor[2],alpha);
}
b = 255.0f * currententity->colormod[2];
}
}
- else if (s->dlightframe == r_dlightframecount/* && r_dynamicwater.value*/)
+ else if (s->dlightframe == r_dlightframecount && r_dynamic.value)
light = true;
else
{
if (lighthalf)
{
- r = 64.0f * currententity->colormod[0];
- g = 64.0f * currententity->colormod[1];
- b = 64.0f * currententity->colormod[2];
+ r = 64.0f * currententity->colormod[0] + (int) r_ambient.value;
+ g = 64.0f * currententity->colormod[1] + (int) r_ambient.value;
+ b = 64.0f * currententity->colormod[2] + (int) r_ambient.value;
}
else
{
- r = 128.0f * currententity->colormod[0];
- g = 128.0f * currententity->colormod[1];
- b = 128.0f * currententity->colormod[2];
+ r = 128.0f * currententity->colormod[0] + (int) (r_ambient.value * 2.0f);
+ g = 128.0f * currententity->colormod[1] + (int) (r_ambient.value * 2.0f);
+ b = 128.0f * currententity->colormod[2] + (int) (r_ambient.value * 2.0f);
}
}
for (p=s->polys ; p ; p=p->next)
nv[2] += r_waterripple.value * turbsin[(int)((v[3]*0.125f+realtime) * TURBSCALE) & 255] * turbsin[(int)((v[4]*0.125f+realtime) * TURBSCALE) & 255] * (1.0f / 64.0f);
if (light)
{
- shadecolor[0] = shadecolor[1] = shadecolor[2] = 128;
+ shadecolor[0] = shadecolor[1] = shadecolor[2] = 128 + (int) (r_ambient.value * 2.0f);
R_DynamicLightPoint(shadecolor, nv, s->dlightbits);
if (lighthalf)
{
}
continue;
}
- c_brush_polys++;
t = R_TextureAnimation (s->texinfo->texture);
v = s->polys->verts[0];
if (vertexlit || s->texinfo->texture->transparent)
size3 = smax*tmax*3; // *3 for colored lighting
for (i = 0;i < s->polys->numverts;i++, v += VERTEXSIZE)
{
- shadecolor[0] = shadecolor[1] = shadecolor[2] = 0;
+ shadecolor[0] = shadecolor[1] = shadecolor[2] = r_ambient.value * 2.0f;
lm = (byte *)((long) s->samples + ((int) v[8] * smax + (int) v[7]) * 3); // LordHavoc: *3 for colored lighting
for (maps = 0;maps < MAXLIGHTMAPS && s->styles[maps] != 255;maps++)
{
else
{
// check for lightmap modification
-// if (r_dynamic.value)
-// {
- if (s->dlightframe == r_framecount || s->cached_dlight || lighthalf != s->cached_lighthalf) // dynamic this frame or previously, or lighthalf changed
+ if (r_dynamic.value)
+ {
+ if (s->dlightframe == r_framecount || s->cached_dlight || r_ambient.value != s->cached_ambient || lighthalf != s->cached_lighthalf) // dynamic this frame or previously, or lighthalf changed
R_UpdateLightmap(s, s->lightmaptexturenum);
else
for (maps = 0 ; maps < MAXLIGHTMAPS && s->styles[maps] != 255 ; maps++)
R_UpdateLightmap(s, s->lightmaptexturenum);
break;
}
-// }
+ }
if (currentwallpoly < MAX_WALLPOLYS && (currentwallvert + s->polys->numverts) <= MAX_WALLVERTS)
{
wallpoly[currentwallpoly].texnum = (unsigned short) t->gl_texturenum;
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if (lightmaprgba)
- glTexImage2D (GL_TEXTURE_2D, 0, 4, BLOCK_WIDTH, BLOCK_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, blank);
+ glTexImage2D (GL_TEXTURE_2D, 0, 3, BLOCK_WIDTH, BLOCK_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, blank);
else
glTexImage2D (GL_TEXTURE_2D, 0, 3, BLOCK_WIDTH, BLOCK_HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, blank);
}
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if (lightmaprgba)
- glTexImage2D(GL_TEXTURE_2D, 0, 4, BLOCK_WIDTH, BLOCK_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, lightmaps[i]);
+ glTexImage2D(GL_TEXTURE_2D, 0, 3, BLOCK_WIDTH, BLOCK_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, lightmaps[i]);
else
glTexImage2D(GL_TEXTURE_2D, 0, 3, BLOCK_WIDTH, BLOCK_HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, lightmaps[i]);
}