X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=gl_rsurf.c;h=867a82b22926ad7a301ff46c345c934a77b88111;hb=d5280b22384f55bb0e346984727eb5674991d21b;hp=b3557b55702379eceb151c18c9f1bef4b55985d9;hpb=7a001bd650455489c03aa3ec81471774a36ab4fb;p=xonotic%2Fdarkplaces.git diff --git a/gl_rsurf.c b/gl_rsurf.c index b3557b55..867a82b2 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -335,6 +335,7 @@ static void R_DrawPortal_Callback(const entity_render_t *ent, const rtlight_t *r // 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]; @@ -354,11 +355,13 @@ static void R_DrawPortal_Callback(const entity_render_t *ent, const rtlight_t *r 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); @@ -580,6 +583,7 @@ void R_Q1BSP_DrawAddWaterPlanes(entity_render_t *ent) 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) @@ -974,9 +978,11 @@ void R_Q1BSP_GetLightInfo(entity_render_t *ent, vec3_t relativelightorigin, floa // 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]); @@ -1053,6 +1059,65 @@ void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, const vec3_t relativelightor GL_PolygonOffset(r_refdef.shadowpolygonfactor, r_refdef.shadowpolygonoffset); } +void R_Q1BSP_CompileShadowMap(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativelightdirection, float lightradius, int numsurfaces, const int *surfacelist) +{ + dp_model_t *model = ent->model; + msurface_t *surface; + int surfacelistindex; + int sidetotals[6] = { 0, 0, 0, 0, 0, 0 }; + r_shadow_compilingrtlight->static_meshchain_shadow_shadowmap = Mod_ShadowMesh_Begin(r_main_mempool, 32768, 32768, NULL, NULL, NULL, false, false, true); + R_Shadow_PrepareShadowSides(model->brush.shadowmesh->numtriangles); + for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++) + { + surface = model->data_surfaces + surfacelist[surfacelistindex]; + if (surface->texture->basematerialflags & MATERIALFLAG_NOSHADOW) + continue; + R_Shadow_ChooseSidesFromBox(surface->num_firstshadowmeshtriangle, surface->num_triangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, &r_shadow_compilingrtlight->matrix_worldtolight, relativelightorigin, relativelightdirection, r_shadow_compilingrtlight->cullmins, r_shadow_compilingrtlight->cullmaxs, surface->mins, surface->maxs, sidetotals); + } + R_Shadow_ShadowMapFromList(model->brush.shadowmesh->numverts, model->brush.shadowmesh->numtriangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, numshadowsides, sidetotals, shadowsides, shadowsideslist); + r_shadow_compilingrtlight->static_meshchain_shadow_shadowmap = Mod_ShadowMesh_Finish(r_main_mempool, r_shadow_compilingrtlight->static_meshchain_shadow_shadowmap, false, false, true); +} + +void R_Q1BSP_DrawShadowMap(int side, 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, *batch[64]; + int modelsurfacelistindex, batchsize; + // check the box in modelspace, it was already checked in worldspace + if (!BoxesOverlap(model->normalmins, model->normalmaxs, lightmins, lightmaxs)) + return; + // 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; + if(!BoxesOverlap(lightmins, lightmaxs, surface->mins, surface->maxs)) + continue; + r_refdef.stats.lights_dynamicshadowtriangles += surface->num_triangles; + r_refdef.stats.lights_shadowtriangles += surface->num_triangles; + batch[0] = surface; + batchsize = 1; + while(++modelsurfacelistindex < modelnumsurfaces && batchsize < (int)(sizeof(batch)/sizeof(batch[0]))) + { + surface = model->data_surfaces + modelsurfacelist[modelsurfacelistindex]; + if(surface->texture != batch[0]->texture) + break; + if(!BoxesOverlap(lightmins, lightmaxs, surface->mins, surface->maxs)) + continue; + r_refdef.stats.lights_dynamicshadowtriangles += surface->num_triangles; + r_refdef.stats.lights_shadowtriangles += surface->num_triangles; + batch[batchsize++] = surface; + } + --modelsurfacelistindex; + GL_CullFace(rsurface.texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE ? GL_NONE : r_refdef.view.cullface_back); + RSurf_PrepareVerticesForBatch(false, false, batchsize, batch); + RSurf_DrawBatch_Simple(batchsize, batch); + GL_LockArrays(0, 0); + } +} + #define BATCHSIZE 1024 static void R_Q1BSP_DrawLight_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist) @@ -1063,7 +1128,7 @@ static void R_Q1BSP_DrawLight_TransparentCallback(const entity_render_t *ent, co // 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) {