Revert "batch together traces on the whole surface - saves a small amount of time"

This reverts commit 72611b7e97.

# Conflicts:
#	light/ltface.cc
This commit is contained in:
Jonathan 2024-03-13 01:23:51 -04:00
parent 3356b5776e
commit d006ac730a
1 changed files with 39 additions and 40 deletions

View File

@ -2026,9 +2026,9 @@ LightFace_SurfaceLight(const mbsp_t *bsp, lightsurf_t *lightsurf, lightmapdict_t
raystream_occlusion_t &rs = occlusion_stream;
rs.clearPushedRays();
for (int c = 0; c < vpl.points.size(); c++) {
rs.clearPushedRays();
for (int i = 0; i < lightsurf->samples.size(); i++) {
const auto &sample = lightsurf->samples[i];
@ -2059,50 +2059,49 @@ LightFace_SurfaceLight(const mbsp_t *bsp, lightsurf_t *lightsurf, lightmapdict_t
rs.pushRay(i, pos, dir, dist, &indirect);
}
}
}
if (!rs.numPushedRays())
continue;
rs.tracePushedRaysOcclusion(lightsurf->modelinfo, CHANNEL_MASK_DEFAULT);
#if 0
total_surflight_rays += rs.numPushedRays();
#endif
const int lightmapstyle = vpl_setting.style;
lightmap_t *lightmap = Lightmap_ForStyle(lightmaps, lightmapstyle, lightsurf);
bool hit = false;
const int numrays = rs.numPushedRays();
for (int j = 0; j < numrays; j++) {
if (rs.getPushedRayOccluded(j))
if (!rs.numPushedRays())
continue;
const ray_io &ray = rs.getRay(j);
const int i = ray.index;
qvec3f indirect = rs.getPushedRayColor(j);
//Q_assert(!std::isnan(indirect[0]));
// Use dirt scaling on the surface lighting.
const float dirtscale =
Dirt_GetScaleFactor(cfg, lightsurf->samples[i].occlusion, nullptr, 0.0, lightsurf);
indirect *= dirtscale;
lightsample_t &sample = lightmap->samples[i];
sample.color += indirect;
lightmap->bounce_color += indirect;
hit = true;
#if 0
++total_surflight_ray_hits;
total_surflight_rays += rs.numPushedRays();
#endif
}
rs.tracePushedRaysOcclusion(lightsurf->modelinfo, CHANNEL_MASK_DEFAULT);
// If surface light contributed anything, save.
if (hit)
Lightmap_Save(bsp, lightmaps, lightsurf, lightmap, lightmapstyle);
const int lightmapstyle = vpl_setting.style;
lightmap_t *lightmap = Lightmap_ForStyle(lightmaps, lightmapstyle, lightsurf);
bool hit = false;
const int numrays = rs.numPushedRays();
for (int j = 0; j < numrays; j++) {
if (rs.getPushedRayOccluded(j))
continue;
const ray_io &ray = rs.getRay(j);
const int i = ray.index;
qvec3f indirect = rs.getPushedRayColor(j);
//Q_assert(!std::isnan(indirect[0]));
// Use dirt scaling on the surface lighting.
const float dirtscale =
Dirt_GetScaleFactor(cfg, lightsurf->samples[i].occlusion, nullptr, 0.0, lightsurf);
indirect *= dirtscale;
lightsample_t &sample = lightmap->samples[i];
sample.color += indirect;
lightmap->bounce_color += indirect;
hit = true;
#if 0
++total_surflight_ray_hits;
#endif
}
// If surface light contributed anything, save.
if (hit)
Lightmap_Save(bsp, lightmaps, lightsurf, lightmap, lightmapstyle);
}
}
}
}