cvar_t r_floatbuildlightmap = {0, "r_floatbuildlightmap", "0"};
cvar_t r_detailtextures = {CVAR_SAVE, "r_detailtextures", "1"};
cvar_t r_surfaceworldnode = {0, "r_surfaceworldnode", "1"};
-cvar_t r_drawcollisionbrushes_polygonoffset = {0, "r_drawcollisionbrushes_polygonoffset", "-4"};
+cvar_t r_drawcollisionbrushes_polygonfactor = {0, "r_drawcollisionbrushes_polygonfactor", "-1"};
+cvar_t r_drawcollisionbrushes_polygonoffset = {0, "r_drawcollisionbrushes_polygonoffset", "0"};
+cvar_t gl_lightmaps = {0, "gl_lightmaps", "0"};
static int dlightdivtable[32768];
// set to full bright if no light data
bl = intblocklights;
- if ((ent->effects & EF_FULLBRIGHT) || !ent->model->brushq1.lightdata)
+ if (!ent->model->brushq1.lightdata)
{
for (i = 0;i < size3;i++)
bl[i] = 255*256;
// set to full bright if no light data
bl = floatblocklights;
- if ((ent->effects & EF_FULLBRIGHT) || !ent->model->brushq1.lightdata)
+ if (!ent->model->brushq1.lightdata)
j = 255*256;
else
j = r_ambient.value * 512.0f; // would be 128.0f logically, but using 512.0f to match winquake style
}
R_Mesh_Matrix(&ent->matrix);
- Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
+ Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
memset(&m, 0, sizeof(m));
texture = surf->texinfo->texture->currentframe;
float base, colorscale;
rmeshstate_t m;
float modelorg[3];
- Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
+ Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
memset(&m, 0, sizeof(m));
if (rendertype == SURFRENDER_ADD)
{
{
rmeshstate_t m;
float modelorg[3];
- Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
+ Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
memset(&m, 0, sizeof(m));
GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
GL_DepthMask(false);
{
rmeshstate_t m;
float modelorg[3];
- Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
+ Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
memset(&m, 0, sizeof(m));
GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
GL_DepthMask(false);
R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i);
}
-static void RSurfShader_OpaqueWall_Pass_BaseTripleTexCombine(const entity_render_t *ent, const texture_t *texture, msurface_t **surfchain)
+static void RSurfShader_OpaqueWall_Pass_BaseCombine_TextureLightmapDetailGlow(const entity_render_t *ent, const texture_t *texture, msurface_t **surfchain)
{
const msurface_t *surf;
rmeshstate_t m;
m.texrgbscale[1] = 2;
m.tex[2] = R_GetTexture(texture->skin.detail);
m.texrgbscale[2] = 2;
- GL_Color(1, 1, 1, 1);
+ if (texture->skin.glow)
+ {
+ m.tex[3] = R_GetTexture(texture->skin.glow);
+ m.texcombinergb[3] = GL_ADD;
+ }
+ if (r_shadow_realtime_world.integer)
+ GL_Color(r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, 1);
+ else
+ GL_Color(1, 1, 1, 1);
while((surf = *surfchain++) != NULL)
{
m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f;
m.pointer_texcoord[1] = surf->mesh.data_texcoordlightmap2f;
m.pointer_texcoord[2] = surf->mesh.data_texcoorddetail2f;
+ m.pointer_texcoord[3] = surf->mesh.data_texcoordtexture2f;
R_Mesh_State_Texture(&m);
R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i);
}
}
}
-static void RSurfShader_OpaqueWall_Pass_BaseDoubleTexCombine(const entity_render_t *ent, const texture_t *texture, msurface_t **surfchain)
+static void RSurfShader_OpaqueWall_Pass_BaseCombine_TextureLightmapDetail(const entity_render_t *ent, const texture_t *texture, msurface_t **surfchain)
{
const msurface_t *surf;
rmeshstate_t m;
m.tex[0] = R_GetTexture(texture->skin.base);
m.tex[1] = R_GetTexture((**surfchain).lightmaptexture);
m.texrgbscale[1] = 2;
- GL_Color(1, 1, 1, 1);
+ m.tex[2] = R_GetTexture(texture->skin.detail);
+ m.texrgbscale[2] = 2;
+ if (r_shadow_realtime_world.integer)
+ GL_Color(r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, 1);
+ else
+ GL_Color(1, 1, 1, 1);
+
+ while((surf = *surfchain++) != NULL)
+ {
+ if (surf->visframe == r_framecount)
+ {
+ lightmaptexturenum = R_GetTexture(surf->lightmaptexture);
+ //if (m.tex[1] != lightmaptexturenum)
+ //{
+ m.tex[1] = lightmaptexturenum;
+ // R_Mesh_State_Texture(&m);
+ //}
+ GL_VertexPointer(surf->mesh.data_vertex3f);
+ m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f;
+ m.pointer_texcoord[1] = surf->mesh.data_texcoordlightmap2f;
+ m.pointer_texcoord[2] = surf->mesh.data_texcoorddetail2f;
+ R_Mesh_State_Texture(&m);
+ R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i);
+ }
+ }
+}
+
+static void RSurfShader_OpaqueWall_Pass_BaseCombine_TextureLightmap(const entity_render_t *ent, const texture_t *texture, msurface_t **surfchain)
+{
+ const msurface_t *surf;
+ rmeshstate_t m;
+ int lightmaptexturenum;
+ memset(&m, 0, sizeof(m));
+ GL_BlendFunc(GL_ONE, GL_ZERO);
+ GL_DepthMask(true);
+ GL_DepthTest(true);
+ m.tex[0] = R_GetTexture(texture->skin.base);
+ m.tex[1] = R_GetTexture((**surfchain).lightmaptexture);
+ m.texrgbscale[1] = 2;
+ if (r_shadow_realtime_world.integer)
+ GL_Color(r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, 1);
+ else
+ GL_Color(1, 1, 1, 1);
while((surf = *surfchain++) != NULL)
{
if (surf->visframe == r_framecount)
GL_DepthTest(true);
GL_BlendFunc(GL_ONE, GL_ZERO);
m.tex[0] = R_GetTexture(texture->skin.base);
- GL_Color(1, 1, 1, 1);
+ if (r_shadow_realtime_world.integer)
+ GL_Color(r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, 1);
+ else
+ GL_Color(1, 1, 1, 1);
while((surf = *surfchain++) != NULL)
{
if (surf->visframe == r_framecount)
const msurface_t *surf;
rmeshstate_t m;
float modelorg[3];
- Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
+ Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
memset(&m, 0, sizeof(m));
GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GL_DepthMask(false);
}
}
+/*
static void RSurfShader_OpaqueWall_Pass_OpaqueGlow(const entity_render_t *ent, const texture_t *texture, msurface_t **surfchain)
{
const msurface_t *surf;
}
}
}
+*/
+
+static void RSurfShader_OpaqueWall_Pass_BaseLightmapOnly(const entity_render_t *ent, const texture_t *texture, msurface_t **surfchain)
+{
+ const msurface_t *surf;
+ rmeshstate_t m;
+ int lightmaptexturenum;
+ memset(&m, 0, sizeof(m));
+ GL_BlendFunc(GL_ONE, GL_ZERO);
+ GL_DepthMask(true);
+ GL_DepthTest(true);
+ m.tex[0] = R_GetTexture((**surfchain).lightmaptexture);
+ if (r_shadow_realtime_world.integer)
+ GL_Color(r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, 1);
+ else
+ GL_Color(1, 1, 1, 1);
+ while((surf = *surfchain++) != NULL)
+ {
+ if (surf->visframe == r_framecount)
+ {
+ lightmaptexturenum = R_GetTexture(surf->lightmaptexture);
+ //if (m.tex[0] != lightmaptexturenum)
+ //{
+ m.tex[0] = lightmaptexturenum;
+ // R_Mesh_State_Texture(&m);
+ //}
+ GL_VertexPointer(surf->mesh.data_vertex3f);
+ m.pointer_texcoord[0] = surf->mesh.data_texcoordlightmap2f;
+ R_Mesh_State_Texture(&m);
+ R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i);
+ }
+ }
+}
static void RSurfShader_Wall_Vertex_Callback(const void *calldata1, int calldata2)
{
}
}
}
- else if (r_shadow_realtime_world.integer)
+ else if (ent->effects & EF_FULLBRIGHT)
{
- // opaque base lighting
- RSurfShader_OpaqueWall_Pass_OpaqueGlow(ent, texture, surfchain);
+ RSurfShader_OpaqueWall_Pass_BaseTexture(ent, texture, surfchain);
+ if (r_detailtextures.integer)
+ RSurfShader_OpaqueWall_Pass_BaseDetail(ent, texture, surfchain);
+ if (texture->skin.glow)
+ RSurfShader_OpaqueWall_Pass_Glow(ent, texture, surfchain);
if (fogenabled)
RSurfShader_OpaqueWall_Pass_Fog(ent, texture, surfchain);
}
- else
+ /*
+ // opaque base lighting
+ else if (r_shadow_realtime_world.integer && r_shadow_realtime_world_lightmaps.value <= 0)
{
- // opaque lightmapped
- if (r_textureunits.integer >= 3 && gl_combine.integer && r_detailtextures.integer)
+ if (r_ambient.value > 0)
{
- RSurfShader_OpaqueWall_Pass_BaseTripleTexCombine(ent, texture, surfchain);
- if (texture->skin.glow)
- RSurfShader_OpaqueWall_Pass_Glow(ent, texture, surfchain);
- if (fogenabled)
- RSurfShader_OpaqueWall_Pass_Fog(ent, texture, surfchain);
- }
- else if (r_textureunits.integer >= 2 && gl_combine.integer)
- {
- RSurfShader_OpaqueWall_Pass_BaseDoubleTexCombine(ent, texture, surfchain);
- if (r_detailtextures.integer)
- RSurfShader_OpaqueWall_Pass_BaseDetail(ent, texture, surfchain);
- if (texture->skin.glow)
- RSurfShader_OpaqueWall_Pass_Glow(ent, texture, surfchain);
- if (fogenabled)
- RSurfShader_OpaqueWall_Pass_Fog(ent, texture, surfchain);
}
else
- {
- RSurfShader_OpaqueWall_Pass_BaseTexture(ent, texture, surfchain);
- RSurfShader_OpaqueWall_Pass_BaseLightmap(ent, texture, surfchain);
- if (r_detailtextures.integer)
- RSurfShader_OpaqueWall_Pass_BaseDetail(ent, texture, surfchain);
- if (texture->skin.glow)
- RSurfShader_OpaqueWall_Pass_Glow(ent, texture, surfchain);
- if (fogenabled)
- RSurfShader_OpaqueWall_Pass_Fog(ent, texture, surfchain);
- }
+ RSurfShader_OpaqueWall_Pass_OpaqueGlow(ent, texture, surfchain);
+ if (fogenabled)
+ RSurfShader_OpaqueWall_Pass_Fog(ent, texture, surfchain);
+ }
+ */
+ // opaque lightmapped
+ else if (r_textureunits.integer >= 4 && gl_combine.integer && r_detailtextures.integer && !gl_lightmaps.integer)
+ {
+ RSurfShader_OpaqueWall_Pass_BaseCombine_TextureLightmapDetailGlow(ent, texture, surfchain);
+ if (fogenabled)
+ RSurfShader_OpaqueWall_Pass_Fog(ent, texture, surfchain);
+ }
+ else if (r_textureunits.integer >= 3 && gl_combine.integer && r_detailtextures.integer && !gl_lightmaps.integer)
+ {
+ RSurfShader_OpaqueWall_Pass_BaseCombine_TextureLightmapDetail(ent, texture, surfchain);
+ if (texture->skin.glow)
+ RSurfShader_OpaqueWall_Pass_Glow(ent, texture, surfchain);
+ if (fogenabled)
+ RSurfShader_OpaqueWall_Pass_Fog(ent, texture, surfchain);
+ }
+ else if (r_textureunits.integer >= 2 && gl_combine.integer && !gl_lightmaps.integer)
+ {
+ RSurfShader_OpaqueWall_Pass_BaseCombine_TextureLightmap(ent, texture, surfchain);
+ if (r_detailtextures.integer)
+ RSurfShader_OpaqueWall_Pass_BaseDetail(ent, texture, surfchain);
+ if (texture->skin.glow)
+ RSurfShader_OpaqueWall_Pass_Glow(ent, texture, surfchain);
+ if (fogenabled)
+ RSurfShader_OpaqueWall_Pass_Fog(ent, texture, surfchain);
+ }
+ else if (!gl_lightmaps.integer)
+ {
+ RSurfShader_OpaqueWall_Pass_BaseTexture(ent, texture, surfchain);
+ RSurfShader_OpaqueWall_Pass_BaseLightmap(ent, texture, surfchain);
+ if (r_detailtextures.integer)
+ RSurfShader_OpaqueWall_Pass_BaseDetail(ent, texture, surfchain);
+ if (texture->skin.glow)
+ RSurfShader_OpaqueWall_Pass_Glow(ent, texture, surfchain);
+ if (fogenabled)
+ RSurfShader_OpaqueWall_Pass_Fog(ent, texture, surfchain);
+ }
+ else
+ {
+ RSurfShader_OpaqueWall_Pass_BaseLightmapOnly(ent, texture, surfchain);
+ if (fogenabled)
+ RSurfShader_OpaqueWall_Pass_Fog(ent, texture, surfchain);
}
}
return;
model = ent->model;
- Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
+ Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
numsurfaces = model->brushq1.nummodelsurfaces;
surfaces = model->brushq1.surfaces + model->brushq1.firstmodelsurface;
surfacevisframes = model->brushq1.surfacevisframes + model->brushq1.firstmodelsurface;
((i & 0x0038) >> 3) * (1.0f / 7.0f),
((i & 0x01C0) >> 6) * (1.0f / 7.0f),
0.125f);
- if (PlaneDiff(r_origin, (&portal->plane)) < 0)
+ if (PlaneDiff(r_vieworigin, (&portal->plane)) < 0)
{
for (i = portal->numpoints - 1, v = varray_vertex3f;i >= 0;i--, v += 3)
VectorCopy(portal->points[i].position, v);
if (model == NULL)
return;
#if WORLDNODECULLBACKFACES
- Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
+ Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
#endif
numsurfaces = model->brushq1.nummodelsurfaces;
surf = model->brushq1.surfaces + model->brushq1.firstmodelsurface;
return;
surfacevisframes = model->brushq1.surfacevisframes + model->brushq1.firstmodelsurface;
surfacepvsframes = model->brushq1.surfacepvsframes + model->brushq1.firstmodelsurface;
- Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
+ Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
for (leaf = model->brushq1.pvsleafchain;leaf;leaf = leaf->pvschain)
{
static void R_PortalWorldNode(entity_render_t *ent, mleaf_t *viewleaf)
{
- int c, leafstackpos, *mark, *surfacevisframes, bitnum;
+ int c, leafstackpos, *mark, *surfacevisframes;
#if WORLDNODECULLBACKFACES
int n;
msurface_t *surf;
// RecursiveWorldNode
surfaces = ent->model->brushq1.surfaces;
surfacevisframes = ent->model->brushq1.surfacevisframes;
- Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
+ Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
viewleaf->worldnodeframe = r_framecount;
leafstack[0] = viewleaf;
leafstackpos = 1;
{
leaf->worldnodeframe = r_framecount;
// FIXME: R_CullBox is absolute, should be done relative
- bitnum = (leaf - ent->model->brushq1.leafs) - 1;
- if ((r_pvsbits[bitnum >> 3] & (1 << (bitnum & 7))) && !R_CullBox(leaf->mins, leaf->maxs))
+ if (CHECKPVSBIT(r_pvsbits, leaf->clusterindex) && !R_CullBox(leaf->mins, leaf->maxs))
leafstack[leafstackpos++] = leaf;
}
}
if (viewleaf)
{
surfacepvsframes = model->brushq1.surfacepvsframes;
- for (j = 0;j < model->brushq1.visleafs;j++)
+ for (j = 0, leaf = model->brushq1.data_leafs;j < model->brushq1.num_leafs;j++, leaf++)
{
- if (r_pvsbits[j >> 3] & (1 << (j & 7)))
+ if (CHECKPVSBIT(r_pvsbits, leaf->clusterindex))
{
- leaf = model->brushq1.leafs + j + 1;
leaf->pvsframe = model->brushq1.pvsframecount;
leaf->pvschain = model->brushq1.pvsleafchain;
model->brushq1.pvsleafchain = leaf;
vec3_t modelorg;
mleaf_t *viewleaf;
- Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
+ Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
viewleaf = (ent->model && ent->model->brushq1.PointInLeaf) ? ent->model->brushq1.PointInLeaf(ent->model, modelorg) : NULL;
R_PVSUpdate(ent, viewleaf);
{
if (ent->model == NULL)
return;
- if (!ent->model->brushq1.numleafs)
+ if (!ent->model->brushq1.num_leafs)
{
if (ent->model->DrawSky)
ent->model->DrawSky(ent);
}
}
-void R_Model_Brush_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor, const matrix4x4_t *matrix_modeltofilter, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz)
+void R_Model_Brush_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor, const matrix4x4_t *matrix_modeltolight, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz, rtexture_t *lightcubemap)
{
int surfnum;
msurface_t *surf;
t = surf->texinfo->texture->currentframe;
if (t->rendertype == SURFRENDER_OPAQUE && t->flags & SURF_SHADOWLIGHT)
{
- R_Shadow_DiffuseLighting(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i, surf->mesh.data_vertex3f, surf->mesh.data_svector3f, surf->mesh.data_tvector3f, surf->mesh.data_normal3f, surf->mesh.data_texcoordtexture2f, relativelightorigin, lightradius, lightcolor, matrix_modeltofilter, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, t->skin.base, t->skin.nmap, NULL);
- R_Shadow_SpecularLighting(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i, surf->mesh.data_vertex3f, surf->mesh.data_svector3f, surf->mesh.data_tvector3f, surf->mesh.data_normal3f, surf->mesh.data_texcoordtexture2f, relativelightorigin, relativeeyeorigin, lightradius, lightcolor, matrix_modeltofilter, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, t->skin.gloss, t->skin.nmap, NULL);
+ R_Shadow_DiffuseLighting(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i, surf->mesh.data_vertex3f, surf->mesh.data_svector3f, surf->mesh.data_tvector3f, surf->mesh.data_normal3f, surf->mesh.data_texcoordtexture2f, relativelightorigin, lightradius, lightcolor, matrix_modeltolight, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, t->skin.base, t->skin.nmap, lightcubemap);
+ R_Shadow_SpecularLighting(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i, surf->mesh.data_vertex3f, surf->mesh.data_svector3f, surf->mesh.data_tvector3f, surf->mesh.data_normal3f, surf->mesh.data_texcoordtexture2f, relativelightorigin, relativeeyeorigin, lightradius, lightcolor, matrix_modeltolight, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, t->skin.gloss, t->skin.nmap, lightcubemap);
}
}
}
rmeshstate_t m;
if (!face->num_triangles)
return;
+ c_faces++;
if (skyrendernow)
{
skyrendernow = false;
{
rmeshstate_t m;
memset(&m, 0, sizeof(m));
- GL_BlendFunc(GL_ONE, GL_SRC_COLOR);
- GL_DepthMask(true);
+ GL_BlendFunc(GL_DST_COLOR, GL_SRC_COLOR);
+ GL_DepthMask(false);
GL_DepthTest(true);
m.tex[0] = R_GetTexture(face->lightmaptexture);
m.pointer_texcoord[0] = face->data_texcoordlightmap2f;
R_Mesh_Draw(face->num_vertices, face->num_triangles, face->data_element3i);
}
+void R_Q3BSP_DrawFace_OpaqueWall_Pass_LightmapOnly(entity_render_t *ent, q3mface_t *face)
+{
+ rmeshstate_t m;
+ memset(&m, 0, sizeof(m));
+ GL_BlendFunc(GL_ONE, GL_ZERO);
+ GL_DepthMask(true);
+ GL_DepthTest(true);
+ m.tex[0] = R_GetTexture(face->lightmaptexture);
+ m.pointer_texcoord[0] = face->data_texcoordlightmap2f;
+ if (r_shadow_realtime_world.integer)
+ GL_Color(r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, 1);
+ else
+ GL_Color(1, 1, 1, 1);
+ R_Mesh_State_Texture(&m);
+ GL_VertexPointer(face->data_vertex3f);
+ R_Mesh_Draw(face->num_vertices, face->num_triangles, face->data_element3i);
+}
+
void R_Q3BSP_DrawFace_OpaqueWall_Pass_Glow(entity_render_t *ent, q3mface_t *face)
{
rmeshstate_t m;
memset(&m, 0, sizeof(m));
GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
- GL_DepthMask(true);
+ GL_DepthMask(false);
GL_DepthTest(true);
if (face->texture->skin.glow)
{
void R_Q3BSP_DrawFace_OpaqueWall_Pass_TextureVertex(entity_render_t *ent, q3mface_t *face)
{
+ int i;
+ float mul;
rmeshstate_t m;
memset(&m, 0, sizeof(m));
GL_BlendFunc(GL_ONE, GL_ZERO);
GL_DepthTest(true);
m.tex[0] = R_GetTexture(face->texture->skin.base);
m.pointer_texcoord[0] = face->data_texcoordtexture2f;
- if (gl_combine.integer)
+ mul = 2.0f;
+ if (r_shadow_realtime_world.integer && r_shadow_realtime_world_lightmaps.value != 1)
+ mul *= r_shadow_realtime_world_lightmaps.value;
+ if (mul == 2 && gl_combine.integer)
{
m.texrgbscale[0] = 2;
GL_ColorPointer(face->data_color4f);
}
+ else if (mul == 1)
+ GL_ColorPointer(face->data_color4f);
+ else
+ {
+ for (i = 0;i < face->num_vertices;i++)
+ {
+ varray_color4f[i*4+0] = face->data_color4f[i*4+0] * mul;
+ varray_color4f[i*4+1] = face->data_color4f[i*4+1] * mul;
+ varray_color4f[i*4+2] = face->data_color4f[i*4+2] * mul;
+ varray_color4f[i*4+3] = face->data_color4f[i*4+3];
+ }
+ GL_ColorPointer(varray_color4f);
+ }
+ R_Mesh_State_Texture(&m);
+ GL_VertexPointer(face->data_vertex3f);
+ R_Mesh_Draw(face->num_vertices, face->num_triangles, face->data_element3i);
+}
+
+void R_Q3BSP_DrawFace_OpaqueWall_Pass_VertexOnly(entity_render_t *ent, q3mface_t *face)
+{
+ int i;
+ float mul;
+ rmeshstate_t m;
+ memset(&m, 0, sizeof(m));
+ GL_BlendFunc(GL_ONE, GL_ZERO);
+ GL_DepthMask(true);
+ GL_DepthTest(true);
+ R_Mesh_State_Texture(&m);
+ mul = 2.0f;
+ if (r_shadow_realtime_world.integer && r_shadow_realtime_world_lightmaps.value != 1)
+ mul *= r_shadow_realtime_world_lightmaps.value;
+ if (mul == 1)
+ GL_ColorPointer(face->data_color4f);
else
{
- int i;
for (i = 0;i < face->num_vertices;i++)
{
varray_color4f[i*4+0] = face->data_color4f[i*4+0] * 2.0f;
}
GL_ColorPointer(varray_color4f);
}
- R_Mesh_State_Texture(&m);
GL_VertexPointer(face->data_vertex3f);
R_Mesh_Draw(face->num_vertices, face->num_triangles, face->data_element3i);
}
{
if (!face->num_triangles)
return;
- if (face->texture->renderflags)
+ if (face->texture->surfaceparms)
{
- if (face->texture->renderflags & Q3MTEXTURERENDERFLAGS_SKY)
- return;
- if (face->texture->renderflags & Q3MTEXTURERENDERFLAGS_NODRAW)
+ if (face->texture->surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NODRAW))
return;
}
+ c_faces++;
face->visframe = r_framecount;
- if ((face->texture->renderflags & Q3MTEXTURERENDERFLAGS_TRANSPARENT) || ent->alpha < 1 || (ent->effects & EF_ADDITIVE))
+ if ((face->texture->surfaceparms & Q3SURFACEPARM_TRANS) || ent->alpha < 1 || (ent->effects & EF_ADDITIVE))
{
vec3_t facecenter, center;
facecenter[0] = (face->mins[0] + face->maxs[0]) * 0.5f;
return;
}
R_Mesh_Matrix(&ent->matrix);
- if (r_shadow_realtime_world.integer)
+ if (r_shadow_realtime_world.integer && r_shadow_realtime_world_lightmaps.value <= 0)
R_Q3BSP_DrawFace_OpaqueWall_Pass_OpaqueGlow(ent, face);
else if ((ent->effects & EF_FULLBRIGHT) || r_fullbright.integer)
{
}
else if (face->lightmaptexture)
{
- if (r_textureunits.integer >= 2 && gl_combine.integer)
- R_Q3BSP_DrawFace_OpaqueWall_Pass_TextureLightmapCombine(ent, face);
+ if (gl_lightmaps.integer)
+ R_Q3BSP_DrawFace_OpaqueWall_Pass_LightmapOnly(ent, face);
else
{
- R_Q3BSP_DrawFace_OpaqueWall_Pass_Texture(ent, face);
- R_Q3BSP_DrawFace_OpaqueWall_Pass_Lightmap(ent, face);
+ if (r_textureunits.integer >= 2 && gl_combine.integer)
+ R_Q3BSP_DrawFace_OpaqueWall_Pass_TextureLightmapCombine(ent, face);
+ else
+ {
+ R_Q3BSP_DrawFace_OpaqueWall_Pass_Texture(ent, face);
+ R_Q3BSP_DrawFace_OpaqueWall_Pass_Lightmap(ent, face);
+ }
+ if (face->texture->skin.glow)
+ R_Q3BSP_DrawFace_OpaqueWall_Pass_Glow(ent, face);
}
- if (face->texture->skin.glow)
- R_Q3BSP_DrawFace_OpaqueWall_Pass_Glow(ent, face);
}
else
{
- R_Q3BSP_DrawFace_OpaqueWall_Pass_TextureVertex(ent, face);
- if (face->texture->skin.glow)
- R_Q3BSP_DrawFace_OpaqueWall_Pass_Glow(ent, face);
+ if (gl_lightmaps.integer)
+ R_Q3BSP_DrawFace_OpaqueWall_Pass_VertexOnly(ent, face);
+ else
+ {
+ R_Q3BSP_DrawFace_OpaqueWall_Pass_TextureVertex(ent, face);
+ if (face->texture->skin.glow)
+ R_Q3BSP_DrawFace_OpaqueWall_Pass_Glow(ent, face);
+ }
}
if (r_ambient.value)
R_Q3BSP_DrawFace_OpaqueWall_Pass_AddTextureAmbient(ent, face);
{
int i;
q3mleaf_t *leaf;
- while (node->isnode)
+ for (;;)
{
if (R_CullBox(node->mins, node->maxs))
return;
+ if (!node->plane)
+ break;
+ c_nodes++;
R_Q3BSP_RecursiveWorldNode(ent, node->children[0], modelorg, pvs, markframe);
node = node->children[1];
}
- if (R_CullBox(node->mins, node->maxs))
- return;
leaf = (q3mleaf_t *)node;
- if (pvs[leaf->clusterindex >> 3] & (1 << (leaf->clusterindex & 7)))
+ if (CHECKPVSBIT(pvs, leaf->clusterindex))
+ {
+ c_leafs++;
for (i = 0;i < leaf->numleaffaces;i++)
leaf->firstleafface[i]->markframe = markframe;
+ }
+}
+
+// FIXME: num_leafs needs to be recalculated at load time to include only
+// node-referenced leafs, as some maps are incorrectly compiled with leafs for
+// the submodels (which would render the submodels occasionally, as part of
+// the world - not good)
+void R_Q3BSP_MarkLeafPVS(entity_render_t *ent, qbyte *pvs, int markframe)
+{
+ int i, j;
+ q3mleaf_t *leaf;
+ for (j = 0, leaf = ent->model->brushq3.data_leafs;j < ent->model->brushq3.num_leafs;j++, leaf++)
+ {
+ if (CHECKPVSBIT(pvs, leaf->clusterindex))
+ {
+ c_leafs++;
+ for (i = 0;i < leaf->numleaffaces;i++)
+ leaf->firstleafface[i]->markframe = markframe;
+ }
+ }
}
static int r_q3bsp_framecount = -1;
model = ent->model;
if (r_drawcollisionbrushes.integer < 2)
{
- Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
+ Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
if (ent == &cl_entities[0].render && model->brushq3.num_pvsclusters && !r_novis.integer && (pvs = model->brush.GetPVS(model, modelorg)))
{
if (r_q3bsp_framecount != r_framecount)
{
r_q3bsp_framecount = r_framecount;
R_Q3BSP_RecursiveWorldNode(ent, model->brushq3.data_nodes, modelorg, pvs, r_framecount);
+ //R_Q3BSP_MarkLeafPVS(ent, pvs, r_framecount);
}
for (i = 0, face = model->brushq3.data_thismodel->firstface;i < model->brushq3.data_thismodel->numfaces;i++, face++)
- if (face->markframe == r_framecount && (face->texture->renderflags & Q3MTEXTURERENDERFLAGS_SKY) && !R_CullBox(face->mins, face->maxs))
+ if (face->markframe == r_framecount && (face->texture->surfaceflags & Q3SURFACEFLAG_SKY) && !R_CullBox(face->mins, face->maxs))
R_Q3BSP_DrawSkyFace(ent, face);
}
else
for (i = 0, face = model->brushq3.data_thismodel->firstface;i < model->brushq3.data_thismodel->numfaces;i++, face++)
- if ((face->texture->renderflags & Q3MTEXTURERENDERFLAGS_SKY))
+ if ((face->texture->surfaceflags & Q3SURFACEFLAG_SKY))
R_Q3BSP_DrawSkyFace(ent, face);
}
}
model = ent->model;
if (r_drawcollisionbrushes.integer < 2)
{
- Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
+ Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
if (ent == &cl_entities[0].render && model->brushq3.num_pvsclusters && !r_novis.integer && (pvs = model->brush.GetPVS(model, modelorg)))
{
if (r_q3bsp_framecount != r_framecount)
{
r_q3bsp_framecount = r_framecount;
R_Q3BSP_RecursiveWorldNode(ent, model->brushq3.data_nodes, modelorg, pvs, r_framecount);
+ //R_Q3BSP_MarkLeafPVS(ent, pvs, r_framecount);
}
for (i = 0, face = model->brushq3.data_thismodel->firstface;i < model->brushq3.data_thismodel->numfaces;i++, face++)
if (face->markframe == r_framecount && !R_CullBox(face->mins, face->maxs))
GL_DepthMask(false);
GL_DepthTest(true);
R_Mesh_State_Texture(&m);
+ qglPolygonOffset(r_drawcollisionbrushes_polygonfactor.value, r_drawcollisionbrushes_polygonoffset.value);
for (i = 0;i < model->brushq3.data_thismodel->numbrushes;i++)
if (model->brushq3.data_thismodel->firstbrush[i].colbrushf && model->brushq3.data_thismodel->firstbrush[i].colbrushf->numtriangles)
R_DrawCollisionBrush(model->brushq3.data_thismodel->firstbrush[i].colbrushf);
+ qglPolygonOffset(0, 0);
}
}
{
model = ent->model;
R_Mesh_Matrix(&ent->matrix);
- Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
+ Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
lightmins[0] = relativelightorigin[0] - lightradius;
lightmins[1] = relativelightorigin[1] - lightradius;
lightmins[2] = relativelightorigin[2] - lightradius;
}
}
-void R_Q3BSP_DrawFaceLight(entity_render_t *ent, q3mface_t *face, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor, const matrix4x4_t *matrix_modeltofilter, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz)
+void R_Q3BSP_DrawFaceLight(entity_render_t *ent, q3mface_t *face, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor, const matrix4x4_t *matrix_modeltolight, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz, rtexture_t *lightcubemap)
{
- if ((face->texture->renderflags & Q3MTEXTURERENDERFLAGS_NODRAW) || !face->num_triangles)
+ if ((face->texture->surfaceflags & Q3SURFACEFLAG_NODRAW) || !face->num_triangles)
return;
- R_Shadow_DiffuseLighting(face->num_vertices, face->num_triangles, face->data_element3i, face->data_vertex3f, face->data_svector3f, face->data_tvector3f, face->data_normal3f, face->data_texcoordtexture2f, relativelightorigin, lightradius, lightcolor, matrix_modeltofilter, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, face->texture->skin.base, face->texture->skin.nmap, NULL);
- R_Shadow_SpecularLighting(face->num_vertices, face->num_triangles, face->data_element3i, face->data_vertex3f, face->data_svector3f, face->data_tvector3f, face->data_normal3f, face->data_texcoordtexture2f, relativelightorigin, relativeeyeorigin, lightradius, lightcolor, matrix_modeltofilter, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, face->texture->skin.gloss, face->texture->skin.nmap, NULL);
+ R_Shadow_DiffuseLighting(face->num_vertices, face->num_triangles, face->data_element3i, face->data_vertex3f, face->data_svector3f, face->data_tvector3f, face->data_normal3f, face->data_texcoordtexture2f, relativelightorigin, lightradius, lightcolor, matrix_modeltolight, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, face->texture->skin.base, face->texture->skin.nmap, lightcubemap);
+ R_Shadow_SpecularLighting(face->num_vertices, face->num_triangles, face->data_element3i, face->data_vertex3f, face->data_svector3f, face->data_tvector3f, face->data_normal3f, face->data_texcoordtexture2f, relativelightorigin, relativeeyeorigin, lightradius, lightcolor, matrix_modeltolight, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, face->texture->skin.gloss, face->texture->skin.nmap, lightcubemap);
}
-void R_Q3BSP_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor, const matrix4x4_t *matrix_modeltofilter, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz)
+void R_Q3BSP_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor, const matrix4x4_t *matrix_modeltolight, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz, rtexture_t *lightcubemap)
{
int i;
q3mface_t *face;
{
model = ent->model;
R_Mesh_Matrix(&ent->matrix);
- Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
+ Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
lightmins[0] = relativelightorigin[0] - lightradius;
lightmins[1] = relativelightorigin[1] - lightradius;
lightmins[2] = relativelightorigin[2] - lightradius;
//else
for (i = 0, face = model->brushq3.data_thismodel->firstface;i < model->brushq3.data_thismodel->numfaces;i++, face++)
if ((ent != &cl_entities[0].render || face->visframe == r_framecount) && BoxesOverlap(lightmins, lightmaxs, face->mins, face->maxs))
- R_Q3BSP_DrawFaceLight(ent, face, relativelightorigin, relativeeyeorigin, lightradius, lightcolor, matrix_modeltofilter, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz);
+ R_Q3BSP_DrawFaceLight(ent, face, relativelightorigin, relativeeyeorigin, lightradius, lightcolor, matrix_modeltolight, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, lightcubemap);
}
}
Cvar_RegisterVariable(&r_floatbuildlightmap);
Cvar_RegisterVariable(&r_detailtextures);
Cvar_RegisterVariable(&r_surfaceworldnode);
+ Cvar_RegisterVariable(&r_drawcollisionbrushes_polygonfactor);
Cvar_RegisterVariable(&r_drawcollisionbrushes_polygonoffset);
+ Cvar_RegisterVariable(&gl_lightmaps);
R_RegisterModule("GL_Surf", gl_surf_start, gl_surf_shutdown, gl_surf_newmap);
}