R_Mesh_Draw(&m);
}
+static void RSurfShader_Wall_Pass_BaseFullbright(msurface_t *s)
+{
+ int i;
+ float diff[3], ifog;
+ surfvertex_t *v;
+ surfvert_t *sv;
+ rmeshinfo_t m;
+
+ memset(&m, 0, sizeof(m));
+ if (currentrenderentity->effects & EF_ADDITIVE)
+ {
+ m.transparent = true;
+ m.blendfunc1 = GL_SRC_ALPHA;
+ m.blendfunc2 = GL_ONE;
+ }
+ else if (currentrenderentity != &cl_entities[0].render && (s->currenttexture->fogtexture != NULL || currentrenderentity->alpha != 1))
+ {
+ m.transparent = true;
+ m.blendfunc1 = GL_SRC_ALPHA;
+ m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
+ }
+ else
+ {
+ m.transparent = false;
+ m.blendfunc1 = GL_ONE;
+ m.blendfunc2 = GL_ZERO;
+ }
+ m.numtriangles = s->mesh.numtriangles;
+ m.numverts = s->mesh.numverts;
+ m.index = s->mesh.index;
+ m.vertex = &svert[0].v[0];
+ m.vertexstep = sizeof(surfvert_t);
+ m.tex[0] = R_GetTexture(s->currenttexture->texture);
+ m.texcoords[0] = &s->mesh.vertex->st[0];
+ m.texcoordstep[0] = sizeof(surfvertex_t);
+ if (fogenabled)
+ {
+ m.color = &svert[0].c[0];
+ m.colorstep = sizeof(surfvert_t);
+ for (i = 0, sv = svert, v = s->mesh.vertex;i < m.numverts;i++, sv++, v++)
+ {
+ softwaretransform(v->v, sv->v);
+ VectorSubtract(sv->v, r_origin, diff);
+ ifog = 1 - exp(fogdensity/DotProduct(diff, diff));
+ sv->c[0] = ifog;
+ sv->c[1] = ifog;
+ sv->c[2] = ifog;
+ sv->c[3] = currentrenderentity->alpha;
+ }
+ }
+ else
+ {
+ m.cr = m.cg = m.cb = 1;
+ m.ca = currentrenderentity->alpha;
+ for (i = 0, sv = svert, v = s->mesh.vertex;i < m.numverts;i++, sv++, v++)
+ softwaretransform(v->v, sv->v);
+ }
+ R_Mesh_Draw(&m);
+}
+
static void RSurfShader_Wall_Pass_Light(msurface_t *s)
{
int i;
R_Mesh_Draw(&m);
}
+static int RSurfShader_Wall_Fullbright(int stage, msurface_t *s)
+{
+ switch(stage)
+ {
+ case 0:
+ RSurfShader_Wall_Pass_BaseFullbright(s);
+ return false;
+ case 1:
+ if (s->currenttexture->glowtexture)
+ RSurfShader_Wall_Pass_Glow(s);
+ return false;
+ default:
+ return true;
+ }
+}
+
static int RSurfShader_Wall_Vertex(int stage, msurface_t *s)
{
switch(stage)
Cshader_t Cshader_wall_vertex = {{NULL, RSurfShader_Wall_Vertex, RSurfShader_Wall_Fog}, NULL};
Cshader_t Cshader_wall_lightmap = {{NULL, RSurfShader_Wall_Lightmap, RSurfShader_Wall_Fog}, NULL};
+Cshader_t Cshader_wall_fullbright = {{NULL, RSurfShader_Wall_Fullbright, RSurfShader_Wall_Fog}, NULL};
Cshader_t Cshader_water = {{NULL, RSurfShader_Water, NULL}, NULL};
Cshader_t Cshader_sky = {{RSurfShader_Sky, NULL, NULL}, NULL};
-int Cshader_count = 4;
-Cshader_t *Cshaders[4] =
+int Cshader_count = 5;
+Cshader_t *Cshaders[5] =
{
&Cshader_wall_vertex,
&Cshader_wall_lightmap,
+ &Cshader_wall_fullbright,
&Cshader_water,
&Cshader_sky
};
s->texturemins[i] = bmins[i] * 16;
s->extents[i] = (bmaxs[i] - bmins[i]) * 16;
-// if ( !(tex->flags & TEX_SPECIAL) && s->extents[i] > 512)
- if ((tex->flags & TEX_SPECIAL) == 0 && (s->extents[i]+1) > (256*16))
- Host_Error ("Bad surface extents");
}
}
}
}
+void Mod_GenerateVertexMesh (msurface_t *surf)
+{
+ int i, *index;
+ float *in;
+ surfvertex_t *out;
+ surfmesh_t *mesh;
+
+ surf->lightmaptexturestride = 0;
+ surf->lightmaptexture = NULL;
+
+ mesh = &surf->mesh;
+ mesh->numverts = surf->poly_numverts;
+ mesh->numtriangles = surf->poly_numverts - 2;
+ mesh->index = Mem_Alloc(loadmodel->mempool, mesh->numtriangles * sizeof(int[3]) + mesh->numverts * sizeof(surfvertex_t));
+ mesh->vertex = (surfvertex_t *)((long) mesh->index + mesh->numtriangles * sizeof(int[3]));
+ memset(mesh->vertex, 0, mesh->numverts * sizeof(surfvertex_t));
+
+ index = mesh->index;
+ for (i = 0;i < mesh->numtriangles;i++)
+ {
+ *index++ = 0;
+ *index++ = i + 1;
+ *index++ = i + 2;
+ }
+
+ for (i = 0, in = surf->poly_verts, out = mesh->vertex;i < mesh->numverts;i++, in += 3, out++)
+ {
+ VectorCopy (in, out->v);
+ out->st[0] = (DotProduct (out->v, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3]) / surf->texinfo->texture->width;
+ out->st[1] = (DotProduct (out->v, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3]) / surf->texinfo->texture->height;
+ }
+}
+
void Mod_GenerateSurfacePolygon (msurface_t *surf)
{
float *vert;
if (out->texinfo->texture->flags & SURF_DRAWSKY)
{
out->shader = &Cshader_sky;
+ out->samples = NULL;
Mod_GenerateWarpMesh (out);
continue;
}
out->texturemins[i] = -8192*1024;
}
*/
+ out->samples = NULL;
Mod_GenerateWarpMesh (out);
continue;
}
{
// qbsp couldn't find the texture for this surface, but it was either turb or sky... assume turb
out->shader = &Cshader_water;
+ out->samples = NULL;
Mod_GenerateWarpMesh (out);
}
+ else if ((out->extents[0]+1) > (256*16) || (out->extents[1]+1) > (256*16))
+ {
+ Con_Printf ("Bad surface extents, converting to fullbright polygon");
+ out->shader = &Cshader_wall_fullbright;
+ out->samples = NULL;
+ Mod_GenerateVertexMesh(out);
+ }
else if (out->extents[0] < r_vertexsurfacesthreshold.integer && out->extents[1] < r_vertexsurfacesthreshold.integer)
{
out->shader = &Cshader_wall_vertex;