unsigned int permutation = 0;
r_glsl_permutation = NULL;
// TODO: implement geometry-shader based shadow volumes someday
- if (r_shadow_rtlight)
+ if (rsurface.rtlight)
{
// light source
shaderfilename = "glsl/default.glsl";
permutation = SHADERPERMUTATION_MODE_LIGHTSOURCE | SHADERPERMUTATION_USES_VERTEXSHADER | SHADERPERMUTATION_USES_FRAGMENTSHADER;
- if (r_shadow_rtlight->currentcubemap != r_texture_whitecube)
+ if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
permutation |= SHADERPERMUTATION_CUBEFILTER;
if (diffusescale > 0)
permutation |= SHADERPERMUTATION_DIFFUSE;
R_Mesh_TexMatrix(0, &rsurface.texture->currenttexmatrix);
if (permutation & SHADERPERMUTATION_MODE_LIGHTSOURCE)
{
- if (r_glsl_permutation->loc_Texture_Cube >= 0 && r_shadow_rtlight) R_Mesh_TexBindCubeMap(3, R_GetTexture(r_shadow_rtlight->currentcubemap));
- if (r_glsl_permutation->loc_LightPosition >= 0) qglUniform3fARB(r_glsl_permutation->loc_LightPosition, r_shadow_entitylightorigin[0], r_shadow_entitylightorigin[1], r_shadow_entitylightorigin[2]);
+ if (r_glsl_permutation->loc_Texture_Cube >= 0 && rsurface.rtlight) R_Mesh_TexBindCubeMap(3, R_GetTexture(rsurface.rtlight->currentcubemap));
+ if (r_glsl_permutation->loc_LightPosition >= 0) qglUniform3fARB(r_glsl_permutation->loc_LightPosition, rsurface.entitylightorigin[0], rsurface.entitylightorigin[1], rsurface.entitylightorigin[2]);
if (permutation & SHADERPERMUTATION_DIFFUSE)
{
if (r_glsl_permutation->loc_LightColor >= 0) qglUniform3fARB(r_glsl_permutation->loc_LightColor, lightcolorbase[0], lightcolorbase[1], lightcolorbase[2]);
if (r_glsl_permutation->loc_Texture_Normal >= 0) R_Mesh_TexBind(0, R_GetTexture(rsurface.texture->currentskinframe->nmap));
if (r_glsl_permutation->loc_Texture_Color >= 0) R_Mesh_TexBind(1, R_GetTexture(rsurface.texture->basetexture));
if (r_glsl_permutation->loc_Texture_Gloss >= 0) R_Mesh_TexBind(2, R_GetTexture(rsurface.texture->glosstexture));
- //if (r_glsl_permutation->loc_Texture_Cube >= 0 && permutation & SHADERPERMUTATION_MODE_LIGHTSOURCE) R_Mesh_TexBindCubeMap(3, R_GetTexture(r_shadow_rtlight->currentcubemap));
+ //if (r_glsl_permutation->loc_Texture_Cube >= 0 && permutation & SHADERPERMUTATION_MODE_LIGHTSOURCE) R_Mesh_TexBindCubeMap(3, R_GetTexture(rsurface.rtlight->currentcubemap));
if (r_glsl_permutation->loc_Texture_Attenuation >= 0) R_Mesh_TexBind(10, R_GetTexture(r_shadow_attenuationgradienttexture));
if (r_glsl_permutation->loc_Texture_FogMask >= 0) R_Mesh_TexBind(4, R_GetTexture(r_texture_fogattenuation));
if (r_glsl_permutation->loc_Texture_Pants >= 0) R_Mesh_TexBind(5, R_GetTexture(rsurface.texture->currentskinframe->pants));
if (r_glsl_permutation->loc_FogColor >= 0)
{
// additive passes are only darkened by fog, not tinted
- if (r_shadow_rtlight || (rsurface.texture->currentmaterialflags & MATERIALFLAG_ADD))
+ if (rsurface.rtlight || (rsurface.texture->currentmaterialflags & MATERIALFLAG_ADD))
qglUniform3fARB(r_glsl_permutation->loc_FogColor, 0, 0, 0);
else
qglUniform3fARB(r_glsl_permutation->loc_FogColor, r_refdef.fogcolor[0], r_refdef.fogcolor[1], r_refdef.fogcolor[2]);
vec3_t org;
Matrix4x4_OriginFromMatrix(&ent->matrix, org);
//if ((ent->effects & EF_ADDITIVE) || (ent->alpha < 1))
- R_MeshQueue_AddTransparent(ent->effects & EF_NODEPTHTEST ? r_view.origin : org, R_DrawNoModel_TransparentCallback, ent, 0, r_shadow_rtlight);
+ R_MeshQueue_AddTransparent(ent->effects & EF_NODEPTHTEST ? r_view.origin : org, R_DrawNoModel_TransparentCallback, ent, 0, rsurface.rtlight);
//else
// R_DrawNoModelCallback(ent, 0);
}
void RSurf_ActiveWorldEntity(void)
{
+ model_t *model = r_refdef.worldmodel;
RSurf_CleanUp();
- rsurface.model = r_refdef.worldmodel;
- if (rsurface.array_size < rsurface.model->surfmesh.num_vertices)
- R_Mesh_ResizeArrays(rsurface.model->surfmesh.num_vertices);
+ if (rsurface.array_size < model->surfmesh.num_vertices)
+ R_Mesh_ResizeArrays(model->surfmesh.num_vertices);
rsurface.matrix = identitymatrix;
rsurface.inversematrix = identitymatrix;
R_Mesh_Matrix(&identitymatrix);
rsurface.frameblend[2].lerp = 0;
rsurface.frameblend[3].frame = 0;
rsurface.frameblend[3].lerp = 0;
- rsurface.modelvertex3f = rsurface.model->surfmesh.data_vertex3f;
- rsurface.modelvertex3f_bufferobject = rsurface.model->surfmesh.vbo;
- rsurface.modelvertex3f_bufferoffset = rsurface.model->surfmesh.vbooffset_vertex3f;
- rsurface.modelsvector3f = rsurface.model->surfmesh.data_svector3f;
- rsurface.modelsvector3f_bufferobject = rsurface.model->surfmesh.vbo;
- rsurface.modelsvector3f_bufferoffset = rsurface.model->surfmesh.vbooffset_svector3f;
- rsurface.modeltvector3f = rsurface.model->surfmesh.data_tvector3f;
- rsurface.modeltvector3f_bufferobject = rsurface.model->surfmesh.vbo;
- rsurface.modeltvector3f_bufferoffset = rsurface.model->surfmesh.vbooffset_tvector3f;
- rsurface.modelnormal3f = rsurface.model->surfmesh.data_normal3f;
- rsurface.modelnormal3f_bufferobject = rsurface.model->surfmesh.vbo;
- rsurface.modelnormal3f_bufferoffset = rsurface.model->surfmesh.vbooffset_normal3f;
+ rsurface.modelvertex3f = model->surfmesh.data_vertex3f;
+ rsurface.modelvertex3f_bufferobject = model->surfmesh.vbo;
+ rsurface.modelvertex3f_bufferoffset = model->surfmesh.vbooffset_vertex3f;
+ rsurface.modelsvector3f = model->surfmesh.data_svector3f;
+ rsurface.modelsvector3f_bufferobject = model->surfmesh.vbo;
+ rsurface.modelsvector3f_bufferoffset = model->surfmesh.vbooffset_svector3f;
+ rsurface.modeltvector3f = model->surfmesh.data_tvector3f;
+ rsurface.modeltvector3f_bufferobject = model->surfmesh.vbo;
+ rsurface.modeltvector3f_bufferoffset = model->surfmesh.vbooffset_tvector3f;
+ rsurface.modelnormal3f = model->surfmesh.data_normal3f;
+ rsurface.modelnormal3f_bufferobject = model->surfmesh.vbo;
+ rsurface.modelnormal3f_bufferoffset = model->surfmesh.vbooffset_normal3f;
+ rsurface.modellightmapcolor4f = model->surfmesh.data_lightmapcolor4f;
+ rsurface.modellightmapcolor4f_bufferobject = model->surfmesh.vbo;
+ rsurface.modellightmapcolor4f_bufferoffset = model->surfmesh.vbooffset_lightmapcolor4f;
+ rsurface.modeltexcoordtexture2f = model->surfmesh.data_texcoordtexture2f;
+ rsurface.modeltexcoordtexture2f_bufferobject = model->surfmesh.vbo;
+ rsurface.modeltexcoordtexture2f_bufferoffset = model->surfmesh.vbooffset_texcoordtexture2f;
+ rsurface.modeltexcoordlightmap2f = model->surfmesh.data_texcoordlightmap2f;
+ rsurface.modeltexcoordlightmap2f_bufferobject = model->surfmesh.vbo;
+ rsurface.modeltexcoordlightmap2f_bufferoffset = model->surfmesh.vbooffset_texcoordlightmap2f;
+ rsurface.modelelement3i = model->surfmesh.data_element3i;
+ rsurface.modelelement3i_bufferobject = model->surfmesh.ebo;
+ rsurface.modelneighbor3i = model->surfmesh.data_neighbor3i;
+ rsurface.modellightmapoffsets = model->surfmesh.data_lightmapoffsets;
+ rsurface.modelnum_vertices = model->surfmesh.num_vertices;
+ rsurface.modelnum_triangles = model->surfmesh.num_triangles;
+ rsurface.modelsurfaces = model->data_surfaces;
rsurface.generatedvertex = false;
rsurface.vertex3f = rsurface.modelvertex3f;
rsurface.vertex3f_bufferobject = rsurface.modelvertex3f_bufferobject;
void RSurf_ActiveModelEntity(const entity_render_t *ent, qboolean wantnormals, qboolean wanttangents)
{
+ model_t *model = ent->model;
RSurf_CleanUp();
- rsurface.model = ent->model;
- if (rsurface.array_size < rsurface.model->surfmesh.num_vertices)
- R_Mesh_ResizeArrays(rsurface.model->surfmesh.num_vertices);
+ if (rsurface.array_size < model->surfmesh.num_vertices)
+ R_Mesh_ResizeArrays(model->surfmesh.num_vertices);
rsurface.matrix = ent->matrix;
rsurface.inversematrix = ent->inversematrix;
R_Mesh_Matrix(&rsurface.matrix);
rsurface.frameblend[1] = ent->frameblend[1];
rsurface.frameblend[2] = ent->frameblend[2];
rsurface.frameblend[3] = ent->frameblend[3];
- if (rsurface.model->surfmesh.isanimated && (rsurface.frameblend[0].lerp != 1 || rsurface.frameblend[0].frame != 0))
+ if (model->surfmesh.isanimated && (rsurface.frameblend[0].lerp != 1 || rsurface.frameblend[0].frame != 0))
{
if (wanttangents)
{
rsurface.modelsvector3f = rsurface.array_modelsvector3f;
rsurface.modeltvector3f = rsurface.array_modeltvector3f;
rsurface.modelnormal3f = rsurface.array_modelnormal3f;
- Mod_Alias_GetMesh_Vertices(rsurface.model, rsurface.frameblend, rsurface.array_modelvertex3f, rsurface.array_modelnormal3f, rsurface.array_modelsvector3f, rsurface.array_modeltvector3f);
+ Mod_Alias_GetMesh_Vertices(model, rsurface.frameblend, rsurface.array_modelvertex3f, rsurface.array_modelnormal3f, rsurface.array_modelsvector3f, rsurface.array_modeltvector3f);
}
else if (wantnormals)
{
rsurface.modelsvector3f = NULL;
rsurface.modeltvector3f = NULL;
rsurface.modelnormal3f = rsurface.array_modelnormal3f;
- Mod_Alias_GetMesh_Vertices(rsurface.model, rsurface.frameblend, rsurface.array_modelvertex3f, rsurface.array_modelnormal3f, NULL, NULL);
+ Mod_Alias_GetMesh_Vertices(model, rsurface.frameblend, rsurface.array_modelvertex3f, rsurface.array_modelnormal3f, NULL, NULL);
}
else
{
rsurface.modelsvector3f = NULL;
rsurface.modeltvector3f = NULL;
rsurface.modelnormal3f = NULL;
- Mod_Alias_GetMesh_Vertices(rsurface.model, rsurface.frameblend, rsurface.array_modelvertex3f, NULL, NULL, NULL);
+ Mod_Alias_GetMesh_Vertices(model, rsurface.frameblend, rsurface.array_modelvertex3f, NULL, NULL, NULL);
}
rsurface.modelvertex3f_bufferobject = 0;
rsurface.modelvertex3f_bufferoffset = 0;
}
else
{
- rsurface.modelvertex3f = rsurface.model->surfmesh.data_vertex3f;
- rsurface.modelvertex3f_bufferobject = rsurface.model->surfmesh.vbo;
- rsurface.modelvertex3f_bufferoffset = rsurface.model->surfmesh.vbooffset_vertex3f;
- rsurface.modelsvector3f = rsurface.model->surfmesh.data_svector3f;
- rsurface.modelsvector3f_bufferobject = rsurface.model->surfmesh.vbo;
- rsurface.modelsvector3f_bufferoffset = rsurface.model->surfmesh.vbooffset_svector3f;
- rsurface.modeltvector3f = rsurface.model->surfmesh.data_tvector3f;
- rsurface.modeltvector3f_bufferobject = rsurface.model->surfmesh.vbo;
- rsurface.modeltvector3f_bufferoffset = rsurface.model->surfmesh.vbooffset_tvector3f;
- rsurface.modelnormal3f = rsurface.model->surfmesh.data_normal3f;
- rsurface.modelnormal3f_bufferobject = rsurface.model->surfmesh.vbo;
- rsurface.modelnormal3f_bufferoffset = rsurface.model->surfmesh.vbooffset_normal3f;
+ rsurface.modelvertex3f = model->surfmesh.data_vertex3f;
+ rsurface.modelvertex3f_bufferobject = model->surfmesh.vbo;
+ rsurface.modelvertex3f_bufferoffset = model->surfmesh.vbooffset_vertex3f;
+ rsurface.modelsvector3f = model->surfmesh.data_svector3f;
+ rsurface.modelsvector3f_bufferobject = model->surfmesh.vbo;
+ rsurface.modelsvector3f_bufferoffset = model->surfmesh.vbooffset_svector3f;
+ rsurface.modeltvector3f = model->surfmesh.data_tvector3f;
+ rsurface.modeltvector3f_bufferobject = model->surfmesh.vbo;
+ rsurface.modeltvector3f_bufferoffset = model->surfmesh.vbooffset_tvector3f;
+ rsurface.modelnormal3f = model->surfmesh.data_normal3f;
+ rsurface.modelnormal3f_bufferobject = model->surfmesh.vbo;
+ rsurface.modelnormal3f_bufferoffset = model->surfmesh.vbooffset_normal3f;
rsurface.generatedvertex = false;
}
+ rsurface.modellightmapcolor4f = model->surfmesh.data_lightmapcolor4f;
+ rsurface.modellightmapcolor4f_bufferobject = model->surfmesh.vbo;
+ rsurface.modellightmapcolor4f_bufferoffset = model->surfmesh.vbooffset_lightmapcolor4f;
+ rsurface.modeltexcoordtexture2f = model->surfmesh.data_texcoordtexture2f;
+ rsurface.modeltexcoordtexture2f_bufferobject = model->surfmesh.vbo;
+ rsurface.modeltexcoordtexture2f_bufferoffset = model->surfmesh.vbooffset_texcoordtexture2f;
+ rsurface.modeltexcoordlightmap2f = model->surfmesh.data_texcoordlightmap2f;
+ rsurface.modeltexcoordlightmap2f_bufferobject = model->surfmesh.vbo;
+ rsurface.modeltexcoordlightmap2f_bufferoffset = model->surfmesh.vbooffset_texcoordlightmap2f;
+ rsurface.modelelement3i = model->surfmesh.data_element3i;
+ rsurface.modelelement3i_bufferobject = model->surfmesh.ebo;
+ rsurface.modelneighbor3i = model->surfmesh.data_neighbor3i;
+ rsurface.modellightmapoffsets = model->surfmesh.data_lightmapoffsets;
+ rsurface.modelnum_vertices = model->surfmesh.num_vertices;
+ rsurface.modelnum_triangles = model->surfmesh.num_triangles;
+ rsurface.modelsurfaces = model->data_surfaces;
rsurface.vertex3f = rsurface.modelvertex3f;
rsurface.vertex3f_bufferobject = rsurface.modelvertex3f_bufferobject;
rsurface.vertex3f_bufferoffset = rsurface.modelvertex3f_bufferoffset;
rsurface.normal3f = rsurface.modelnormal3f = rsurface.array_modelnormal3f;
rsurface.normal3f_bufferobject = rsurface.modelnormal3f_bufferobject = 0;
rsurface.normal3f_bufferoffset = rsurface.modelnormal3f_bufferoffset = 0;
- Mod_BuildNormals(0, rsurface.model->surfmesh.num_vertices, rsurface.model->surfmesh.num_triangles, rsurface.modelvertex3f, rsurface.model->surfmesh.data_element3i, rsurface.array_modelnormal3f, r_smoothnormals_areaweighting.integer);
+ Mod_BuildNormals(0, rsurface.modelnum_vertices, rsurface.modelnum_triangles, rsurface.modelvertex3f, rsurface.modelelement3i, rsurface.array_modelnormal3f, r_smoothnormals_areaweighting.integer);
}
if (generatetangents && !rsurface.modelsvector3f)
{
rsurface.tvector3f = rsurface.modeltvector3f = rsurface.array_modeltvector3f;
rsurface.tvector3f_bufferobject = rsurface.modeltvector3f_bufferobject = 0;
rsurface.tvector3f_bufferoffset = rsurface.modeltvector3f_bufferoffset = 0;
- Mod_BuildTextureVectorsFromNormals(0, rsurface.model->surfmesh.num_vertices, rsurface.model->surfmesh.num_triangles, rsurface.modelvertex3f, rsurface.model->surfmesh.data_texcoordtexture2f, rsurface.modelnormal3f, rsurface.model->surfmesh.data_element3i, rsurface.array_modelsvector3f, rsurface.array_modeltvector3f, r_smoothnormals_areaweighting.integer);
+ Mod_BuildTextureVectorsFromNormals(0, rsurface.modelnum_vertices, rsurface.modelnum_triangles, rsurface.modelvertex3f, rsurface.modeltexcoordtexture2f, rsurface.modelnormal3f, rsurface.modelelement3i, rsurface.array_modelsvector3f, rsurface.array_modeltvector3f, r_smoothnormals_areaweighting.integer);
}
}
// if vertices are deformed (sprite flares and things in maps, possibly water waves, bulges and other deformations), generate them into rsurface.deform* arrays from whatever the rsurface.model* array pointers point to (may be static model data or generated data for an animated model)
}
}
}
- Mod_BuildNormals(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, rsurface.modelvertex3f, rsurface.model->surfmesh.data_element3i + surface->num_firsttriangle * 3, rsurface.array_deformednormal3f, r_smoothnormals_areaweighting.integer);
- Mod_BuildTextureVectorsFromNormals(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, rsurface.modelvertex3f, rsurface.model->surfmesh.data_texcoordtexture2f, rsurface.array_deformednormal3f, rsurface.model->surfmesh.data_element3i + surface->num_firsttriangle * 3, rsurface.array_deformedsvector3f, rsurface.array_deformedtvector3f, r_smoothnormals_areaweighting.integer);
+ Mod_BuildNormals(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, rsurface.modelvertex3f, rsurface.modelelement3i + surface->num_firsttriangle * 3, rsurface.array_deformednormal3f, r_smoothnormals_areaweighting.integer);
+ Mod_BuildTextureVectorsFromNormals(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, rsurface.modelvertex3f, rsurface.modeltexcoordtexture2f, rsurface.array_deformednormal3f, rsurface.modelelement3i + surface->num_firsttriangle * 3, rsurface.array_deformedsvector3f, rsurface.array_deformedtvector3f, r_smoothnormals_areaweighting.integer);
}
rsurface.vertex3f = rsurface.array_deformedvertex3f;
rsurface.vertex3f_bufferobject = 0;
if (texturenumsurfaces == 1)
{
GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
- R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (rsurface.model->surfmesh.data_element3i + 3 * surface->num_firsttriangle), rsurface.model->surfmesh.ebo, (sizeof(int[3]) * surface->num_firsttriangle));
+ R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (rsurface.modelelement3i + 3 * surface->num_firsttriangle), rsurface.modelelement3i_bufferobject, (sizeof(int[3]) * surface->num_firsttriangle));
}
else if (r_batchmode.integer == 2)
{
j = i + 1;
if (surface->num_triangles > MAXBATCHTRIANGLES)
{
- R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (rsurface.model->surfmesh.data_element3i + 3 * surface->num_firsttriangle), rsurface.model->surfmesh.ebo, (sizeof(int[3]) * surface->num_firsttriangle));
+ R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (rsurface.modelelement3i + 3 * surface->num_firsttriangle), rsurface.modelelement3i_bufferobject, (sizeof(int[3]) * surface->num_firsttriangle));
continue;
}
- memcpy(batchelements, rsurface.model->surfmesh.data_element3i + 3 * surface->num_firsttriangle, surface->num_triangles * sizeof(int[3]));
+ memcpy(batchelements, rsurface.modelelement3i + 3 * surface->num_firsttriangle, surface->num_triangles * sizeof(int[3]));
batchtriangles = surface->num_triangles;
firstvertex = surface->num_firstvertex;
endvertex = surface->num_firstvertex + surface->num_vertices;
surface2 = texturesurfacelist[j];
if (batchtriangles + surface2->num_triangles > MAXBATCHTRIANGLES)
break;
- memcpy(batchelements + batchtriangles * 3, rsurface.model->surfmesh.data_element3i + 3 * surface2->num_firsttriangle, surface2->num_triangles * sizeof(int[3]));
+ memcpy(batchelements + batchtriangles * 3, rsurface.modelelement3i + 3 * surface2->num_firsttriangle, surface2->num_triangles * sizeof(int[3]));
batchtriangles += surface2->num_triangles;
firstvertex = min(firstvertex, surface2->num_firstvertex);
endvertex = max(endvertex, surface2->num_firstvertex + surface2->num_vertices);
numvertices = surface2->num_firstvertex + surface2->num_vertices - surface->num_firstvertex;
numtriangles = surface2->num_firsttriangle + surface2->num_triangles - surface->num_firsttriangle;
GL_LockArrays(surface->num_firstvertex, numvertices);
- R_Mesh_Draw(surface->num_firstvertex, numvertices, numtriangles, (rsurface.model->surfmesh.data_element3i + 3 * surface->num_firsttriangle), rsurface.model->surfmesh.ebo, (sizeof(int[3]) * surface->num_firsttriangle));
+ R_Mesh_Draw(surface->num_firstvertex, numvertices, numtriangles, (rsurface.modelelement3i + 3 * surface->num_firsttriangle), rsurface.modelelement3i_bufferobject, (sizeof(int[3]) * surface->num_firsttriangle));
}
}
else
{
surface = texturesurfacelist[i];
GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
- R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (rsurface.model->surfmesh.data_element3i + 3 * surface->num_firsttriangle), rsurface.model->surfmesh.ebo, (sizeof(int[3]) * surface->num_firsttriangle));
+ R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (rsurface.modelelement3i + 3 * surface->num_firsttriangle), rsurface.modelelement3i_bufferobject, (sizeof(int[3]) * surface->num_firsttriangle));
}
}
}
if (deluxemaptexunit >= 0)
R_Mesh_TexBind(deluxemaptexunit, R_GetTexture(surface->deluxemaptexture));
GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
- R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (rsurface.model->surfmesh.data_element3i + 3 * surface->num_firsttriangle), rsurface.model->surfmesh.ebo, (sizeof(int[3]) * surface->num_firsttriangle));
+ R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (rsurface.modelelement3i + 3 * surface->num_firsttriangle), rsurface.modelelement3i_bufferobject, (sizeof(int[3]) * surface->num_firsttriangle));
}
else if (r_batchmode.integer == 2)
{
j = i + 1;
if (surface->num_triangles > MAXBATCHTRIANGLES)
{
- R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (rsurface.model->surfmesh.data_element3i + 3 * surface->num_firsttriangle), rsurface.model->surfmesh.ebo, (sizeof(int[3]) * surface->num_firsttriangle));
+ R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (rsurface.modelelement3i + 3 * surface->num_firsttriangle), rsurface.modelelement3i_bufferobject, (sizeof(int[3]) * surface->num_firsttriangle));
continue;
}
- memcpy(batchelements, rsurface.model->surfmesh.data_element3i + 3 * surface->num_firsttriangle, surface->num_triangles * sizeof(int[3]));
+ memcpy(batchelements, rsurface.modelelement3i + 3 * surface->num_firsttriangle, surface->num_triangles * sizeof(int[3]));
batchtriangles = surface->num_triangles;
firstvertex = surface->num_firstvertex;
endvertex = surface->num_firstvertex + surface->num_vertices;
surface2 = texturesurfacelist[j];
if (surface2->lightmaptexture != surface->lightmaptexture || batchtriangles + surface2->num_triangles > MAXBATCHTRIANGLES)
break;
- memcpy(batchelements + batchtriangles * 3, rsurface.model->surfmesh.data_element3i + 3 * surface2->num_firsttriangle, surface2->num_triangles * sizeof(int[3]));
+ memcpy(batchelements + batchtriangles * 3, rsurface.modelelement3i + 3 * surface2->num_firsttriangle, surface2->num_triangles * sizeof(int[3]));
batchtriangles += surface2->num_triangles;
firstvertex = min(firstvertex, surface2->num_firstvertex);
endvertex = max(endvertex, surface2->num_firstvertex + surface2->num_vertices);
numvertices = surface2->num_firstvertex + surface2->num_vertices - surface->num_firstvertex;
numtriangles = surface2->num_firsttriangle + surface2->num_triangles - surface->num_firsttriangle;
GL_LockArrays(surface->num_firstvertex, numvertices);
- R_Mesh_Draw(surface->num_firstvertex, numvertices, numtriangles, (rsurface.model->surfmesh.data_element3i + 3 * surface->num_firsttriangle), rsurface.model->surfmesh.ebo, (sizeof(int[3]) * surface->num_firsttriangle));
+ R_Mesh_Draw(surface->num_firstvertex, numvertices, numtriangles, (rsurface.modelelement3i + 3 * surface->num_firsttriangle), rsurface.modelelement3i_bufferobject, (sizeof(int[3]) * surface->num_firsttriangle));
}
#if 0
Con_Printf("\n");
if (deluxemaptexunit >= 0)
R_Mesh_TexBind(deluxemaptexunit, R_GetTexture(surface->deluxemaptexture));
GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
- R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (rsurface.model->surfmesh.data_element3i + 3 * surface->num_firsttriangle), rsurface.model->surfmesh.ebo, (sizeof(int[3]) * surface->num_firsttriangle));
+ R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (rsurface.modelelement3i + 3 * surface->num_firsttriangle), rsurface.modelelement3i_bufferobject, (sizeof(int[3]) * surface->num_firsttriangle));
}
}
}
{
float f = ((j + surface->num_firsttriangle) & 31) * (1.0f / 31.0f) * r_view.colorscale;
GL_Color(f, f, f, 1);
- R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, 1, (rsurface.model->surfmesh.data_element3i + 3 * (j + surface->num_firsttriangle)), rsurface.model->surfmesh.ebo, (sizeof(int[3]) * (j + surface->num_firsttriangle)));
+ R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, 1, (rsurface.modelelement3i + 3 * (j + surface->num_firsttriangle)), rsurface.modelelement3i_bufferobject, (sizeof(int[3]) * (j + surface->num_firsttriangle)));
}
}
}
int k = (int)(((size_t)surface) / sizeof(msurface_t));
GL_Color((k & 15) * (1.0f / 16.0f) * r_view.colorscale, ((k >> 4) & 15) * (1.0f / 16.0f) * r_view.colorscale, ((k >> 8) & 15) * (1.0f / 16.0f) * r_view.colorscale, 1);
GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
- R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (rsurface.model->surfmesh.data_element3i + 3 * surface->num_firsttriangle), rsurface.model->surfmesh.ebo, (sizeof(int[3]) * surface->num_firsttriangle));
+ R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (rsurface.modelelement3i + 3 * surface->num_firsttriangle), rsurface.modelelement3i_bufferobject, (sizeof(int[3]) * surface->num_firsttriangle));
}
}
}
{
if (surface->lightmapinfo->samples)
{
- const unsigned char *lm = surface->lightmapinfo->samples + (rsurface.model->surfmesh.data_lightmapoffsets + surface->num_firstvertex)[i];
+ const unsigned char *lm = surface->lightmapinfo->samples + (rsurface.modellightmapoffsets + surface->num_firstvertex)[i];
float scale = r_refdef.lightstylevalue[surface->lightmapinfo->styles[0]] * (1.0f / 32768.0f);
VectorScale(lm, scale, c);
if (surface->lightmapinfo->styles[1] != 255)
}
else
{
- rsurface.lightmapcolor4f = rsurface.model->surfmesh.data_lightmapcolor4f;
- rsurface.lightmapcolor4f_bufferobject = rsurface.model->surfmesh.vbo;
- rsurface.lightmapcolor4f_bufferoffset = rsurface.model->surfmesh.vbooffset_lightmapcolor4f;
+ rsurface.lightmapcolor4f = rsurface.modellightmapcolor4f;
+ rsurface.lightmapcolor4f_bufferobject = rsurface.modellightmapcolor4f_bufferobject;
+ rsurface.lightmapcolor4f_bufferoffset = rsurface.modellightmapcolor4f_bufferoffset;
}
if (applyfog) RSurf_DrawBatch_GL11_ApplyFog(texturenumsurfaces, texturesurfacelist);
if (applycolor) RSurf_DrawBatch_GL11_ApplyColor(texturenumsurfaces, texturesurfacelist, r, g, b, a);
// in Quake3 maps as it causes problems with q3map2 sky tricks,
// and skymasking also looks very bad when noclipping outside the
// level, so don't use it then either.
- if (rsurface.model->type == mod_brushq1 && r_q1bsp_skymasking.integer && !r_viewcache.world_novis)
+ if (r_refdef.worldmodel && r_refdef.worldmodel->type == mod_brushq1 && r_q1bsp_skymasking.integer && !r_viewcache.world_novis)
{
GL_Color(r_refdef.fogcolor[0] * r_view.colorscale, r_refdef.fogcolor[1] * r_view.colorscale, r_refdef.fogcolor[2] * r_view.colorscale, 1);
R_Mesh_ColorPointer(NULL, 0, 0);
RSurf_PrepareVerticesForBatch(true, r_glsl_permutation->loc_Texture_Normal >= 0, texturenumsurfaces, texturesurfacelist);
else
RSurf_PrepareVerticesForBatch(r_glsl_permutation->loc_Texture_Normal >= 0, r_glsl_permutation->loc_Texture_Normal >= 0, texturenumsurfaces, texturesurfacelist);
- R_Mesh_TexCoordPointer(0, 2, rsurface.model->surfmesh.data_texcoordtexture2f, rsurface.model->surfmesh.vbo, rsurface.model->surfmesh.vbooffset_texcoordtexture2f);
+ R_Mesh_TexCoordPointer(0, 2, rsurface.modeltexcoordtexture2f, rsurface.modeltexcoordtexture2f_bufferobject, rsurface.modeltexcoordtexture2f_bufferoffset);
R_Mesh_TexCoordPointer(1, 3, rsurface.svector3f, rsurface.svector3f_bufferobject, rsurface.svector3f_bufferoffset);
R_Mesh_TexCoordPointer(2, 3, rsurface.tvector3f, rsurface.tvector3f_bufferobject, rsurface.tvector3f_bufferoffset);
R_Mesh_TexCoordPointer(3, 3, rsurface.normal3f, rsurface.normal3f_bufferobject, rsurface.normal3f_bufferoffset);
- R_Mesh_TexCoordPointer(4, 2, rsurface.model->surfmesh.data_texcoordlightmap2f, rsurface.model->surfmesh.vbo, rsurface.model->surfmesh.vbooffset_texcoordlightmap2f);
+ R_Mesh_TexCoordPointer(4, 2, rsurface.modeltexcoordlightmap2f, rsurface.modeltexcoordlightmap2f_bufferobject, rsurface.modeltexcoordlightmap2f_bufferoffset);
GL_Color(rsurface.texture->currentlayers[0].color[0], rsurface.texture->currentlayers[0].color[1], rsurface.texture->currentlayers[0].color[2], rsurface.texture->currentlayers[0].color[3]);
if (rsurface.texture->currentmaterialflags & MATERIALFLAG_FULLBRIGHT)
R_Mesh_TexBind(7, R_GetTexture(r_texture_white));
if (r_glsl_permutation->loc_Texture_Deluxemap >= 0)
R_Mesh_TexBind(8, R_GetTexture(r_texture_blanknormalmap));
- R_Mesh_ColorPointer(rsurface.model->surfmesh.data_lightmapcolor4f, rsurface.model->surfmesh.vbo, rsurface.model->surfmesh.vbooffset_lightmapcolor4f);
+ R_Mesh_ColorPointer(rsurface.modellightmapcolor4f, rsurface.modellightmapcolor4f_bufferobject, rsurface.modellightmapcolor4f_bufferoffset);
}
if (rsurface.uselightmaptexture && !(rsurface.texture->currentmaterialflags & MATERIALFLAG_FULLBRIGHT))
case TEXTURELAYERTYPE_LITTEXTURE:
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(r_texture_white);
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordlightmap2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordlightmap2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordlightmap2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordlightmap2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordlightmap2f_bufferoffset;
m.tex[1] = R_GetTexture(layer->texture);
m.texmatrix[1] = layer->texmatrix;
m.texrgbscale[1] = layertexrgbscale;
- m.pointer_texcoord[1] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[1] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[1] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[1] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[1] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[1] = rsurface.modeltexcoordtexture2f_bufferoffset;
R_Mesh_TextureState(&m);
if (rsurface.lightmode == 2)
RSurf_DrawBatch_GL11_VertexShade(texturenumsurfaces, texturesurfacelist, layercolor[0], layercolor[1], layercolor[2], layercolor[3], applycolor, applyfog);
m.tex[0] = R_GetTexture(layer->texture);
m.texmatrix[0] = layer->texmatrix;
m.texrgbscale[0] = layertexrgbscale;
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
R_Mesh_TextureState(&m);
RSurf_DrawBatch_GL11_Unlit(texturenumsurfaces, texturesurfacelist, layercolor[0], layercolor[1], layercolor[2], layercolor[3], applycolor, applyfog);
break;
{
m.tex[0] = R_GetTexture(layer->texture);
m.texmatrix[0] = layer->texmatrix;
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
}
R_Mesh_TextureState(&m);
// generate a color array for the fog pass
// first the lightmap pass
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(r_texture_white);
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordlightmap2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordlightmap2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordlightmap2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordlightmap2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordlightmap2f_bufferoffset;
R_Mesh_TextureState(&m);
if (rsurface.lightmode == 2)
RSurf_DrawBatch_GL11_VertexShade(texturenumsurfaces, texturesurfacelist, 1, 1, 1, 1, false, false);
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(layer->texture);
m.texmatrix[0] = layer->texmatrix;
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
R_Mesh_TextureState(&m);
RSurf_DrawBatch_GL11_Unlit(texturenumsurfaces, texturesurfacelist, layer->color[0] * 0.5f, layer->color[1] * 0.5f, layer->color[2] * 0.5f, layer->color[3], layer->color[0] != 2 || layer->color[1] != 2 || layer->color[2] != 2 || layer->color[3] != 1, false);
}
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(layer->texture);
m.texmatrix[0] = layer->texmatrix;
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
R_Mesh_TextureState(&m);
if (rsurface.lightmode == 2)
RSurf_DrawBatch_GL11_VertexShade(texturenumsurfaces, texturesurfacelist, layer->color[0], layer->color[1], layer->color[2], layer->color[3], layer->color[0] != 1 || layer->color[1] != 1 || layer->color[2] != 1 || layer->color[3] != 1, applyfog);
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(layer->texture);
m.texmatrix[0] = layer->texmatrix;
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
R_Mesh_TextureState(&m);
RSurf_DrawBatch_GL11_Unlit(texturenumsurfaces, texturesurfacelist, layer->color[0], layer->color[1], layer->color[2], layer->color[3], layer->color[0] != 1 || layer->color[1] != 1 || layer->color[2] != 1 || layer->color[3] != 1, applyfog);
break;
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(layer->texture);
m.texmatrix[0] = layer->texmatrix;
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
R_Mesh_TextureState(&m);
}
else
{
if (rsurface.texture->currentmaterialflags & MATERIALFLAG_NODRAW)
return;
- r_shadow_rtlight = NULL;
+ rsurface.rtlight = NULL;
CHECKGLERROR
if (depthonly)
{
rsurface.mode = RSURFMODE_MULTIPASS;
if (r_depthfirst.integer == 3)
{
- int i = (int)(texturesurfacelist[0] - rsurface.model->data_surfaces);
+ int i = (int)(texturesurfacelist[0] - rsurface.modelsurfaces);
GL_Color(((i >> 6) & 7) / 7.0f, ((i >> 3) & 7) / 7.0f, (i & 7) / 7.0f,1);
}
else
R_Mesh_ColorPointer(NULL, 0, 0);
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(r_texture_white);
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordlightmap2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordlightmap2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordlightmap2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordlightmap2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordlightmap2f_bufferoffset;
R_Mesh_TextureState(&m);
RSurf_PrepareVerticesForBatch(rsurface.lightmode == 2, false, texturenumsurfaces, texturesurfacelist);
if (rsurface.lightmode == 2)
GL_BlendFunc(rsurface.texture->currentlayers[0].blendfunc1, rsurface.texture->currentlayers[0].blendfunc2);
GL_DepthMask(writedepth && !(rsurface.texture->currentmaterialflags & MATERIALFLAG_BLENDED));
GL_AlphaTest((rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST) != 0);
- // FIXME: identify models using a better check than rsurface.model->brush.shadowmesh
- rsurface.lightmode = ((rsurface.texture->currentmaterialflags & MATERIALFLAG_FULLBRIGHT) || rsurface.model->brush.shadowmesh) ? 0 : 2;
+ // use lightmode 0 (fullbright or lightmap) or 2 (model lighting)
+ rsurface.lightmode = ((rsurface.texture->currentmaterialflags & MATERIALFLAG_FULLBRIGHT) || rsurface.modeltexcoordlightmap2f != NULL) ? 0 : 2;
if (r_glsl.integer && gl_support_fragment_shader)
R_DrawTextureSurfaceList_GL20(texturenumsurfaces, texturesurfacelist);
else if (gl_combine.integer && r_textureunits.integer >= 2)
for (i = 0;i < numsurfaces;i = j)
{
j = i + 1;
- surface = rsurface.model->data_surfaces + surfacelist[i];
+ surface = rsurface.modelsurfaces + surfacelist[i];
texture = surface->texture;
R_UpdateTextureInfo(ent, texture);
rsurface.texture = texture->currentframe;
texturesurfacelist[texturenumsurfaces++] = surface;
for (;j < endsurface;j++)
{
- surface = rsurface.model->data_surfaces + surfacelist[j];
+ surface = rsurface.modelsurfaces + surfacelist[j];
if (texture != surface->texture || rsurface.uselightmaptexture != (surface->lightmaptexture != NULL))
break;
texturesurfacelist[texturenumsurfaces++] = surface;
tempcenter[1] = (surface->mins[1] + surface->maxs[1]) * 0.5f;
tempcenter[2] = (surface->mins[2] + surface->maxs[2]) * 0.5f;
Matrix4x4_Transform(&rsurface.matrix, tempcenter, center);
- R_MeshQueue_AddTransparent(rsurface.texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST ? r_view.origin : center, R_DrawSurface_TransparentCallback, ent, surface - rsurface.model->data_surfaces, r_shadow_rtlight);
+ R_MeshQueue_AddTransparent(rsurface.texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST ? r_view.origin : center, R_DrawSurface_TransparentCallback, ent, surface - rsurface.modelsurfaces, rsurface.rtlight);
}
else
{
int r_shadow_buffer_numlighttrispvsbytes;
unsigned char *r_shadow_buffer_lighttrispvs;
-// current light's cull box (copied out of an rtlight or calculated by GetLightInfo)
-vec3_t r_shadow_rtlight_cullmins;
-vec3_t r_shadow_rtlight_cullmaxs;
-// current light's culling planes
-int r_shadow_rtlight_numfrustumplanes;
-mplane_t r_shadow_rtlight_frustumplanes[12+6+6]; // see R_Shadow_ComputeShadowCasterCullingPlanes
-
rtexturepool_t *r_shadow_texturepool;
rtexture_t *r_shadow_attenuationgradienttexture;
rtexture_t *r_shadow_attenuation2dtexture;
Cvar_SetValueQuick(&gl_ext_stenciltwoside, 0);
}
-// light currently being rendered
-rtlight_t *r_shadow_rtlight;
-
-// this is the location of the light in entity space
-vec3_t r_shadow_entitylightorigin;
-// this transforms entity coordinates to light filter cubemap coordinates
-// (also often used for other purposes)
-matrix4x4_t r_shadow_entitytolight;
-// based on entitytolight this transforms -1 to +1 to 0 to 1 for purposes
-// of attenuation texturing in full 3D (Z result often ignored)
-matrix4x4_t r_shadow_entitytoattenuationxyz;
-// this transforms only the Z to S, and T is always 0.5
-matrix4x4_t r_shadow_entitytoattenuationz;
-
void R_Shadow_RenderMode_Begin(void)
{
R_Shadow_ValidateCvars();
void R_Shadow_RenderMode_ActiveLight(rtlight_t *rtlight)
{
- r_shadow_rtlight = rtlight;
+ rsurface.rtlight = rtlight;
}
void R_Shadow_RenderMode_Reset(void)
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_TexBindCubeMap(3, R_GetTexture(r_shadow_rtlight->currentcubemap)); // light filter
+ R_Mesh_TexBindCubeMap(3, R_GetTexture(rsurface.rtlight->currentcubemap)); // light filter
R_Mesh_TexBind(4, R_GetTexture(r_texture_fogattenuation)); // fog
R_Mesh_TexBind(5, R_GetTexture(r_texture_white)); // pants
R_Mesh_TexBind(6, R_GetTexture(r_texture_white)); // shirt
R_Mesh_TexBind(7, R_GetTexture(r_texture_white)); // lightmap
R_Mesh_TexBind(8, R_GetTexture(r_texture_blanknormalmap)); // deluxemap
R_Mesh_TexBind(9, R_GetTexture(r_texture_black)); // glow
- //R_Mesh_TexMatrix(3, r_shadow_entitytolight); // light filter matrix
+ //R_Mesh_TexMatrix(3, rsurface.entitytolight); // light filter matrix
GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
GL_ColorMask(r_view.colormask[0], r_view.colormask[1], r_view.colormask[2], 0);
CHECKGLERROR
{
for (;numverts > 0;numverts--, vertex3f += 3, normal3f += 3, color4f += 4)
{
- Matrix4x4_Transform(&r_shadow_entitytolight, vertex3f, v);
- Matrix4x4_Transform3x3(&r_shadow_entitytolight, normal3f, n);
+ Matrix4x4_Transform(&rsurface.entitytolight, vertex3f, v);
+ Matrix4x4_Transform3x3(&rsurface.entitytolight, normal3f, n);
if ((dot = DotProduct(n, v)) < 0)
{
shadeintensity = -dot / sqrt(VectorLength2(v) * VectorLength2(n));
if (r_refdef.fogenabled)
{
float f;
- Matrix4x4_Transform(&r_shadow_entitytolight, vertex3f, v);
+ Matrix4x4_Transform(&rsurface.entitytolight, vertex3f, v);
f = FogPoint_Model(vertex3f);
VectorScale(color4f, f, color4f);
}
{
for (;numverts > 0;numverts--, vertex3f += 3, normal3f += 3, color4f += 4)
{
- Matrix4x4_Transform(&r_shadow_entitytolight, vertex3f, v);
+ Matrix4x4_Transform(&rsurface.entitytolight, vertex3f, v);
if ((dist = fabs(v[2])) < 1 && (distintensity = r_shadow_attentable[(int)(dist * ATTENTABLESIZE)]))
{
- Matrix4x4_Transform3x3(&r_shadow_entitytolight, normal3f, n);
+ Matrix4x4_Transform3x3(&rsurface.entitytolight, normal3f, n);
if ((dot = DotProduct(n, v)) < 0)
{
shadeintensity = -dot / sqrt(VectorLength2(v) * VectorLength2(n));
{
for (;numverts > 0;numverts--, vertex3f += 3, color4f += 4)
{
- Matrix4x4_Transform(&r_shadow_entitytolight, vertex3f, v);
+ Matrix4x4_Transform(&rsurface.entitytolight, vertex3f, v);
if ((dist = fabs(v[2])) < 1 && (distintensity = r_shadow_attentable[(int)(dist * ATTENTABLESIZE)]))
{
color4f[0] = ambientcolor[0] * distintensity;
{
for (;numverts > 0;numverts--, vertex3f += 3, normal3f += 3, color4f += 4)
{
- Matrix4x4_Transform(&r_shadow_entitytolight, vertex3f, v);
+ Matrix4x4_Transform(&rsurface.entitytolight, vertex3f, v);
if ((dist = VectorLength(v)) < 1 && (distintensity = r_shadow_attentable[(int)(dist * ATTENTABLESIZE)]))
{
distintensity = (1 - dist) * r_shadow_lightattenuationlinearscale.value / (r_shadow_lightattenuationdividebias.value + dist*dist);
- Matrix4x4_Transform3x3(&r_shadow_entitytolight, normal3f, n);
+ Matrix4x4_Transform3x3(&rsurface.entitytolight, normal3f, n);
if ((dot = DotProduct(n, v)) < 0)
{
shadeintensity = -dot / sqrt(VectorLength2(v) * VectorLength2(n));
{
for (;numverts > 0;numverts--, vertex3f += 3, color4f += 4)
{
- Matrix4x4_Transform(&r_shadow_entitytolight, vertex3f, v);
+ Matrix4x4_Transform(&rsurface.entitytolight, vertex3f, v);
if ((dist = VectorLength(v)) < 1 && (distintensity = r_shadow_attentable[(int)(dist * ATTENTABLESIZE)]))
{
distintensity = (1 - dist) * r_shadow_lightattenuationlinearscale.value / (r_shadow_lightattenuationdividebias.value + dist*dist);
float lightdir[3];
for (i = 0;i < numvertices;i++, vertex3f += 3, svector3f += 3, tvector3f += 3, normal3f += 3, out3f += 3)
{
- VectorSubtract(r_shadow_entitylightorigin, vertex3f, lightdir);
+ VectorSubtract(rsurface.entitylightorigin, vertex3f, lightdir);
// the cubemap normalizes this for us
out3f[0] = DotProduct(svector3f, lightdir);
out3f[1] = DotProduct(tvector3f, lightdir);
float lightdir[3], eyedir[3], halfdir[3];
for (i = 0;i < numvertices;i++, vertex3f += 3, svector3f += 3, tvector3f += 3, normal3f += 3, out3f += 3)
{
- VectorSubtract(r_shadow_entitylightorigin, vertex3f, lightdir);
+ VectorSubtract(rsurface.entitylightorigin, vertex3f, lightdir);
VectorNormalize(lightdir);
VectorSubtract(rsurface.modelorg, vertex3f, eyedir);
VectorNormalize(eyedir);
{
// ARB2 GLSL shader path (GFFX5200, Radeon 9500)
R_SetupSurfaceShader(lightcolorbase, false, ambientscale, diffusescale, specularscale);
- R_Mesh_TexCoordPointer(0, 2, rsurface.model->surfmesh.data_texcoordtexture2f, rsurface.model->surfmesh.vbo, rsurface.model->surfmesh.vbooffset_texcoordtexture2f);
+ R_Mesh_TexCoordPointer(0, 2, rsurface.modeltexcoordtexture2f, rsurface.modeltexcoordtexture2f_bufferobject, rsurface.modeltexcoordtexture2f_bufferoffset);
R_Mesh_TexCoordPointer(1, 3, rsurface.svector3f, rsurface.svector3f_bufferobject, rsurface.svector3f_bufferoffset);
R_Mesh_TexCoordPointer(2, 3, rsurface.tvector3f, rsurface.tvector3f_bufferobject, rsurface.tvector3f_bufferoffset);
R_Mesh_TexCoordPointer(3, 3, rsurface.normal3f, rsurface.normal3f_bufferobject, rsurface.normal3f_bufferoffset);
//
// Limit mult to 64 for sanity sake.
GL_Color(1,1,1,1);
- if (r_shadow_texture3d.integer && r_shadow_rtlight->currentcubemap != r_texture_whitecube && r_textureunits.integer >= 4)
+ if (r_shadow_texture3d.integer && rsurface.rtlight->currentcubemap != r_texture_whitecube && r_textureunits.integer >= 4)
{
// 3 3D combine path (Geforce3, Radeon 8500)
memset(&m, 0, sizeof(m));
m.pointer_texcoord3f[0] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[0] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[0] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
+ m.texmatrix[0] = rsurface.entitytoattenuationxyz;
m.tex[1] = R_GetTexture(basetexture);
- m.pointer_texcoord[1] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[1] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[1] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[1] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[1] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[1] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[1] = rsurface.texture->currenttexmatrix;
- m.texcubemap[2] = R_GetTexture(r_shadow_rtlight->currentcubemap);
+ m.texcubemap[2] = R_GetTexture(rsurface.rtlight->currentcubemap);
m.pointer_texcoord3f[2] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[2] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[2] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[2] = r_shadow_entitytolight;
+ m.texmatrix[2] = rsurface.entitytolight;
GL_BlendFunc(GL_ONE, GL_ONE);
}
- else if (r_shadow_texture3d.integer && r_shadow_rtlight->currentcubemap == r_texture_whitecube && r_textureunits.integer >= 2)
+ else if (r_shadow_texture3d.integer && rsurface.rtlight->currentcubemap == r_texture_whitecube && r_textureunits.integer >= 2)
{
// 2 3D combine path (Geforce3, original Radeon)
memset(&m, 0, sizeof(m));
m.pointer_texcoord3f[0] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[0] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[0] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
+ m.texmatrix[0] = rsurface.entitytoattenuationxyz;
m.tex[1] = R_GetTexture(basetexture);
- m.pointer_texcoord[1] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[1] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[1] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[1] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[1] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[1] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[1] = rsurface.texture->currenttexmatrix;
GL_BlendFunc(GL_ONE, GL_ONE);
}
- else if (r_textureunits.integer >= 4 && r_shadow_rtlight->currentcubemap != r_texture_whitecube)
+ else if (r_textureunits.integer >= 4 && rsurface.rtlight->currentcubemap != r_texture_whitecube)
{
// 4 2D combine path (Geforce3, Radeon 8500)
memset(&m, 0, sizeof(m));
m.pointer_texcoord3f[0] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[0] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[0] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
+ m.texmatrix[0] = rsurface.entitytoattenuationxyz;
m.tex[1] = R_GetTexture(r_shadow_attenuation2dtexture);
m.pointer_texcoord3f[1] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[1] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[1] = r_shadow_entitytoattenuationz;
+ m.texmatrix[1] = rsurface.entitytoattenuationz;
m.tex[2] = R_GetTexture(basetexture);
- m.pointer_texcoord[2] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[2] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[2] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[2] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[2] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[2] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[2] = rsurface.texture->currenttexmatrix;
- if (r_shadow_rtlight->currentcubemap != r_texture_whitecube)
+ if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
{
- m.texcubemap[3] = R_GetTexture(r_shadow_rtlight->currentcubemap);
+ m.texcubemap[3] = R_GetTexture(rsurface.rtlight->currentcubemap);
m.pointer_texcoord3f[3] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[3] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[3] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[3] = r_shadow_entitytolight;
+ m.texmatrix[3] = rsurface.entitytolight;
}
GL_BlendFunc(GL_ONE, GL_ONE);
}
- else if (r_textureunits.integer >= 3 && r_shadow_rtlight->currentcubemap == r_texture_whitecube)
+ else if (r_textureunits.integer >= 3 && rsurface.rtlight->currentcubemap == r_texture_whitecube)
{
// 3 2D combine path (Geforce3, original Radeon)
memset(&m, 0, sizeof(m));
m.pointer_texcoord3f[0] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[0] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[0] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
+ m.texmatrix[0] = rsurface.entitytoattenuationxyz;
m.tex[1] = R_GetTexture(r_shadow_attenuation2dtexture);
m.pointer_texcoord3f[1] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[1] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[1] = r_shadow_entitytoattenuationz;
+ m.texmatrix[1] = rsurface.entitytoattenuationz;
m.tex[2] = R_GetTexture(basetexture);
- m.pointer_texcoord[2] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[2] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[2] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[2] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[2] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[2] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[2] = rsurface.texture->currenttexmatrix;
GL_BlendFunc(GL_ONE, GL_ONE);
}
m.pointer_texcoord3f[0] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[0] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[0] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
+ m.texmatrix[0] = rsurface.entitytoattenuationxyz;
m.tex[1] = R_GetTexture(r_shadow_attenuation2dtexture);
m.pointer_texcoord3f[1] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[1] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[1] = r_shadow_entitytoattenuationz;
+ m.texmatrix[1] = rsurface.entitytoattenuationz;
R_Mesh_TextureState(&m);
GL_ColorMask(0,0,0,1);
GL_BlendFunc(GL_ONE, GL_ZERO);
// second pass
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(basetexture);
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
- if (r_shadow_rtlight->currentcubemap != r_texture_whitecube)
+ if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
{
- m.texcubemap[1] = R_GetTexture(r_shadow_rtlight->currentcubemap);
+ m.texcubemap[1] = R_GetTexture(rsurface.rtlight->currentcubemap);
m.pointer_texcoord3f[1] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[1] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[1] = r_shadow_entitytolight;
+ m.texmatrix[1] = rsurface.entitytolight;
}
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
}
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(normalmaptexture);
m.texcombinergb[0] = GL_REPLACE;
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
m.pointer_texcoord3f[2] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[2] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[2] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[2] = r_shadow_entitytoattenuationxyz;
+ m.texmatrix[2] = rsurface.entitytoattenuationxyz;
R_Mesh_TextureState(&m);
GL_ColorMask(0,0,0,1);
GL_BlendFunc(GL_ONE, GL_ZERO);
// second pass
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(basetexture);
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
- if (r_shadow_rtlight->currentcubemap != r_texture_whitecube)
+ if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
{
- m.texcubemap[1] = R_GetTexture(r_shadow_rtlight->currentcubemap);
+ m.texcubemap[1] = R_GetTexture(rsurface.rtlight->currentcubemap);
m.pointer_texcoord3f[1] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[1] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[1] = r_shadow_entitytolight;
+ m.texmatrix[1] = rsurface.entitytolight;
}
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
}
- else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && r_shadow_rtlight->currentcubemap != r_texture_whitecube)
+ else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && rsurface.rtlight->currentcubemap != r_texture_whitecube)
{
// 1/2/2 3D combine path (original Radeon)
memset(&m, 0, sizeof(m));
m.pointer_texcoord3f[0] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[0] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[0] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
+ m.texmatrix[0] = rsurface.entitytoattenuationxyz;
R_Mesh_TextureState(&m);
GL_ColorMask(0,0,0,1);
GL_BlendFunc(GL_ONE, GL_ZERO);
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(normalmaptexture);
m.texcombinergb[0] = GL_REPLACE;
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
// second pass
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(basetexture);
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
- if (r_shadow_rtlight->currentcubemap != r_texture_whitecube)
+ if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
{
- m.texcubemap[1] = R_GetTexture(r_shadow_rtlight->currentcubemap);
+ m.texcubemap[1] = R_GetTexture(rsurface.rtlight->currentcubemap);
m.pointer_texcoord3f[1] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[1] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[1] = r_shadow_entitytolight;
+ m.texmatrix[1] = rsurface.entitytolight;
}
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
}
- else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && r_shadow_rtlight->currentcubemap == r_texture_whitecube)
+ else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && rsurface.rtlight->currentcubemap == r_texture_whitecube)
{
// 2/2 3D combine path (original Radeon)
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(normalmaptexture);
m.texcombinergb[0] = GL_REPLACE;
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
// second pass
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(basetexture);
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
m.tex3d[1] = R_GetTexture(r_shadow_attenuation3dtexture);
m.pointer_texcoord3f[1] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[1] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[1] = r_shadow_entitytoattenuationxyz;
+ m.texmatrix[1] = rsurface.entitytoattenuationxyz;
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
}
else if (r_textureunits.integer >= 4)
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(normalmaptexture);
m.texcombinergb[0] = GL_REPLACE;
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
m.pointer_texcoord3f[2] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[2] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[2] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[2] = r_shadow_entitytoattenuationxyz;
+ m.texmatrix[2] = rsurface.entitytoattenuationxyz;
m.tex[3] = R_GetTexture(r_shadow_attenuation2dtexture);
m.pointer_texcoord3f[3] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[3] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[3] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[3] = r_shadow_entitytoattenuationz;
+ m.texmatrix[3] = rsurface.entitytoattenuationz;
R_Mesh_TextureState(&m);
GL_ColorMask(0,0,0,1);
GL_BlendFunc(GL_ONE, GL_ZERO);
// second pass
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(basetexture);
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
- if (r_shadow_rtlight->currentcubemap != r_texture_whitecube)
+ if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
{
- m.texcubemap[1] = R_GetTexture(r_shadow_rtlight->currentcubemap);
+ m.texcubemap[1] = R_GetTexture(rsurface.rtlight->currentcubemap);
m.pointer_texcoord3f[1] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[1] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[1] = r_shadow_entitytolight;
+ m.texmatrix[1] = rsurface.entitytolight;
}
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
}
m.pointer_texcoord3f[0] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[0] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[0] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
+ m.texmatrix[0] = rsurface.entitytoattenuationxyz;
m.tex[1] = R_GetTexture(r_shadow_attenuation2dtexture);
m.pointer_texcoord3f[1] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[0] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[0] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[1] = r_shadow_entitytoattenuationz;
+ m.texmatrix[1] = rsurface.entitytoattenuationz;
R_Mesh_TextureState(&m);
GL_ColorMask(0,0,0,1);
GL_BlendFunc(GL_ONE, GL_ZERO);
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(normalmaptexture);
m.texcombinergb[0] = GL_REPLACE;
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
// second pass
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(basetexture);
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
- if (r_shadow_rtlight->currentcubemap != r_texture_whitecube)
+ if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
{
- m.texcubemap[1] = R_GetTexture(r_shadow_rtlight->currentcubemap);
+ m.texcubemap[1] = R_GetTexture(rsurface.rtlight->currentcubemap);
m.pointer_texcoord3f[1] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[1] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[1] = r_shadow_entitytolight;
+ m.texmatrix[1] = rsurface.entitytolight;
}
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
}
GL_Color(1,1,1,1);
// generate normalization cubemap texcoords
R_Shadow_GenTexCoords_Specular_NormalCubeMap(firstvertex, numvertices, numtriangles, element3i);
- if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && r_shadow_rtlight->currentcubemap != r_texture_whitecube)
+ if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && rsurface.rtlight->currentcubemap != r_texture_whitecube)
{
// 2/0/0/1/2 3D combine blendsquare path
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(normalmaptexture);
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
m.pointer_texcoord3f[0] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[0] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[0] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
+ m.texmatrix[0] = rsurface.entitytoattenuationxyz;
R_Mesh_TextureState(&m);
GL_BlendFunc(GL_DST_ALPHA, GL_ZERO);
R_Mesh_Draw(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset);
// fifth pass
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(glosstexture);
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
- if (r_shadow_rtlight->currentcubemap != r_texture_whitecube)
+ if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
{
- m.texcubemap[1] = R_GetTexture(r_shadow_rtlight->currentcubemap);
+ m.texcubemap[1] = R_GetTexture(rsurface.rtlight->currentcubemap);
m.pointer_texcoord3f[1] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[1] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[1] = r_shadow_entitytolight;
+ m.texmatrix[1] = rsurface.entitytolight;
}
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
}
- else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && r_shadow_rtlight->currentcubemap == r_texture_whitecube /* && gl_support_blendsquare*/) // FIXME: detect blendsquare!
+ else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && rsurface.rtlight->currentcubemap == r_texture_whitecube /* && gl_support_blendsquare*/) // FIXME: detect blendsquare!
{
// 2/0/0/2 3D combine blendsquare path
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(normalmaptexture);
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
// fourth pass
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(glosstexture);
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
m.tex3d[1] = R_GetTexture(r_shadow_attenuation3dtexture);
m.pointer_texcoord3f[1] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[1] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[1] = r_shadow_entitytoattenuationxyz;
+ m.texmatrix[1] = rsurface.entitytoattenuationxyz;
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
}
else
// 2/0/0/2/2 2D combine blendsquare path
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(normalmaptexture);
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
m.pointer_texcoord3f[0] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[0] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[0] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
+ m.texmatrix[0] = rsurface.entitytoattenuationxyz;
m.tex[1] = R_GetTexture(r_shadow_attenuation2dtexture);
m.pointer_texcoord3f[1] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[1] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[1] = r_shadow_entitytoattenuationz;
+ m.texmatrix[1] = rsurface.entitytoattenuationz;
R_Mesh_TextureState(&m);
GL_BlendFunc(GL_DST_ALPHA, GL_ZERO);
R_Mesh_Draw(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset);
// fifth pass
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(glosstexture);
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
- if (r_shadow_rtlight->currentcubemap != r_texture_whitecube)
+ if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
{
- m.texcubemap[1] = R_GetTexture(r_shadow_rtlight->currentcubemap);
+ m.texcubemap[1] = R_GetTexture(rsurface.rtlight->currentcubemap);
m.pointer_texcoord3f[1] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[1] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
- m.texmatrix[1] = r_shadow_entitytolight;
+ m.texmatrix[1] = rsurface.entitytolight;
}
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
}
R_Shadow_RenderLighting_Light_Dot3_SpecularPass(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, lightcolorbase, glosstexture, normalmaptexture, specularscale * r_view.colorscale);
}
-void R_Shadow_RenderLighting_Light_Vertex_Pass(const model_t *model, int firstvertex, int numvertices, int numtriangles, const int *element3i, int element3i_bufferobject, size_t element3i_bufferoffset, vec3_t diffusecolor2, vec3_t ambientcolor2)
+void R_Shadow_RenderLighting_Light_Vertex_Pass(int firstvertex, int numvertices, int numtriangles, const int *element3i, int element3i_bufferobject, size_t element3i_bufferoffset, vec3_t diffusecolor2, vec3_t ambientcolor2)
{
int renders;
int i;
static void R_Shadow_RenderLighting_Light_Vertex(int firstvertex, int numvertices, int numtriangles, const int *element3i, int element3i_bufferobject, size_t element3i_bufferoffset, 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 ambientscale, float diffusescale, float specularscale, qboolean dopants, qboolean doshirt)
{
// OpenGL 1.1 path (anything)
- const model_t *model = rsurface.model;
float ambientcolorbase[3], diffusecolorbase[3];
float ambientcolorpants[3], diffusecolorpants[3];
float ambientcolorshirt[3], diffusecolorshirt[3];
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(basetexture);
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
- m.pointer_texcoord[0] = rsurface.model->surfmesh.data_texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.model->surfmesh.vbo;
- m.pointer_texcoord_bufferoffset[0] = rsurface.model->surfmesh.vbooffset_texcoordtexture2f;
+ m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
+ m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
+ m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
if (r_textureunits.integer >= 2)
{
// voodoo2 or TNT
m.tex[1] = R_GetTexture(r_shadow_attenuation2dtexture);
- m.texmatrix[1] = r_shadow_entitytoattenuationxyz;
+ m.texmatrix[1] = rsurface.entitytoattenuationxyz;
m.pointer_texcoord3f[1] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[1] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
{
// Voodoo4 or Kyro (or Geforce3/Radeon with gl_combine off)
m.tex[2] = R_GetTexture(r_shadow_attenuation2dtexture);
- m.texmatrix[2] = r_shadow_entitytoattenuationz;
+ m.texmatrix[2] = rsurface.entitytoattenuationz;
m.pointer_texcoord3f[2] = rsurface.vertex3f;
m.pointer_texcoord_bufferobject[2] = rsurface.vertex3f_bufferobject;
m.pointer_texcoord_bufferoffset[2] = rsurface.vertex3f_bufferoffset;
}
R_Mesh_TextureState(&m);
//R_Mesh_TexBind(0, R_GetTexture(basetexture));
- R_Shadow_RenderLighting_Light_Vertex_Pass(model, firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, diffusecolorbase, ambientcolorbase);
+ R_Shadow_RenderLighting_Light_Vertex_Pass(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, diffusecolorbase, ambientcolorbase);
if (dopants)
{
R_Mesh_TexBind(0, R_GetTexture(pantstexture));
- R_Shadow_RenderLighting_Light_Vertex_Pass(model, firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, diffusecolorpants, ambientcolorpants);
+ R_Shadow_RenderLighting_Light_Vertex_Pass(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, diffusecolorpants, ambientcolorpants);
}
if (doshirt)
{
R_Mesh_TexBind(0, R_GetTexture(shirttexture));
- R_Shadow_RenderLighting_Light_Vertex_Pass(model, firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, diffusecolorshirt, ambientcolorshirt);
+ R_Shadow_RenderLighting_Light_Vertex_Pass(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, diffusecolorshirt, ambientcolorshirt);
}
}
float ambientscale, diffusescale, specularscale;
vec3_t lightcolorbase, lightcolorpants, lightcolorshirt;
// calculate colors to render this texture with
- lightcolorbase[0] = r_shadow_rtlight->currentcolor[0] * rsurface.texture->currentlayers[0].color[0] * rsurface.texture->currentlayers[0].color[3];
- lightcolorbase[1] = r_shadow_rtlight->currentcolor[1] * rsurface.texture->currentlayers[0].color[1] * rsurface.texture->currentlayers[0].color[3];
- lightcolorbase[2] = r_shadow_rtlight->currentcolor[2] * rsurface.texture->currentlayers[0].color[2] * rsurface.texture->currentlayers[0].color[3];
- ambientscale = r_shadow_rtlight->ambientscale;
- diffusescale = r_shadow_rtlight->diffusescale;
- specularscale = r_shadow_rtlight->specularscale * rsurface.texture->specularscale;
+ lightcolorbase[0] = rsurface.rtlight->currentcolor[0] * rsurface.texture->currentlayers[0].color[0] * rsurface.texture->currentlayers[0].color[3];
+ lightcolorbase[1] = rsurface.rtlight->currentcolor[1] * rsurface.texture->currentlayers[0].color[1] * rsurface.texture->currentlayers[0].color[3];
+ lightcolorbase[2] = rsurface.rtlight->currentcolor[2] * rsurface.texture->currentlayers[0].color[2] * rsurface.texture->currentlayers[0].color[3];
+ ambientscale = rsurface.rtlight->ambientscale;
+ diffusescale = rsurface.rtlight->diffusescale;
+ specularscale = rsurface.rtlight->specularscale * rsurface.texture->specularscale;
if (!r_shadow_usenormalmap.integer)
{
ambientscale += 1.0f * diffusescale;
int i, j;
mplane_t plane;
// reset the count of frustum planes
- // see r_shadow_rtlight_frustumplanes definition for how much this array
+ // see rsurface.rtlight_frustumplanes definition for how much this array
// can hold
- r_shadow_rtlight_numfrustumplanes = 0;
+ rsurface.rtlight_numfrustumplanes = 0;
#if 1
// generate a deformed frustum that includes the light origin, this is
if (PlaneDiff(rtlight->shadoworigin, &r_view.frustum[i]) < -0.03125)
continue;
// copy the plane
- r_shadow_rtlight_frustumplanes[r_shadow_rtlight_numfrustumplanes++] = r_view.frustum[i];
+ rsurface.rtlight_frustumplanes[rsurface.rtlight_numfrustumplanes++] = r_view.frustum[i];
}
// if all the standard frustum planes were accepted, the light is onscreen
// otherwise we need to generate some more planes below...
- if (r_shadow_rtlight_numfrustumplanes < 4)
+ if (rsurface.rtlight_numfrustumplanes < 4)
{
// at least one of the stock frustum planes failed, so we need to
// create one or two custom planes to enclose the light origin
// we have created a valid plane, compute extra info
PlaneClassify(&plane);
// copy the plane
- r_shadow_rtlight_frustumplanes[r_shadow_rtlight_numfrustumplanes++] = plane;
+ rsurface.rtlight_frustumplanes[rsurface.rtlight_numfrustumplanes++] = plane;
#if 1
// if we've found 5 frustum planes then we have constructed a
// proper split-side case and do not need to keep searching for
// planes to enclose the light origin
- if (r_shadow_rtlight_numfrustumplanes == 5)
+ if (rsurface.rtlight_numfrustumplanes == 5)
break;
#endif
}
#endif
#if 0
- for (i = 0;i < r_shadow_rtlight_numfrustumplanes;i++)
+ for (i = 0;i < rsurface.rtlight_numfrustumplanes;i++)
{
- plane = r_shadow_rtlight_frustumplanes[i];
+ plane = rsurface.rtlight_frustumplanes[i];
Con_Printf("light %p plane #%i %f %f %f : %f (%f %f %f %f %f)\n", rtlight, i, plane.normal[0], plane.normal[1], plane.normal[2], plane.dist, PlaneDiff(r_view.frustumcorner[0], &plane), PlaneDiff(r_view.frustumcorner[1], &plane), PlaneDiff(r_view.frustumcorner[2], &plane), PlaneDiff(r_view.frustumcorner[3], &plane), PlaneDiff(rtlight->shadoworigin, &plane));
}
#endif
VectorSubtract(plane.normal, rtlight->shadoworigin, plane.normal);
plane.dist = VectorNormalizeLength(plane.normal);
plane.dist += DotProduct(plane.normal, rtlight->shadoworigin);
- r_shadow_rtlight_frustumplanes[r_shadow_rtlight_numfrustumplanes++] = plane;
+ rsurface.rtlight_frustumplanes[rsurface.rtlight_numfrustumplanes++] = plane;
}
}
#endif
{
VectorClear(plane.normal);
plane.normal[i >> 1] = (i & 1) ? -1 : 1;
- plane.dist = (i & 1) ? -r_shadow_rtlight_cullmaxs[i >> 1] : r_shadow_rtlight_cullmins[i >> 1];
- r_shadow_rtlight_frustumplanes[r_shadow_rtlight_numfrustumplanes++] = plane;
+ plane.dist = (i & 1) ? -rsurface.rtlight_cullmaxs[i >> 1] : rsurface.rtlight_cullmins[i >> 1];
+ rsurface.rtlight_frustumplanes[rsurface.rtlight_numfrustumplanes++] = plane;
}
#endif
vec_t bestdist;
// reduce all plane distances to tightly fit the rtlight cull box, which
// is in worldspace
- VectorSet(points[0], r_shadow_rtlight_cullmins[0], r_shadow_rtlight_cullmins[1], r_shadow_rtlight_cullmins[2]);
- VectorSet(points[1], r_shadow_rtlight_cullmaxs[0], r_shadow_rtlight_cullmins[1], r_shadow_rtlight_cullmins[2]);
- VectorSet(points[2], r_shadow_rtlight_cullmins[0], r_shadow_rtlight_cullmaxs[1], r_shadow_rtlight_cullmins[2]);
- VectorSet(points[3], r_shadow_rtlight_cullmaxs[0], r_shadow_rtlight_cullmaxs[1], r_shadow_rtlight_cullmins[2]);
- VectorSet(points[4], r_shadow_rtlight_cullmins[0], r_shadow_rtlight_cullmins[1], r_shadow_rtlight_cullmaxs[2]);
- VectorSet(points[5], r_shadow_rtlight_cullmaxs[0], r_shadow_rtlight_cullmins[1], r_shadow_rtlight_cullmaxs[2]);
- VectorSet(points[6], r_shadow_rtlight_cullmins[0], r_shadow_rtlight_cullmaxs[1], r_shadow_rtlight_cullmaxs[2]);
- VectorSet(points[7], r_shadow_rtlight_cullmaxs[0], r_shadow_rtlight_cullmaxs[1], r_shadow_rtlight_cullmaxs[2]);
- oldnum = r_shadow_rtlight_numfrustumplanes;
- r_shadow_rtlight_numfrustumplanes = 0;
+ VectorSet(points[0], rsurface.rtlight_cullmins[0], rsurface.rtlight_cullmins[1], rsurface.rtlight_cullmins[2]);
+ VectorSet(points[1], rsurface.rtlight_cullmaxs[0], rsurface.rtlight_cullmins[1], rsurface.rtlight_cullmins[2]);
+ VectorSet(points[2], rsurface.rtlight_cullmins[0], rsurface.rtlight_cullmaxs[1], rsurface.rtlight_cullmins[2]);
+ VectorSet(points[3], rsurface.rtlight_cullmaxs[0], rsurface.rtlight_cullmaxs[1], rsurface.rtlight_cullmins[2]);
+ VectorSet(points[4], rsurface.rtlight_cullmins[0], rsurface.rtlight_cullmins[1], rsurface.rtlight_cullmaxs[2]);
+ VectorSet(points[5], rsurface.rtlight_cullmaxs[0], rsurface.rtlight_cullmins[1], rsurface.rtlight_cullmaxs[2]);
+ VectorSet(points[6], rsurface.rtlight_cullmins[0], rsurface.rtlight_cullmaxs[1], rsurface.rtlight_cullmaxs[2]);
+ VectorSet(points[7], rsurface.rtlight_cullmaxs[0], rsurface.rtlight_cullmaxs[1], rsurface.rtlight_cullmaxs[2]);
+ oldnum = rsurface.rtlight_numfrustumplanes;
+ rsurface.rtlight_numfrustumplanes = 0;
for (j = 0;j < oldnum;j++)
{
// find the nearest point on the box to this plane
- bestdist = DotProduct(r_shadow_rtlight_frustumplanes[j].normal, points[0]);
+ bestdist = DotProduct(rsurface.rtlight_frustumplanes[j].normal, points[0]);
for (i = 1;i < 8;i++)
{
- dist = DotProduct(r_shadow_rtlight_frustumplanes[j].normal, points[i]);
+ dist = DotProduct(rsurface.rtlight_frustumplanes[j].normal, points[i]);
if (bestdist > dist)
bestdist = dist;
}
- Con_Printf("light %p %splane #%i %f %f %f : %f < %f\n", rtlight, r_shadow_rtlight_frustumplanes[j].dist < bestdist + 0.03125 ? "^2" : "^1", j, r_shadow_rtlight_frustumplanes[j].normal[0], r_shadow_rtlight_frustumplanes[j].normal[1], r_shadow_rtlight_frustumplanes[j].normal[2], r_shadow_rtlight_frustumplanes[j].dist, bestdist);
+ Con_Printf("light %p %splane #%i %f %f %f : %f < %f\n", rtlight, rsurface.rtlight_frustumplanes[j].dist < bestdist + 0.03125 ? "^2" : "^1", j, rsurface.rtlight_frustumplanes[j].normal[0], rsurface.rtlight_frustumplanes[j].normal[1], rsurface.rtlight_frustumplanes[j].normal[2], rsurface.rtlight_frustumplanes[j].dist, bestdist);
// if the nearest point is near or behind the plane, we want this
// plane, otherwise the plane is useless as it won't cull anything
- if (r_shadow_rtlight_frustumplanes[j].dist < bestdist + 0.03125)
+ if (rsurface.rtlight_frustumplanes[j].dist < bestdist + 0.03125)
{
- PlaneClassify(&r_shadow_rtlight_frustumplanes[j]);
- r_shadow_rtlight_frustumplanes[r_shadow_rtlight_numfrustumplanes++] = r_shadow_rtlight_frustumplanes[j];
+ PlaneClassify(&rsurface.rtlight_frustumplanes[j]);
+ rsurface.rtlight_frustumplanes[rsurface.rtlight_numfrustumplanes++] = rsurface.rtlight_frustumplanes[j];
}
}
}
void R_Shadow_DrawWorldShadow(int numsurfaces, int *surfacelist, const unsigned char *trispvs)
{
RSurf_ActiveWorldEntity();
- if (r_shadow_rtlight->compiled && r_shadow_realtime_world_compile.integer && r_shadow_realtime_world_compileshadow.integer)
+ if (rsurface.rtlight->compiled && r_shadow_realtime_world_compile.integer && r_shadow_realtime_world_compileshadow.integer)
{
shadowmesh_t *mesh;
CHECKGLERROR
- for (mesh = r_shadow_rtlight->static_meshchain_shadow;mesh;mesh = mesh->next)
+ for (mesh = rsurface.rtlight->static_meshchain_shadow;mesh;mesh = mesh->next)
{
r_refdef.stats.lights_shadowtriangles += mesh->numtriangles;
R_Mesh_VertexPointer(mesh->vertex3f, mesh->vbo, mesh->vbooffset_vertex3f);
if (CHECKPVSBIT(trispvs, t))
shadowmarklist[numshadowmark++] = t;
}
- R_Shadow_VolumeFromList(r_refdef.worldmodel->brush.shadowmesh->numverts, r_refdef.worldmodel->brush.shadowmesh->numtriangles, r_refdef.worldmodel->brush.shadowmesh->vertex3f, r_refdef.worldmodel->brush.shadowmesh->element3i, r_refdef.worldmodel->brush.shadowmesh->neighbor3i, r_shadow_rtlight->shadoworigin, NULL, r_shadow_rtlight->radius + r_refdef.worldmodel->radius*2 + r_shadow_projectdistance.value, numshadowmark, shadowmarklist);
+ R_Shadow_VolumeFromList(r_refdef.worldmodel->brush.shadowmesh->numverts, r_refdef.worldmodel->brush.shadowmesh->numtriangles, r_refdef.worldmodel->brush.shadowmesh->vertex3f, r_refdef.worldmodel->brush.shadowmesh->element3i, r_refdef.worldmodel->brush.shadowmesh->neighbor3i, rsurface.rtlight->shadoworigin, NULL, rsurface.rtlight->radius + r_refdef.worldmodel->radius*2 + r_shadow_projectdistance.value, numshadowmark, shadowmarklist);
}
else if (numsurfaces)
- r_refdef.worldmodel->DrawShadowVolume(r_refdef.worldentity, r_shadow_rtlight->shadoworigin, NULL, r_shadow_rtlight->radius, numsurfaces, surfacelist, r_shadow_rtlight_cullmins, r_shadow_rtlight_cullmaxs);
+ r_refdef.worldmodel->DrawShadowVolume(r_refdef.worldentity, rsurface.rtlight->shadoworigin, NULL, rsurface.rtlight->radius, numsurfaces, surfacelist, rsurface.rtlight_cullmins, rsurface.rtlight_cullmaxs);
}
void R_Shadow_DrawEntityShadow(entity_render_t *ent)
vec3_t relativeshadoworigin, relativeshadowmins, relativeshadowmaxs;
vec_t relativeshadowradius;
RSurf_ActiveModelEntity(ent, false, false);
- Matrix4x4_Transform(&ent->inversematrix, r_shadow_rtlight->shadoworigin, relativeshadoworigin);
- relativeshadowradius = r_shadow_rtlight->radius / ent->scale;
+ Matrix4x4_Transform(&ent->inversematrix, rsurface.rtlight->shadoworigin, relativeshadoworigin);
+ relativeshadowradius = rsurface.rtlight->radius / ent->scale;
relativeshadowmins[0] = relativeshadoworigin[0] - relativeshadowradius;
relativeshadowmins[1] = relativeshadoworigin[1] - relativeshadowradius;
relativeshadowmins[2] = relativeshadoworigin[2] - relativeshadowradius;
{
// set up properties for rendering light onto this entity
RSurf_ActiveModelEntity(ent, true, true);
- Matrix4x4_Concat(&r_shadow_entitytolight, &r_shadow_rtlight->matrix_worldtolight, &ent->matrix);
- Matrix4x4_Concat(&r_shadow_entitytoattenuationxyz, &matrix_attenuationxyz, &r_shadow_entitytolight);
- Matrix4x4_Concat(&r_shadow_entitytoattenuationz, &matrix_attenuationz, &r_shadow_entitytolight);
- Matrix4x4_Transform(&ent->inversematrix, r_shadow_rtlight->shadoworigin, r_shadow_entitylightorigin);
+ Matrix4x4_Concat(&rsurface.entitytolight, &rsurface.rtlight->matrix_worldtolight, &ent->matrix);
+ Matrix4x4_Concat(&rsurface.entitytoattenuationxyz, &matrix_attenuationxyz, &rsurface.entitytolight);
+ Matrix4x4_Concat(&rsurface.entitytoattenuationz, &matrix_attenuationz, &rsurface.entitytolight);
+ Matrix4x4_Transform(&ent->inversematrix, rsurface.rtlight->shadoworigin, rsurface.entitylightorigin);
if (r_shadow_lightingrendermode == R_SHADOW_RENDERMODE_LIGHT_GLSL)
- R_Mesh_TexMatrix(3, &r_shadow_entitytolight);
+ R_Mesh_TexMatrix(3, &rsurface.entitytolight);
}
void R_Shadow_DrawWorldLight(int numsurfaces, int *surfacelist, const unsigned char *trispvs)
// set up properties for rendering light onto this entity
RSurf_ActiveWorldEntity();
- r_shadow_entitytolight = r_shadow_rtlight->matrix_worldtolight;
- Matrix4x4_Concat(&r_shadow_entitytoattenuationxyz, &matrix_attenuationxyz, &r_shadow_entitytolight);
- Matrix4x4_Concat(&r_shadow_entitytoattenuationz, &matrix_attenuationz, &r_shadow_entitytolight);
- VectorCopy(r_shadow_rtlight->shadoworigin, r_shadow_entitylightorigin);
+ rsurface.entitytolight = rsurface.rtlight->matrix_worldtolight;
+ Matrix4x4_Concat(&rsurface.entitytoattenuationxyz, &matrix_attenuationxyz, &rsurface.entitytolight);
+ Matrix4x4_Concat(&rsurface.entitytoattenuationz, &matrix_attenuationz, &rsurface.entitytolight);
+ VectorCopy(rsurface.rtlight->shadoworigin, rsurface.entitylightorigin);
if (r_shadow_lightingrendermode == R_SHADOW_RENDERMODE_LIGHT_GLSL)
- R_Mesh_TexMatrix(3, &r_shadow_entitytolight);
+ R_Mesh_TexMatrix(3, &rsurface.entitytolight);
r_refdef.worldmodel->DrawLight(r_refdef.worldentity, numsurfaces, surfacelist, trispvs);
}
if (R_CullBox(rtlight->cullmins, rtlight->cullmaxs))
return;
- VectorCopy(rtlight->cullmins, r_shadow_rtlight_cullmins);
- VectorCopy(rtlight->cullmaxs, r_shadow_rtlight_cullmaxs);
+ VectorCopy(rtlight->cullmins, rsurface.rtlight_cullmins);
+ VectorCopy(rtlight->cullmaxs, rsurface.rtlight_cullmaxs);
if (rtlight->compiled && r_shadow_realtime_world_compile.integer)
{
// dynamic light, world available and can receive realtime lighting
// calculate lit surfaces and leafs
R_Shadow_EnlargeLeafSurfaceTrisBuffer(r_refdef.worldmodel->brush.num_leafs, r_refdef.worldmodel->num_surfaces, r_refdef.worldmodel->brush.shadowmesh ? r_refdef.worldmodel->brush.shadowmesh->numtriangles : r_refdef.worldmodel->surfmesh.num_triangles, r_refdef.worldmodel->surfmesh.num_triangles);
- r_refdef.worldmodel->GetLightInfo(r_refdef.worldentity, rtlight->shadoworigin, rtlight->radius, r_shadow_rtlight_cullmins, r_shadow_rtlight_cullmaxs, r_shadow_buffer_leaflist, r_shadow_buffer_leafpvs, &numleafs, r_shadow_buffer_surfacelist, r_shadow_buffer_surfacepvs, &numsurfaces, r_shadow_buffer_shadowtrispvs, r_shadow_buffer_lighttrispvs);
+ r_refdef.worldmodel->GetLightInfo(r_refdef.worldentity, rtlight->shadoworigin, rtlight->radius, rsurface.rtlight_cullmins, rsurface.rtlight_cullmaxs, r_shadow_buffer_leaflist, r_shadow_buffer_leafpvs, &numleafs, r_shadow_buffer_surfacelist, r_shadow_buffer_surfacepvs, &numsurfaces, r_shadow_buffer_shadowtrispvs, r_shadow_buffer_lighttrispvs);
leaflist = r_shadow_buffer_leaflist;
leafpvs = r_shadow_buffer_leafpvs;
surfacelist = r_shadow_buffer_surfacelist;
shadowtrispvs = r_shadow_buffer_shadowtrispvs;
lighttrispvs = r_shadow_buffer_lighttrispvs;
// if the reduced leaf bounds are offscreen, skip it
- if (R_CullBox(r_shadow_rtlight_cullmins, r_shadow_rtlight_cullmaxs))
+ if (R_CullBox(rsurface.rtlight_cullmins, rsurface.rtlight_cullmaxs))
return;
}
else
return;
}
// set up a scissor rectangle for this light
- if (R_Shadow_ScissorForBBox(r_shadow_rtlight_cullmins, r_shadow_rtlight_cullmaxs))
+ if (R_Shadow_ScissorForBBox(rsurface.rtlight_cullmins, rsurface.rtlight_cullmaxs))
return;
R_Shadow_ComputeShadowCasterCullingPlanes(rtlight);
model_t *model;
entity_render_t *ent = r_refdef.entities[i];
vec3_t org;
- if (!BoxesOverlap(ent->mins, ent->maxs, r_shadow_rtlight_cullmins, r_shadow_rtlight_cullmaxs))
+ if (!BoxesOverlap(ent->mins, ent->maxs, rsurface.rtlight_cullmins, rsurface.rtlight_cullmaxs))
continue;
// skip the object entirely if it is not within the valid
// shadow-casting region (which includes the lit region)
- if (R_CullBoxCustomPlanes(ent->mins, ent->maxs, r_shadow_rtlight_numfrustumplanes, r_shadow_rtlight_frustumplanes))
+ if (R_CullBoxCustomPlanes(ent->mins, ent->maxs, rsurface.rtlight_numfrustumplanes, rsurface.rtlight_frustumplanes))
continue;
if (!(model = ent->model))
continue;