// called with a batch, so numsurfaces is always 1, and the surfacelist
// contains only a leaf number for coloring purposes
const mportal_t *portal = (mportal_t *)ent;
+ qboolean isvis;
int i, numpoints;
float *v;
float vertex3f[POLYGONELEMENTS_MAXPOINTS*3];
R_Mesh_ResetTextureState();
R_SetupGenericShader(false);
- i = surfacelist[0];
+ isvis = (portal->here->clusterindex >= 0 && portal->past->clusterindex >= 0 && portal->here->clusterindex != portal->past->clusterindex);
+
+ i = surfacelist[0] >> 1;
GL_Color(((i & 0x0007) >> 0) * (1.0f / 7.0f) * r_refdef.view.colorscale,
((i & 0x0038) >> 3) * (1.0f / 7.0f) * r_refdef.view.colorscale,
((i & 0x01C0) >> 6) * (1.0f / 7.0f) * r_refdef.view.colorscale,
- 0.125f);
+ isvis ? 0.125f : 0.03125f);
for (i = 0, v = vertex3f;i < numpoints;i++, v += 3)
VectorCopy(portal->points[i].position, v);
R_Mesh_Draw(0, numpoints, 0, numpoints - 2, NULL, polygonelements, 0, 0);
R_Water_AddWaterPlane(surfaces + j);
}
}
+ rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity
}
void R_Q1BSP_Draw(entity_render_t *ent)
// optionally using svbsp for exact culling of compiled lights
// (or if the user enables dlight svbsp culling, which is mostly for
// debugging not actual use)
- R_Q1BSP_CallRecursiveGetLightInfo(&info, r_shadow_compilingrtlight ? r_shadow_realtime_world_compilesvbsp.integer : r_shadow_realtime_dlight_svbspculling.integer);
+ R_Q1BSP_CallRecursiveGetLightInfo(&info, (r_shadow_compilingrtlight ? r_shadow_realtime_world_compilesvbsp.integer : r_shadow_realtime_dlight_svbspculling.integer) != 0);
}
+ rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity
+
// limit combined leaf box to light boundaries
outmins[0] = max(info.outmins[0] - 1, info.lightmins[0]);
outmins[1] = max(info.outmins[1] - 1, info.lightmins[1]);
GL_PolygonOffset(r_refdef.shadowpolygonfactor, r_refdef.shadowpolygonoffset);
}
+void R_Q1BSP_DrawShadowMap(entity_render_t *ent, const vec3_t relativelightorigin, const vec3_t relativelightdirection, float lightradius, int modelnumsurfaces, const int *modelsurfacelist, const vec3_t lightmins, const vec3_t lightmaxs)
+{
+ dp_model_t *model = ent->model;
+ msurface_t *surface;
+ int modelsurfacelistindex;
+ float projectdistance = relativelightdirection ? lightradius : lightradius + model->radius*2 + r_shadow_projectdistance.value;
+ // check the box in modelspace, it was already checked in worldspace
+ if (!BoxesOverlap(model->normalmins, model->normalmaxs, lightmins, lightmaxs))
+ return;
+ if (model->brush.shadowmesh)
+ {
+ R_Shadow_PrepareShadowMark(model->brush.shadowmesh->numtriangles);
+ for (modelsurfacelistindex = 0;modelsurfacelistindex < modelnumsurfaces;modelsurfacelistindex++)
+ {
+ surface = model->data_surfaces + modelsurfacelist[modelsurfacelistindex];
+ if (R_GetCurrentTexture(surface->texture)->currentmaterialflags & MATERIALFLAG_NOSHADOW)
+ continue;
+ R_Shadow_MarkVolumeFromBox(surface->num_firstshadowmeshtriangle, surface->num_triangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, relativelightorigin, relativelightdirection, lightmins, lightmaxs, surface->mins, surface->maxs);
+ }
+ R_Shadow_ShadowMapFromList(model->brush.shadowmesh->numverts, model->brush.shadowmesh->numtriangles, model->brush.shadowmesh->vertex3f, 0, 0, model->brush.shadowmesh->element3i, numshadowmark, shadowmarklist);
+ }
+ else
+ {
+ projectdistance = lightradius + model->radius*2;
+ R_Shadow_PrepareShadowMark(model->surfmesh.num_triangles);
+ // identify lit faces within the bounding box
+ for (modelsurfacelistindex = 0;modelsurfacelistindex < modelnumsurfaces;modelsurfacelistindex++)
+ {
+ surface = model->data_surfaces + modelsurfacelist[modelsurfacelistindex];
+ rsurface.texture = R_GetCurrentTexture(surface->texture);
+ if (rsurface.texture->currentmaterialflags & MATERIALFLAG_NOSHADOW)
+ continue;
+ RSurf_PrepareVerticesForBatch(false, false, 1, &surface);
+ R_Shadow_MarkVolumeFromBox(surface->num_firsttriangle, surface->num_triangles, rsurface.vertex3f, rsurface.modelelement3i, relativelightorigin, relativelightdirection, lightmins, lightmaxs, surface->mins, surface->maxs);
+ }
+ R_Shadow_ShadowMapFromList(model->surfmesh.num_vertices, model->surfmesh.num_triangles, rsurface.vertex3f, rsurface.vertex3f_bufferobject, rsurface.vertex3f_bufferoffset, model->surfmesh.data_element3i, numshadowmark, shadowmarklist);
+ }
+}
+
#define BATCHSIZE 1024
static void R_Q1BSP_DrawLight_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
// note: in practice this never actually receives batches), oh well
R_Shadow_RenderMode_Begin();
R_Shadow_RenderMode_ActiveLight(rtlight);
- R_Shadow_RenderMode_Lighting(false, true);
+ R_Shadow_RenderMode_Lighting(false, true, false);
R_Shadow_SetupEntityLight(ent);
for (i = 0;i < numsurfaces;i = j)
{