r_shadow_rendermode_t r_shadow_lightingrendermode = R_SHADOW_RENDERMODE_NONE;
r_shadow_rendermode_t r_shadow_shadowingrendermode = R_SHADOW_RENDERMODE_NONE;
-mempool_t *r_shadow_mempool;
-
-int maxshadowelements;
+int maxshadowtriangles;
int *shadowelements;
+int maxshadowvertices;
+float *shadowvertex3f;
+
int maxshadowmark;
int numshadowmark;
int *shadowmark;
r_shadow_filters_texturepool = NULL;
R_Shadow_ValidateCvars();
R_Shadow_MakeTextures();
- maxshadowelements = 0;
+ maxshadowtriangles = 0;
shadowelements = NULL;
+ maxshadowvertices = 0;
+ shadowvertex3f = NULL;
maxvertexupdate = 0;
vertexupdate = NULL;
vertexremap = NULL;
r_shadow_attenuation3dtexture = NULL;
R_FreeTexturePool(&r_shadow_texturepool);
R_FreeTexturePool(&r_shadow_filters_texturepool);
- maxshadowelements = 0;
+ maxshadowtriangles = 0;
if (shadowelements)
Mem_Free(shadowelements);
shadowelements = NULL;
+ if (shadowvertex3f)
+ Mem_Free(shadowvertex3f);
+ shadowvertex3f = NULL;
maxvertexupdate = 0;
if (vertexupdate)
Mem_Free(vertexupdate);
}
Cmd_AddCommand("r_shadow_help", R_Shadow_Help_f, "prints documentation on console commands and variables used by realtime lighting and shadowing system");
R_Shadow_EditLights_Init();
- r_shadow_mempool = Mem_AllocPool("R_Shadow", 0, NULL);
r_shadow_worldlightchain = NULL;
- maxshadowelements = 0;
+ maxshadowtriangles = 0;
shadowelements = NULL;
+ maxshadowvertices = 0;
+ shadowvertex3f = NULL;
maxvertexupdate = 0;
vertexupdate = NULL;
vertexremap = NULL;
}
};
-int *R_Shadow_ResizeShadowElements(int numtris)
+void R_Shadow_ResizeShadowArrays(int numvertices, int numtriangles)
{
// make sure shadowelements is big enough for this volume
- if (maxshadowelements < numtris * 24)
+ if (maxshadowtriangles < numtriangles)
{
- maxshadowelements = numtris * 24;
+ maxshadowtriangles = numtriangles;
if (shadowelements)
Mem_Free(shadowelements);
- shadowelements = (int *)Mem_Alloc(r_shadow_mempool, maxshadowelements * sizeof(int));
+ shadowelements = (int *)Mem_Alloc(r_main_mempool, maxshadowtriangles * sizeof(int[24]));
+ }
+ // make sure shadowvertex3f is big enough for this volume
+ if (maxshadowvertices < numvertices)
+ {
+ maxshadowvertices = numvertices;
+ if (shadowvertex3f)
+ Mem_Free(shadowvertex3f);
+ shadowvertex3f = (float *)Mem_Alloc(r_main_mempool, maxshadowvertices * sizeof(float[6]));
}
- return shadowelements;
}
static void R_Shadow_EnlargeLeafSurfaceBuffer(int numleafs, int numsurfaces)
if (r_shadow_buffer_leaflist)
Mem_Free(r_shadow_buffer_leaflist);
r_shadow_buffer_numleafpvsbytes = numleafpvsbytes;
- r_shadow_buffer_leafpvs = (unsigned char *)Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numleafpvsbytes);
- r_shadow_buffer_leaflist = (int *)Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numleafpvsbytes * 8 * sizeof(*r_shadow_buffer_leaflist));
+ r_shadow_buffer_leafpvs = (unsigned char *)Mem_Alloc(r_main_mempool, r_shadow_buffer_numleafpvsbytes);
+ r_shadow_buffer_leaflist = (int *)Mem_Alloc(r_main_mempool, r_shadow_buffer_numleafpvsbytes * 8 * sizeof(*r_shadow_buffer_leaflist));
}
if (r_shadow_buffer_numsurfacepvsbytes < numsurfacepvsbytes)
{
if (r_shadow_buffer_surfacelist)
Mem_Free(r_shadow_buffer_surfacelist);
r_shadow_buffer_numsurfacepvsbytes = numsurfacepvsbytes;
- r_shadow_buffer_surfacepvs = (unsigned char *)Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numsurfacepvsbytes);
- r_shadow_buffer_surfacelist = (int *)Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numsurfacepvsbytes * 8 * sizeof(*r_shadow_buffer_surfacelist));
+ r_shadow_buffer_surfacepvs = (unsigned char *)Mem_Alloc(r_main_mempool, r_shadow_buffer_numsurfacepvsbytes);
+ r_shadow_buffer_surfacelist = (int *)Mem_Alloc(r_main_mempool, r_shadow_buffer_numsurfacepvsbytes * 8 * sizeof(*r_shadow_buffer_surfacelist));
}
}
Mem_Free(shadowmark);
if (shadowmarklist)
Mem_Free(shadowmarklist);
- shadowmark = (int *)Mem_Alloc(r_shadow_mempool, maxshadowmark * sizeof(*shadowmark));
- shadowmarklist = (int *)Mem_Alloc(r_shadow_mempool, maxshadowmark * sizeof(*shadowmarklist));
+ shadowmark = (int *)Mem_Alloc(r_main_mempool, maxshadowmark * sizeof(*shadowmark));
+ shadowmarklist = (int *)Mem_Alloc(r_main_mempool, maxshadowmark * sizeof(*shadowmarklist));
shadowmarkcount = 0;
}
shadowmarkcount++;
Mem_Free(vertexupdate);
if (vertexremap)
Mem_Free(vertexremap);
- vertexupdate = (int *)Mem_Alloc(r_shadow_mempool, maxvertexupdate * sizeof(int));
- vertexremap = (int *)Mem_Alloc(r_shadow_mempool, maxvertexupdate * sizeof(int));
+ vertexupdate = (int *)Mem_Alloc(r_main_mempool, maxvertexupdate * sizeof(int));
+ vertexremap = (int *)Mem_Alloc(r_main_mempool, maxvertexupdate * sizeof(int));
vertexupdatenum = 0;
}
vertexupdatenum++;
if (!numverts || !nummarktris)
return;
// make sure shadowelements is big enough for this volume
- if (maxshadowelements < nummarktris * 24)
- R_Shadow_ResizeShadowElements((nummarktris + 256) * 24);
- tris = R_Shadow_ConstructShadowVolume(numverts, numtris, elements, neighbors, invertex3f, &outverts, shadowelements, varray_vertex3f2, projectorigin, projectdistance, nummarktris, marktris);
+ if (maxshadowtriangles < nummarktris || maxshadowvertices < numverts)
+ R_Shadow_ResizeShadowArrays((numverts + 255) & ~255, (nummarktris + 255) & ~255);
+ tris = R_Shadow_ConstructShadowVolume(numverts, numtris, elements, neighbors, invertex3f, &outverts, shadowelements, shadowvertex3f, projectorigin, projectdistance, nummarktris, marktris);
renderstats.lights_dynamicshadowtriangles += tris;
- R_Shadow_RenderVolume(outverts, tris, varray_vertex3f2, shadowelements);
+ R_Shadow_RenderVolume(outverts, tris, shadowvertex3f, shadowelements);
}
void R_Shadow_MarkVolumeFromBox(int firsttriangle, int numtris, const float *invertex3f, const int *elements, const vec3_t projectorigin, const vec3_t lightmins, const vec3_t lightmaxs, const vec3_t surfacemins, const vec3_t surfacemaxs)
if (r_shadow_compilingrtlight)
{
// if we're compiling an rtlight, capture the mesh
- Mod_ShadowMesh_AddMesh(r_shadow_mempool, r_shadow_compilingrtlight->static_meshchain_shadow, NULL, NULL, NULL, vertex3f, NULL, NULL, NULL, NULL, numtriangles, element3i);
+ Mod_ShadowMesh_AddMesh(r_main_mempool, r_shadow_compilingrtlight->static_meshchain_shadow, NULL, NULL, NULL, vertex3f, NULL, NULL, NULL, NULL, numtriangles, element3i);
return;
}
renderstats.lights_shadowtriangles += numtriangles;
GL_BlendFunc(GL_ONE, GL_ZERO);
GL_DepthMask(false);
GL_DepthTest(true);
- if (!r_showtrispass)
- qglPolygonOffset(r_shadow_shadow_polygonfactor.value, r_shadow_shadow_polygonoffset.value);
- //if (r_shadow_shadow_polygonoffset.value != 0)
- //{
- // qglPolygonOffset(r_shadow_shadow_polygonfactor.value, r_shadow_shadow_polygonoffset.value);
- // qglEnable(GL_POLYGON_OFFSET_FILL);
- //}
- //else
- // qglDisable(GL_POLYGON_OFFSET_FILL);
+ qglPolygonOffset(r_shadowpolygonfactor, r_shadowpolygonoffset);
qglDepthFunc(GL_LESS);
qglCullFace(GL_FRONT); // quake is backwards, this culls back faces
qglEnable(GL_STENCIL_TEST);
void R_Shadow_RenderMode_Lighting(qboolean stenciltest, qboolean transparent)
{
R_Shadow_RenderMode_Reset();
- GL_BlendFunc(GL_ONE, GL_ONE);
+ GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
GL_DepthMask(false);
GL_DepthTest(true);
- if (!r_showtrispass)
- qglPolygonOffset(0, 0);
+ qglPolygonOffset(r_polygonfactor, r_polygonoffset);
//qglDisable(GL_POLYGON_OFFSET_FILL);
GL_Color(1, 1, 1, 1);
GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1);
// do global setup needed for the chosen lighting mode
if (r_shadow_rendermode == R_SHADOW_RENDERMODE_LIGHT_GLSL)
{
- R_Mesh_VertexPointer(varray_vertex3f);
- R_Mesh_TexCoordPointer(0, 2, varray_texcoord2f[0]);
- R_Mesh_TexCoordPointer(1, 3, varray_svector3f);
- R_Mesh_TexCoordPointer(2, 3, varray_tvector3f);
- R_Mesh_TexCoordPointer(3, 3, varray_normal3f);
R_Mesh_TexBind(0, R_GetTexture(r_texture_blanknormalmap)); // normal
R_Mesh_TexBind(1, R_GetTexture(r_texture_white)); // diffuse
R_Mesh_TexBind(2, R_GetTexture(r_texture_white)); // gloss
R_Mesh_TexBind(5, R_GetTexture(r_texture_white)); // pants
R_Mesh_TexBind(6, R_GetTexture(r_texture_white)); // shirt
//R_Mesh_TexMatrix(3, r_shadow_entitytolight); // light filter matrix
- GL_BlendFunc(GL_ONE, GL_ONE);
+ GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 0);
CHECKGLERROR
}
GL_BlendFunc(GL_ONE, GL_ONE);
GL_DepthMask(false);
GL_DepthTest(!r_showdisabledepthtest.integer);
- if (!r_showtrispass)
- qglPolygonOffset(0, 0);
+ qglPolygonOffset(r_polygonfactor, r_polygonoffset);
GL_Color(0.0, 0.0125, 0.1, 1);
GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1);
qglDepthFunc(GL_GEQUAL);
GL_BlendFunc(GL_ONE, GL_ONE);
GL_DepthMask(false);
GL_DepthTest(!r_showdisabledepthtest.integer);
- if (!r_showtrispass)
- qglPolygonOffset(0, 0);
+ qglPolygonOffset(r_polygonfactor, r_polygonoffset);
GL_Color(0.1, 0.0125, 0, 1);
GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1);
if (transparent)
GL_BlendFunc(GL_ONE, GL_ZERO);
GL_DepthMask(true);
GL_DepthTest(true);
- if (!r_showtrispass)
- qglPolygonOffset(0, 0);
+ qglPolygonOffset(r_polygonfactor, r_polygonoffset);
//qglDisable(GL_POLYGON_OFFSET_FILL);
GL_Color(1, 1, 1, 1);
GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1);
return false;
}
-extern float *rsurface_vertex3f;
-extern float *rsurface_svector3f;
-extern float *rsurface_tvector3f;
-extern float *rsurface_normal3f;
-extern void RSurf_SetVertexPointer(const entity_render_t *ent, const texture_t *texture, const msurface_t *surface, const vec3_t modelorg, qboolean generatenormals, qboolean generatetangents);
-
static void R_Shadow_RenderSurfacesLighting_Light_Vertex_Shading(const msurface_t *surface, const float *diffusecolor, const float *ambientcolor)
{
int numverts = surface->num_vertices;
float *vertex3f = rsurface_vertex3f + 3 * surface->num_firstvertex;
float *normal3f = rsurface_normal3f + 3 * surface->num_firstvertex;
- float *color4f = varray_color4f + 4 * surface->num_firstvertex;
+ float *color4f = rsurface_array_color4f + 4 * surface->num_firstvertex;
float dist, dot, distintensity, shadeintensity, v[3], n[3];
if (r_textureunits.integer >= 3)
{
}
// TODO: use glTexGen instead of feeding vertices to texcoordpointer?
-#define USETEXMATRIX
-
-#ifndef USETEXMATRIX
-// this should be done in a texture matrix or vertex program when possible, but here's code to do it manually
-// if hardware texcoord manipulation is not available (or not suitable, this would really benefit from 3DNow! or SSE
-static void R_Shadow_Transform_Vertex3f_TexCoord3f(float *tc3f, int numverts, const float *vertex3f, const matrix4x4_t *matrix)
-{
- do
- {
- tc3f[0] = vertex3f[0] * matrix->m[0][0] + vertex3f[1] * matrix->m[0][1] + vertex3f[2] * matrix->m[0][2] + matrix->m[0][3];
- tc3f[1] = vertex3f[0] * matrix->m[1][0] + vertex3f[1] * matrix->m[1][1] + vertex3f[2] * matrix->m[1][2] + matrix->m[1][3];
- tc3f[2] = vertex3f[0] * matrix->m[2][0] + vertex3f[1] * matrix->m[2][1] + vertex3f[2] * matrix->m[2][2] + matrix->m[2][3];
- vertex3f += 3;
- tc3f += 3;
- }
- while (--numverts);
-}
-
-static void R_Shadow_Transform_Vertex3f_TexCoord2f(float *tc2f, int numverts, const float *vertex3f, const matrix4x4_t *matrix)
-{
- do
- {
- tc2f[0] = vertex3f[0] * matrix->m[0][0] + vertex3f[1] * matrix->m[0][1] + vertex3f[2] * matrix->m[0][2] + matrix->m[0][3];
- tc2f[1] = vertex3f[0] * matrix->m[1][0] + vertex3f[1] * matrix->m[1][1] + vertex3f[2] * matrix->m[1][2] + matrix->m[1][3];
- vertex3f += 3;
- tc2f += 2;
- }
- while (--numverts);
-}
-#endif
static void R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(float *out3f, int numverts, const float *vertex3f, const float *svector3f, const float *tvector3f, const float *normal3f, const vec3_t relativelightorigin)
{
{
// used to display how many times a surface is lit for level design purposes
int surfacelistindex;
+ model_t *model = ent->model;
rmeshstate_t m;
GL_Color(0.1, 0.025, 0, 1);
memset(&m, 0, sizeof(m));
R_Mesh_State(&m);
+ RSurf_SetPointersForPass(false, false);
for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
{
const msurface_t *surface = surfacelist[surfacelistindex];
- RSurf_SetVertexPointer(ent, texture, surface, r_shadow_entityeyeorigin, false, false);
+ if (rsurface_dynamicvertex)
+ RSurf_PrepareDynamicSurfaceVertices(surface);
GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
- R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle);
+ R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, model->surfmesh.data_element3i + 3 * surface->num_firsttriangle);
GL_LockArrays(0, 0);
}
}
{
// ARB2 GLSL shader path (GFFX5200, Radeon 9500)
int surfacelistindex;
- R_SetupSurfaceShader(ent, texture, lightcolorbase, lightcolorpants, lightcolorshirt, basetexture, pantstexture, shirttexture, normalmaptexture, glosstexture, specularscale, dopants, doshirt);
+ model_t *model = ent->model;
+ R_SetupSurfaceShader(ent, texture, r_shadow_entityeyeorigin, lightcolorbase, false);
+ RSurf_SetPointersForPass(false, true);
for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
{
const msurface_t *surface = surfacelist[surfacelistindex];
- const int *elements = surface->groupmesh->data_element3i + surface->num_firsttriangle * 3;
- RSurf_SetVertexPointer(ent, texture, surface, r_shadow_entityeyeorigin, false, true);
- R_Mesh_TexCoordPointer(0, 2, surface->groupmesh->data_texcoordtexture2f);
+ const int *elements = model->surfmesh.data_element3i + surface->num_firsttriangle * 3;
+ if (rsurface_dynamicvertex)
+ RSurf_PrepareDynamicSurfaceVertices(surface);
+ R_Mesh_TexCoordPointer(0, 2, model->surfmesh.data_texcoordtexture2f);
R_Mesh_TexCoordPointer(1, 3, rsurface_svector3f);
R_Mesh_TexCoordPointer(2, 3, rsurface_tvector3f);
R_Mesh_TexCoordPointer(3, 3, rsurface_normal3f);
static void R_Shadow_RenderSurfacesLighting_Light_Dot3_AmbientPass(const entity_render_t *ent, const texture_t *texture, const msurface_t *surface, const vec3_t lightcolorbase, rtexture_t *basetexture, float colorscale)
{
int renders;
+ model_t *model = ent->model;
float color2[3];
rmeshstate_t m;
- const int *elements = surface->groupmesh->data_element3i + surface->num_firsttriangle * 3;
+ const int *elements = model->surfmesh.data_element3i + surface->num_firsttriangle * 3;
GL_Color(1,1,1,1);
// colorscale accounts for how much we multiply the brightness
// during combine.
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex3d[0] = R_GetTexture(r_shadow_attenuation3dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[0] = rsurface_vertex3f;
m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord3f[0] = varray_texcoord3f[0];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[0] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
m.tex[1] = R_GetTexture(basetexture);
- m.pointer_texcoord[1] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[1] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[1] = texture->currenttexmatrix;
m.texcubemap[2] = R_GetTexture(r_shadow_rtlight->currentcubemap);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[2] = rsurface_vertex3f;
m.texmatrix[2] = r_shadow_entitytolight;
-#else
- m.pointer_texcoord3f[2] = varray_texcoord3f[2];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[2] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytolight);
-#endif
GL_BlendFunc(GL_ONE, GL_ONE);
}
else if (r_shadow_texture3d.integer && r_shadow_rtlight->currentcubemap == r_texture_whitecube && r_textureunits.integer >= 2)
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex3d[0] = R_GetTexture(r_shadow_attenuation3dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[0] = rsurface_vertex3f;
m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord3f[0] = varray_texcoord3f[0];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[0] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
m.tex[1] = R_GetTexture(basetexture);
- m.pointer_texcoord[1] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[1] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[1] = texture->currenttexmatrix;
GL_BlendFunc(GL_ONE, GL_ONE);
}
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(r_shadow_attenuation2dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[0] = rsurface_vertex3f;
m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord[0] = varray_texcoord2f[0];
- R_Shadow_Transform_Vertex3f_Texcoord2f(varray_texcoord2f[0] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
m.tex[1] = R_GetTexture(r_shadow_attenuation2dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[1] = rsurface_vertex3f;
m.texmatrix[1] = r_shadow_entitytoattenuationz;
-#else
- m.pointer_texcoord[1] = varray_texcoord2f[1];
- R_Shadow_Transform_Vertex3f_Texcoord2f(varray_texcoord2f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationz);
-#endif
m.tex[2] = R_GetTexture(basetexture);
- m.pointer_texcoord[2] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[2] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[2] = texture->currenttexmatrix;
if (r_shadow_rtlight->currentcubemap != r_texture_whitecube)
{
m.texcubemap[3] = R_GetTexture(r_shadow_rtlight->currentcubemap);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[3] = rsurface_vertex3f;
m.texmatrix[3] = r_shadow_entitytolight;
-#else
- m.pointer_texcoord3f[3] = varray_texcoord3f[3];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[3] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytolight);
-#endif
}
GL_BlendFunc(GL_ONE, GL_ONE);
}
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(r_shadow_attenuation2dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[0] = rsurface_vertex3f;
m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord[0] = varray_texcoord2f[0];
- R_Shadow_Transform_Vertex3f_Texcoord2f(varray_texcoord2f[0] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
m.tex[1] = R_GetTexture(r_shadow_attenuation2dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[1] = rsurface_vertex3f;
m.texmatrix[1] = r_shadow_entitytoattenuationz;
-#else
- m.pointer_texcoord[1] = varray_texcoord2f[1];
- R_Shadow_Transform_Vertex3f_Texcoord2f(varray_texcoord2f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationz);
-#endif
m.tex[2] = R_GetTexture(basetexture);
- m.pointer_texcoord[2] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[2] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[2] = texture->currenttexmatrix;
GL_BlendFunc(GL_ONE, GL_ONE);
}
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(r_shadow_attenuation2dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[0] = rsurface_vertex3f;
m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord[0] = varray_texcoord2f[0];
- R_Shadow_Transform_Vertex3f_Texcoord2f(varray_texcoord2f[0] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
m.tex[1] = R_GetTexture(r_shadow_attenuation2dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[1] = rsurface_vertex3f;
m.texmatrix[1] = r_shadow_entitytoattenuationz;
-#else
- m.pointer_texcoord[1] = varray_texcoord2f[1];
- R_Shadow_Transform_Vertex3f_Texcoord2f(varray_texcoord2f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationz);
-#endif
R_Mesh_State(&m);
GL_ColorMask(0,0,0,1);
GL_BlendFunc(GL_ONE, GL_ZERO);
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(basetexture);
- m.pointer_texcoord[0] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[0] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[0] = texture->currenttexmatrix;
if (r_shadow_rtlight->currentcubemap != r_texture_whitecube)
{
m.texcubemap[1] = R_GetTexture(r_shadow_rtlight->currentcubemap);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[1] = rsurface_vertex3f;
m.texmatrix[1] = r_shadow_entitytolight;
-#else
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytolight);
-#endif
}
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
}
static void R_Shadow_RenderSurfacesLighting_Light_Dot3_DiffusePass(const entity_render_t *ent, const texture_t *texture, const msurface_t *surface, const vec3_t lightcolorbase, rtexture_t *basetexture, rtexture_t *normalmaptexture, float colorscale)
{
int renders;
+ model_t *model = ent->model;
float color2[3];
rmeshstate_t m;
- const int *elements = surface->groupmesh->data_element3i + surface->num_firsttriangle * 3;
+ const int *elements = model->surfmesh.data_element3i + surface->num_firsttriangle * 3;
GL_Color(1,1,1,1);
// colorscale accounts for how much we multiply the brightness
// during combine.
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(normalmaptexture);
m.texcombinergb[0] = GL_REPLACE;
- m.pointer_texcoord[0] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[0] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[0] = texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
+ m.pointer_texcoord3f[1] = rsurface_array_texcoord3f;
+ R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
m.tex3d[2] = R_GetTexture(r_shadow_attenuation3dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[2] = rsurface_vertex3f;
m.texmatrix[2] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord3f[2] = varray_texcoord3f[2];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[2] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
R_Mesh_State(&m);
GL_ColorMask(0,0,0,1);
GL_BlendFunc(GL_ONE, GL_ZERO);
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(basetexture);
- m.pointer_texcoord[0] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[0] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[0] = texture->currenttexmatrix;
if (r_shadow_rtlight->currentcubemap != r_texture_whitecube)
{
m.texcubemap[1] = R_GetTexture(r_shadow_rtlight->currentcubemap);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[1] = rsurface_vertex3f;
m.texmatrix[1] = r_shadow_entitytolight;
-#else
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytolight);
-#endif
}
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
}
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex3d[0] = R_GetTexture(r_shadow_attenuation3dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[0] = rsurface_vertex3f;
m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord3f[0] = varray_texcoord3f[0];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[0] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
R_Mesh_State(&m);
GL_ColorMask(0,0,0,1);
GL_BlendFunc(GL_ONE, GL_ZERO);
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(normalmaptexture);
m.texcombinergb[0] = GL_REPLACE;
- m.pointer_texcoord[0] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[0] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[0] = texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
+ m.pointer_texcoord3f[1] = rsurface_array_texcoord3f;
+ R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
R_Mesh_State(&m);
GL_BlendFunc(GL_DST_ALPHA, GL_ZERO);
GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(basetexture);
- m.pointer_texcoord[0] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[0] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[0] = texture->currenttexmatrix;
if (r_shadow_rtlight->currentcubemap != r_texture_whitecube)
{
m.texcubemap[1] = R_GetTexture(r_shadow_rtlight->currentcubemap);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[1] = rsurface_vertex3f;
m.texmatrix[1] = r_shadow_entitytolight;
-#else
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytolight);
-#endif
}
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
}
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(normalmaptexture);
m.texcombinergb[0] = GL_REPLACE;
- m.pointer_texcoord[0] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[0] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[0] = texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
+ m.pointer_texcoord3f[1] = rsurface_array_texcoord3f;
+ R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
R_Mesh_State(&m);
GL_ColorMask(0,0,0,1);
GL_BlendFunc(GL_ONE, GL_ZERO);
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(basetexture);
- m.pointer_texcoord[0] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[0] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[0] = texture->currenttexmatrix;
m.tex3d[1] = R_GetTexture(r_shadow_attenuation3dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[1] = rsurface_vertex3f;
m.texmatrix[1] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
}
else if (r_textureunits.integer >= 4)
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(normalmaptexture);
m.texcombinergb[0] = GL_REPLACE;
- m.pointer_texcoord[0] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[0] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[0] = texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
+ m.pointer_texcoord3f[1] = rsurface_array_texcoord3f;
+ R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
m.tex[2] = R_GetTexture(r_shadow_attenuation2dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[2] = rsurface_vertex3f;
m.texmatrix[2] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord[2] = varray_texcoord2f[2];
- R_Shadow_Transform_Vertex3f_Texcoord2f(varray_texcoord2f[2] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
m.tex[3] = R_GetTexture(r_shadow_attenuation2dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[3] = rsurface_vertex3f;
m.texmatrix[3] = r_shadow_entitytoattenuationz;
-#else
- m.pointer_texcoord[3] = varray_texcoord2f[3];
- R_Shadow_Transform_Vertex3f_Texcoord2f(varray_texcoord2f[3] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationz);
-#endif
R_Mesh_State(&m);
GL_ColorMask(0,0,0,1);
GL_BlendFunc(GL_ONE, GL_ZERO);
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(basetexture);
- m.pointer_texcoord[0] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[0] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[0] = texture->currenttexmatrix;
if (r_shadow_rtlight->currentcubemap != r_texture_whitecube)
{
m.texcubemap[1] = R_GetTexture(r_shadow_rtlight->currentcubemap);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[1] = rsurface_vertex3f;
m.texmatrix[1] = r_shadow_entitytolight;
-#else
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytolight);
-#endif
}
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
}
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(r_shadow_attenuation2dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[0] = rsurface_vertex3f;
m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord[0] = varray_texcoord2f[0];
- R_Shadow_Transform_Vertex3f_Texcoord2f(varray_texcoord2f[0] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
m.tex[1] = R_GetTexture(r_shadow_attenuation2dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[1] = rsurface_vertex3f;
m.texmatrix[1] = r_shadow_entitytoattenuationz;
-#else
- m.pointer_texcoord[1] = varray_texcoord2f[1];
- R_Shadow_Transform_Vertex3f_Texcoord2f(varray_texcoord2f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationz);
-#endif
R_Mesh_State(&m);
GL_ColorMask(0,0,0,1);
GL_BlendFunc(GL_ONE, GL_ZERO);
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(normalmaptexture);
m.texcombinergb[0] = GL_REPLACE;
- m.pointer_texcoord[0] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[0] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[0] = texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
+ m.pointer_texcoord3f[1] = rsurface_array_texcoord3f;
+ R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
R_Mesh_State(&m);
GL_BlendFunc(GL_DST_ALPHA, GL_ZERO);
GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(basetexture);
- m.pointer_texcoord[0] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[0] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[0] = texture->currenttexmatrix;
if (r_shadow_rtlight->currentcubemap != r_texture_whitecube)
{
m.texcubemap[1] = R_GetTexture(r_shadow_rtlight->currentcubemap);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[1] = rsurface_vertex3f;
m.texmatrix[1] = r_shadow_entitytolight;
-#else
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytolight);
-#endif
}
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
}
static void R_Shadow_RenderSurfacesLighting_Light_Dot3_SpecularPass(const entity_render_t *ent, const texture_t *texture, const msurface_t *surface, const vec3_t lightcolorbase, rtexture_t *glosstexture, rtexture_t *normalmaptexture, float colorscale)
{
int renders;
+ model_t *model = ent->model;
float color2[3];
rmeshstate_t m;
- const int *elements = surface->groupmesh->data_element3i + surface->num_firsttriangle * 3;
+ const int *elements = model->surfmesh.data_element3i + surface->num_firsttriangle * 3;
// FIXME: detect blendsquare!
//if (!gl_support_blendsquare)
// return;
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(normalmaptexture);
- m.pointer_texcoord[0] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[0] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[0] = texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_GenTexCoords_Specular_NormalCubeMap(varray_texcoord3f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin, r_shadow_entityeyeorigin);
+ m.pointer_texcoord3f[1] = rsurface_array_texcoord3f;
+ R_Shadow_GenTexCoords_Specular_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin, r_shadow_entityeyeorigin);
R_Mesh_State(&m);
GL_ColorMask(0,0,0,1);
// this squares the result
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex3d[0] = R_GetTexture(r_shadow_attenuation3dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[0] = rsurface_vertex3f;
m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord3f[0] = varray_texcoord3f[0];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[0] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
R_Mesh_State(&m);
GL_BlendFunc(GL_DST_ALPHA, GL_ZERO);
GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(glosstexture);
- m.pointer_texcoord[0] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[0] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[0] = texture->currenttexmatrix;
if (r_shadow_rtlight->currentcubemap != r_texture_whitecube)
{
m.texcubemap[1] = R_GetTexture(r_shadow_rtlight->currentcubemap);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[1] = rsurface_vertex3f;
m.texmatrix[1] = r_shadow_entitytolight;
-#else
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytolight);
-#endif
}
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
}
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(normalmaptexture);
- m.pointer_texcoord[0] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[0] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[0] = texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_GenTexCoords_Specular_NormalCubeMap(varray_texcoord3f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin, r_shadow_entityeyeorigin);
+ m.pointer_texcoord3f[1] = rsurface_array_texcoord3f;
+ R_Shadow_GenTexCoords_Specular_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin, r_shadow_entityeyeorigin);
R_Mesh_State(&m);
GL_ColorMask(0,0,0,1);
// this squares the result
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(glosstexture);
- m.pointer_texcoord[0] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[0] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[0] = texture->currenttexmatrix;
m.tex3d[1] = R_GetTexture(r_shadow_attenuation3dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[1] = rsurface_vertex3f;
m.texmatrix[1] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
}
else
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(normalmaptexture);
- m.pointer_texcoord[0] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[0] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[0] = texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_GenTexCoords_Specular_NormalCubeMap(varray_texcoord3f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin, r_shadow_entityeyeorigin);
+ m.pointer_texcoord3f[1] = rsurface_array_texcoord3f;
+ R_Shadow_GenTexCoords_Specular_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin, r_shadow_entityeyeorigin);
R_Mesh_State(&m);
GL_ColorMask(0,0,0,1);
// this squares the result
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(r_shadow_attenuation2dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[0] = rsurface_vertex3f;
m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord[0] = varray_texcoord2f[0];
- R_Shadow_Transform_Vertex3f_Texcoord2f(varray_texcoord2f[0] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
m.tex[1] = R_GetTexture(r_shadow_attenuation2dtexture);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[1] = rsurface_vertex3f;
m.texmatrix[1] = r_shadow_entitytoattenuationz;
-#else
- m.pointer_texcoord[1] = varray_texcoord2f[1];
- R_Shadow_Transform_Vertex3f_Texcoord2f(varray_texcoord2f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationz);
-#endif
R_Mesh_State(&m);
GL_BlendFunc(GL_DST_ALPHA, GL_ZERO);
GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
memset(&m, 0, sizeof(m));
m.pointer_vertex = rsurface_vertex3f;
m.tex[0] = R_GetTexture(glosstexture);
- m.pointer_texcoord[0] = surface->groupmesh->data_texcoordtexture2f;
+ m.pointer_texcoord[0] = model->surfmesh.data_texcoordtexture2f;
m.texmatrix[0] = texture->currenttexmatrix;
if (r_shadow_rtlight->currentcubemap != r_texture_whitecube)
{
m.texcubemap[1] = R_GetTexture(r_shadow_rtlight->currentcubemap);
-#ifdef USETEXMATRIX
m.pointer_texcoord3f[1] = rsurface_vertex3f;
m.texmatrix[1] = r_shadow_entitytolight;
-#else
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytolight);
-#endif
}
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
}
qboolean dospecular = specularscale > 0;
if (!doambient && !dodiffuse && !dospecular)
return;
+ RSurf_SetPointersForPass(false, true);
for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
{
const msurface_t *surface = surfacelist[surfacelistindex];
- RSurf_SetVertexPointer(ent, texture, surface, r_shadow_entityeyeorigin, false, true);
+ if (rsurface_dynamicvertex)
+ RSurf_PrepareDynamicSurfaceVertices(surface);
if (doambient)
R_Shadow_RenderSurfacesLighting_Light_Dot3_AmbientPass(ent, texture, surface, lightcolorbase, basetexture, r_shadow_rtlight->ambientscale);
if (dodiffuse)
}
}
-void R_Shadow_RenderSurfacesLighting_Light_Vertex_Pass(const msurface_t *surface, vec3_t diffusecolor2, vec3_t ambientcolor2)
+void R_Shadow_RenderSurfacesLighting_Light_Vertex_Pass(const model_t *model, const msurface_t *surface, vec3_t diffusecolor2, vec3_t ambientcolor2)
{
int renders;
- const int *elements = surface->groupmesh->data_element3i + surface->num_firsttriangle * 3;
+ const int *elements = model->surfmesh.data_element3i + surface->num_firsttriangle * 3;
R_Shadow_RenderSurfacesLighting_Light_Vertex_Shading(surface, diffusecolor2, ambientcolor2);
for (renders = 0;renders < 64 && (ambientcolor2[0] > renders || ambientcolor2[1] > renders || ambientcolor2[2] > renders || diffusecolor2[0] > renders || diffusecolor2[1] > renders || diffusecolor2[2] > renders);renders++)
{
newnumtriangles = 0;
newe = newelements;
}
- if (VectorLength2(varray_color4f + e[0] * 4) + VectorLength2(varray_color4f + e[1] * 4) + VectorLength2(varray_color4f + e[2] * 4) >= 0.01)
+ if (VectorLength2(rsurface_array_color4f + e[0] * 4) + VectorLength2(rsurface_array_color4f + e[1] * 4) + VectorLength2(rsurface_array_color4f + e[2] * 4) >= 0.01)
{
newe[0] = e[0];
newe[1] = e[1];
if (!draw)
break;
#else
- for (i = 0, c = varray_color4f + 4 * surface->num_firstvertex;i < surface->num_vertices;i++, c += 4)
+ for (i = 0, c = rsurface_array_color4f + 4 * surface->num_firstvertex;i < surface->num_vertices;i++, c += 4)
if (VectorLength2(c))
goto goodpass;
break;
GL_LockArrays(0, 0);
#endif
// now reduce the intensity for the next overbright pass
- for (i = 0, c = varray_color4f + 4 * surface->num_firstvertex;i < surface->num_vertices;i++, c += 4)
+ for (i = 0, c = rsurface_array_color4f + 4 * surface->num_firstvertex;i < surface->num_vertices;i++, c += 4)
{
c[0] = max(0, c[0] - 1);
c[1] = max(0, c[1] - 1);
static void R_Shadow_RenderSurfacesLighting_Light_Vertex(const entity_render_t *ent, const texture_t *texture, int numsurfaces, msurface_t **surfacelist, const vec3_t lightcolorbase, const vec3_t lightcolorpants, const vec3_t lightcolorshirt, rtexture_t *basetexture, rtexture_t *pantstexture, rtexture_t *shirttexture, rtexture_t *normalmaptexture, rtexture_t *glosstexture, float specularscale, qboolean dopants, qboolean doshirt)
{
int surfacelistindex;
+ model_t *model = ent->model;
float ambientcolorbase[3], diffusecolorbase[3];
float ambientcolorpants[3], diffusecolorpants[3];
float ambientcolorshirt[3], diffusecolorshirt[3];
{
// voodoo2
m.tex[1] = R_GetTexture(r_shadow_attenuation2dtexture);
-#ifdef USETEXMATRIX
m.texmatrix[1] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord[1] = varray_texcoord2f[1];
- R_Shadow_Transform_Vertex3f_Texcoord2f(varray_texcoord2f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
if (r_textureunits.integer >= 3)
{
// Geforce3/Radeon class but not using dot3
m.tex[2] = R_GetTexture(r_shadow_attenuation2dtexture);
-#ifdef USETEXMATRIX
m.texmatrix[2] = r_shadow_entitytoattenuationz;
-#else
- m.pointer_texcoord[2] = varray_texcoord2f[2];
- R_Shadow_Transform_Vertex3f_Texcoord2f(varray_texcoord2f[2] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationz);
-#endif
}
}
- m.pointer_color = varray_color4f;
+ m.pointer_color = rsurface_array_color4f;
R_Mesh_State(&m);
+ RSurf_SetPointersForPass(true, false);
for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
{
const msurface_t *surface = surfacelist[surfacelistindex];
- RSurf_SetVertexPointer(ent, texture, surface, r_shadow_entityeyeorigin, true, false);
+ if (rsurface_dynamicvertex)
+ RSurf_PrepareDynamicSurfaceVertices(surface);
// OpenGL 1.1 path (anything)
- R_Mesh_TexCoordPointer(0, 2, surface->groupmesh->data_texcoordtexture2f);
+ R_Mesh_TexCoordPointer(0, 2, model->surfmesh.data_texcoordtexture2f);
R_Mesh_TexMatrix(0, &texture->currenttexmatrix);
if (r_textureunits.integer >= 2)
{
// voodoo2 or TNT
-#ifdef USETEXMATRIX
R_Mesh_TexCoordPointer(1, 3, rsurface_vertex3f);
-#else
- R_Shadow_Transform_Vertex3f_Texcoord2f(varray_texcoord2f[1] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
if (r_textureunits.integer >= 3)
{
// Voodoo4 or Kyro (or Geforce3/Radeon with gl_combine off)
-#ifdef USETEXMATRIX
R_Mesh_TexCoordPointer(2, 3, rsurface_vertex3f);
-#else
- R_Shadow_Transform_Vertex3f_Texcoord2f(varray_texcoord2f[2] + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, &r_shadow_entitytoattenuationz);
-#endif
}
}
R_Mesh_TexBind(0, R_GetTexture(basetexture));
- R_Shadow_RenderSurfacesLighting_Light_Vertex_Pass(surface, diffusecolorbase, ambientcolorbase);
+ R_Shadow_RenderSurfacesLighting_Light_Vertex_Pass(model, surface, diffusecolorbase, ambientcolorbase);
if (dopants)
{
R_Mesh_TexBind(0, R_GetTexture(pantstexture));
- R_Shadow_RenderSurfacesLighting_Light_Vertex_Pass(surface, diffusecolorpants, ambientcolorpants);
+ R_Shadow_RenderSurfacesLighting_Light_Vertex_Pass(model, surface, diffusecolorpants, ambientcolorpants);
}
if (doshirt)
{
R_Mesh_TexBind(0, R_GetTexture(shirttexture));
- R_Shadow_RenderSurfacesLighting_Light_Vertex_Pass(surface, diffusecolorshirt, ambientcolorshirt);
+ R_Shadow_RenderSurfacesLighting_Light_Vertex_Pass(model, surface, diffusecolorshirt, ambientcolorshirt);
}
}
}
{
// FIXME: support MATERIALFLAG_NODEPTHTEST
vec3_t lightcolorbase, lightcolorpants, lightcolorshirt;
- rtexture_t *basetexture;
- rtexture_t *pantstexture;
- rtexture_t *shirttexture;
- rtexture_t *glosstexture;
- float specularscale;
- qboolean dopants, doshirt;
- glosstexture = r_texture_black;
- specularscale = 0;
- if (r_shadow_gloss.integer > 0)
- {
- if (texture->skin.gloss)
- {
- if (r_shadow_glossintensity.value > 0 && r_shadow_rtlight->specularscale > 0)
- {
- glosstexture = texture->skin.gloss;
- specularscale = r_shadow_rtlight->specularscale * r_shadow_glossintensity.value;
- }
- }
- else
- {
- if (r_shadow_gloss.integer >= 2 && r_shadow_gloss2intensity.value > 0 && r_shadow_glossintensity.value > 0 && r_shadow_rtlight->specularscale > 0)
- {
- glosstexture = r_texture_white;
- specularscale = r_shadow_rtlight->specularscale * r_shadow_gloss2intensity.value;
- }
- }
- }
// calculate colors to render this texture with
lightcolorbase[0] = r_shadow_rtlight->currentcolor[0] * ent->colormod[0] * texture->currentalpha;
lightcolorbase[1] = r_shadow_rtlight->currentcolor[1] * ent->colormod[1] * texture->currentalpha;
lightcolorbase[2] = r_shadow_rtlight->currentcolor[2] * ent->colormod[2] * texture->currentalpha;
- if ((r_shadow_rtlight->ambientscale + r_shadow_rtlight->diffusescale) * VectorLength2(lightcolorbase) + specularscale * VectorLength2(lightcolorbase) < (1.0f / 1048576.0f))
+ if ((r_shadow_rtlight->ambientscale + r_shadow_rtlight->diffusescale) * VectorLength2(lightcolorbase) + (r_shadow_rtlight->specularscale * texture->specularscale) * VectorLength2(lightcolorbase) < (1.0f / 1048576.0f))
return;
if ((texture->textureflags & Q3TEXTUREFLAG_TWOSIDED) || (ent->flags & RENDER_NOCULLFACE))
qglDisable(GL_CULL_FACE);
else
qglEnable(GL_CULL_FACE);
- dopants = texture->skin.pants != NULL && VectorLength2(ent->colormap_pantscolor) >= (1.0f / 1048576.0f);
- doshirt = texture->skin.shirt != NULL && VectorLength2(ent->colormap_shirtcolor) >= (1.0f / 1048576.0f);
- if (dopants + doshirt)
+ RSurf_PrepareForBatch(ent, texture, r_shadow_entityeyeorigin);
+ if (texture->colormapping)
{
+ qboolean dopants = texture->skin.pants != NULL && VectorLength2(ent->colormap_pantscolor) >= (1.0f / 1048576.0f);
+ qboolean doshirt = texture->skin.shirt != NULL && VectorLength2(ent->colormap_shirtcolor) >= (1.0f / 1048576.0f);
if (dopants)
{
lightcolorpants[0] = lightcolorbase[0] * ent->colormap_pantscolor[0];
lightcolorpants[2] = lightcolorbase[2] * ent->colormap_pantscolor[2];
}
else
- {
- pantstexture = r_texture_black;
VectorClear(lightcolorpants);
- }
if (doshirt)
{
- shirttexture = texture->skin.shirt;
lightcolorshirt[0] = lightcolorbase[0] * ent->colormap_shirtcolor[0];
lightcolorshirt[1] = lightcolorbase[1] * ent->colormap_shirtcolor[1];
lightcolorshirt[2] = lightcolorbase[2] * ent->colormap_shirtcolor[2];
}
else
- {
- shirttexture = r_texture_black;
VectorClear(lightcolorshirt);
- }
switch (r_shadow_rendermode)
{
case R_SHADOW_RENDERMODE_VISIBLELIGHTING:
- R_Shadow_RenderSurfacesLighting_VisibleLighting(ent, texture, numsurfaces, surfacelist, lightcolorbase, lightcolorpants, lightcolorshirt, texture->skin.base, texture->skin.pants, texture->skin.shirt, texture->skin.nmap, glosstexture, specularscale, dopants, doshirt);
+ R_Shadow_RenderSurfacesLighting_VisibleLighting(ent, texture, numsurfaces, surfacelist, lightcolorbase, lightcolorpants, lightcolorshirt, texture->basetexture, texture->skin.pants, texture->skin.shirt, texture->skin.nmap, texture->glosstexture, r_shadow_rtlight->specularscale * texture->specularscale, dopants, doshirt);
break;
case R_SHADOW_RENDERMODE_LIGHT_GLSL:
- R_Shadow_RenderSurfacesLighting_Light_GLSL(ent, texture, numsurfaces, surfacelist, lightcolorbase, lightcolorpants, lightcolorshirt, texture->skin.base, texture->skin.pants, texture->skin.shirt, texture->skin.nmap, glosstexture, specularscale, dopants, doshirt);
+ R_Shadow_RenderSurfacesLighting_Light_GLSL(ent, texture, numsurfaces, surfacelist, lightcolorbase, lightcolorpants, lightcolorshirt, texture->basetexture, texture->skin.pants, texture->skin.shirt, texture->skin.nmap, texture->glosstexture, r_shadow_rtlight->specularscale * texture->specularscale, dopants, doshirt);
break;
case R_SHADOW_RENDERMODE_LIGHT_DOT3:
- R_Shadow_RenderSurfacesLighting_Light_Dot3(ent, texture, numsurfaces, surfacelist, lightcolorbase, lightcolorpants, lightcolorshirt, texture->skin.base, texture->skin.pants, texture->skin.shirt, texture->skin.nmap, glosstexture, specularscale, dopants, doshirt);
+ R_Shadow_RenderSurfacesLighting_Light_Dot3(ent, texture, numsurfaces, surfacelist, lightcolorbase, lightcolorpants, lightcolorshirt, texture->basetexture, texture->skin.pants, texture->skin.shirt, texture->skin.nmap, texture->glosstexture, r_shadow_rtlight->specularscale * texture->specularscale, dopants, doshirt);
break;
case R_SHADOW_RENDERMODE_LIGHT_VERTEX:
- R_Shadow_RenderSurfacesLighting_Light_Vertex(ent, texture, numsurfaces, surfacelist, lightcolorbase, lightcolorpants, lightcolorshirt, texture->skin.base, texture->skin.pants, texture->skin.shirt, texture->skin.nmap, glosstexture, specularscale, dopants, doshirt);
+ R_Shadow_RenderSurfacesLighting_Light_Vertex(ent, texture, numsurfaces, surfacelist, lightcolorbase, lightcolorpants, lightcolorshirt, texture->basetexture, texture->skin.pants, texture->skin.shirt, texture->skin.nmap, texture->glosstexture, r_shadow_rtlight->specularscale * texture->specularscale, dopants, doshirt);
break;
default:
Con_Printf("R_Shadow_RenderSurfacesLighting: unknown r_shadow_rendermode %i\n", r_shadow_rendermode);
}
else
{
- basetexture = texture->skin.merged ? texture->skin.merged : texture->skin.base;
switch (r_shadow_rendermode)
{
case R_SHADOW_RENDERMODE_VISIBLELIGHTING:
- R_Shadow_RenderSurfacesLighting_VisibleLighting(ent, texture, numsurfaces, surfacelist, lightcolorbase, vec3_origin, vec3_origin, basetexture, r_texture_black, r_texture_black, texture->skin.nmap, glosstexture, specularscale, false, false);
+ R_Shadow_RenderSurfacesLighting_VisibleLighting(ent, texture, numsurfaces, surfacelist, lightcolorbase, vec3_origin, vec3_origin, texture->basetexture, r_texture_black, r_texture_black, texture->skin.nmap, texture->glosstexture, r_shadow_rtlight->specularscale * texture->specularscale, false, false);
break;
case R_SHADOW_RENDERMODE_LIGHT_GLSL:
- R_Shadow_RenderSurfacesLighting_Light_GLSL(ent, texture, numsurfaces, surfacelist, lightcolorbase, vec3_origin, vec3_origin, basetexture, r_texture_black, r_texture_black, texture->skin.nmap, glosstexture, specularscale, false, false);
+ R_Shadow_RenderSurfacesLighting_Light_GLSL(ent, texture, numsurfaces, surfacelist, lightcolorbase, vec3_origin, vec3_origin, texture->basetexture, r_texture_black, r_texture_black, texture->skin.nmap, texture->glosstexture, r_shadow_rtlight->specularscale * texture->specularscale, false, false);
break;
case R_SHADOW_RENDERMODE_LIGHT_DOT3:
- R_Shadow_RenderSurfacesLighting_Light_Dot3(ent, texture, numsurfaces, surfacelist, lightcolorbase, vec3_origin, vec3_origin, basetexture, r_texture_black, r_texture_black, texture->skin.nmap, glosstexture, specularscale, false, false);
+ R_Shadow_RenderSurfacesLighting_Light_Dot3(ent, texture, numsurfaces, surfacelist, lightcolorbase, vec3_origin, vec3_origin, texture->basetexture, r_texture_black, r_texture_black, texture->skin.nmap, texture->glosstexture, r_shadow_rtlight->specularscale * texture->specularscale, false, false);
break;
case R_SHADOW_RENDERMODE_LIGHT_VERTEX:
- R_Shadow_RenderSurfacesLighting_Light_Vertex(ent, texture, numsurfaces, surfacelist, lightcolorbase, vec3_origin, vec3_origin, basetexture, r_texture_black, r_texture_black, texture->skin.nmap, glosstexture, specularscale, false, false);
+ R_Shadow_RenderSurfacesLighting_Light_Vertex(ent, texture, numsurfaces, surfacelist, lightcolorbase, vec3_origin, vec3_origin, texture->basetexture, r_texture_black, r_texture_black, texture->skin.nmap, texture->glosstexture, r_shadow_rtlight->specularscale * texture->specularscale, false, false);
break;
default:
Con_Printf("R_Shadow_RenderSurfacesLighting: unknown r_shadow_rendermode %i\n", r_shadow_rendermode);
for (k = 0;k < 3;k++)
for (j = 0;j < 4;j++)
rtlight->matrix_worldtolight.m[k][j] *= scale;
-
- rtlight->lightmap_cullradius = bound(0, rtlight->radius, 2048.0f);
- rtlight->lightmap_cullradius2 = rtlight->lightmap_cullradius * rtlight->lightmap_cullradius;
- VectorScale(rtlight->color, rtlight->radius * (rtlight->style >= 0 ? r_refdef.lightstylevalue[rtlight->style] : 128) * 0.125f, rtlight->lightmap_light);
- rtlight->lightmap_subtract = 1.0f / rtlight->lightmap_cullradius2;
}
// compiles rtlight geometry
R_Shadow_EnlargeLeafSurfaceBuffer(model->brush.num_leafs, model->num_surfaces);
model->GetLightInfo(ent, rtlight->shadoworigin, rtlight->radius, rtlight->cullmins, rtlight->cullmaxs, r_shadow_buffer_leaflist, r_shadow_buffer_leafpvs, &numleafs, r_shadow_buffer_surfacelist, r_shadow_buffer_surfacepvs, &numsurfaces);
numleafpvsbytes = (model->brush.num_leafs + 7) >> 3;
- data = (unsigned char *)Mem_Alloc(r_shadow_mempool, sizeof(int) * numleafs + numleafpvsbytes + sizeof(int) * numsurfaces);
+ data = (unsigned char *)Mem_Alloc(r_main_mempool, sizeof(int) * numleafs + numleafpvsbytes + sizeof(int) * numsurfaces);
rtlight->static_numleafs = numleafs;
rtlight->static_numleafpvsbytes = numleafpvsbytes;
rtlight->static_leaflist = (int *)data;data += sizeof(int) * numleafs;
}
}
- Con_DPrintf("static light built: %f %f %f : %f %f %f box, %i shadow volume triangles (in %i meshes)\n", rtlight->cullmins[0], rtlight->cullmins[1], rtlight->cullmins[2], rtlight->cullmaxs[0], rtlight->cullmaxs[1], rtlight->cullmaxs[2], shadowtris, shadowmeshes);
+ if (developer.integer >= 10)
+ Con_Printf("static light built: %f %f %f : %f %f %f box, %i shadow volume triangles (in %i meshes)\n", rtlight->cullmins[0], rtlight->cullmins[1], rtlight->cullmins[2], rtlight->cullmaxs[0], rtlight->cullmaxs[1], rtlight->cullmaxs[2], shadowtris, shadowmeshes);
}
void R_RTLight_Uncompile(rtlight_t *rtlight)
void R_Shadow_DrawEntityShadow(entity_render_t *ent, int numsurfaces, int *surfacelist)
{
+ model_t *model = ent->model;
vec3_t relativeshadoworigin, relativeshadowmins, relativeshadowmaxs;
vec_t relativeshadowradius;
if (ent == r_refdef.worldentity)
else if (numsurfaces)
{
R_Mesh_Matrix(&ent->matrix);
- ent->model->DrawShadowVolume(ent, r_shadow_rtlight->shadoworigin, r_shadow_rtlight->radius, numsurfaces, surfacelist, r_shadow_rtlight->cullmins, r_shadow_rtlight->cullmaxs);
+ model->DrawShadowVolume(ent, r_shadow_rtlight->shadoworigin, r_shadow_rtlight->radius, numsurfaces, surfacelist, r_shadow_rtlight->cullmins, r_shadow_rtlight->cullmaxs);
}
}
else
relativeshadowmaxs[1] = relativeshadoworigin[1] + relativeshadowradius;
relativeshadowmaxs[2] = relativeshadoworigin[2] + relativeshadowradius;
R_Mesh_Matrix(&ent->matrix);
- ent->model->DrawShadowVolume(ent, relativeshadoworigin, relativeshadowradius, ent->model->nummodelsurfaces, ent->model->surfacelist, relativeshadowmins, relativeshadowmaxs);
+ model->DrawShadowVolume(ent, relativeshadoworigin, relativeshadowradius, model->nummodelsurfaces, model->surfacelist, relativeshadowmins, relativeshadowmaxs);
}
}
void R_Shadow_DrawEntityLight(entity_render_t *ent, int numsurfaces, int *surfacelist)
{
+ model_t *model = ent->model;
+ if (!model->DrawLight)
+ return;
R_Shadow_SetupEntityLight(ent);
if (ent == r_refdef.worldentity)
- ent->model->DrawLight(ent, numsurfaces, surfacelist);
+ model->DrawLight(ent, numsurfaces, surfacelist);
else
- ent->model->DrawLight(ent, ent->model->nummodelsurfaces, ent->model->surfacelist);
+ model->DrawLight(ent, model->nummodelsurfaces, model->surfacelist);
}
void R_DrawRTLight(rtlight_t *rtlight, qboolean visible)
{
for (i = 0;i < r_refdef.numentities;i++)
{
+ model_t *model;
entity_render_t *ent = r_refdef.entities[i];
if (BoxesOverlap(ent->mins, ent->maxs, rtlight->cullmins, rtlight->cullmaxs)
- && ent->model
+ && (model = ent->model)
&& !(ent->flags & RENDER_TRANSPARENT)
&& (r_refdef.worldmodel == NULL || r_refdef.worldmodel->brush.BoxTouchingLeafPVS == NULL || r_refdef.worldmodel->brush.BoxTouchingLeafPVS(r_refdef.worldmodel, leafpvs, ent->mins, ent->maxs)))
{
// about the VectorDistance2 - light emitting entities should not cast their own shadow
- if ((ent->flags & RENDER_SHADOW) && ent->model->DrawShadowVolume && VectorDistance2(ent->origin, rtlight->shadoworigin) > 0.1)
+ if ((ent->flags & RENDER_SHADOW) && model->DrawShadowVolume && VectorDistance2(ent->origin, rtlight->shadoworigin) > 0.1)
shadowentities[numshadowentities++] = ent;
- if (ent->visframe == r_framecount && (ent->flags & RENDER_LIGHT) && ent->model->DrawLight)
+ if (ent->visframe == r_framecount && (ent->flags & RENDER_LIGHT) && model->DrawLight)
lightentities[numlightentities++] = ent;
}
}
dlight_t *R_Shadow_NewWorldLight(void)
{
dlight_t *light;
- light = (dlight_t *)Mem_Alloc(r_shadow_mempool, sizeof(dlight_t));
+ light = (dlight_t *)Mem_Alloc(r_main_mempool, sizeof(dlight_t));
light->next = r_shadow_worldlightchain;
r_shadow_worldlightchain = light;
return light;
void R_Shadow_DrawCursor_TransparentCallback(const entity_render_t *ent, int surfacenumber, const rtlight_t *rtlight)
{
float scale = r_editlights_cursorgrid.value * 0.5f;
- R_DrawSprite(GL_SRC_ALPHA, GL_ONE, r_crosshairs[0]->tex, NULL, false, r_editlights_cursorlocation, r_viewright, r_viewup, scale, -scale, -scale, scale, 1, 1, 1, 0.5f);
+ R_DrawSprite(GL_SRC_ALPHA, GL_ONE, r_crosshairs[1]->tex, NULL, false, r_editlights_cursorlocation, r_viewright, r_viewup, scale, -scale, -scale, scale, 1, 1, 1, 0.5f);
}
void R_Shadow_DrawLightSprite_TransparentCallback(const entity_render_t *ent, int surfacenumber, const rtlight_t *rtlight)