mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 15:50:20 +00:00
Add shadow toggle (F4) and distance-based WMO group culling
Shadow toggle allows disabling shadow pass for performance testing. Distance culling skips WMO groups beyond 200 units. Occlusion queries disabled by default as overhead outweighs benefits in dense scenes.
This commit is contained in:
parent
83ef27c570
commit
ebf349ec7c
5 changed files with 29 additions and 11 deletions
|
|
@ -1039,8 +1039,14 @@ void Renderer::renderWorld(game::World* world) {
|
|||
lastM2RenderMs = 0.0;
|
||||
|
||||
// Shadow pass (before main scene)
|
||||
if (shadowFBO && shadowShaderProgram && terrainLoaded) {
|
||||
if (shadowsEnabled && shadowFBO && shadowShaderProgram && terrainLoaded) {
|
||||
renderShadowPass();
|
||||
} else {
|
||||
// Clear shadow maps when disabled
|
||||
if (terrainRenderer) terrainRenderer->clearShadowMap();
|
||||
if (wmoRenderer) wmoRenderer->clearShadowMap();
|
||||
if (m2Renderer) m2Renderer->clearShadowMap();
|
||||
if (characterRenderer) characterRenderer->clearShadowMap();
|
||||
}
|
||||
|
||||
// Bind HDR scene framebuffer for world rendering
|
||||
|
|
|
|||
|
|
@ -645,7 +645,7 @@ void WMORenderer::render(const Camera& camera, const glm::mat4& view, const glm:
|
|||
continue;
|
||||
}
|
||||
|
||||
// Occlusion culling check (uses previous frame results)
|
||||
// Occlusion culling check first (uses previous frame results)
|
||||
if (occlusionCulling && isGroupOccluded(instance.id, static_cast<uint32_t>(gi))) {
|
||||
lastOcclusionCulledGroups++;
|
||||
continue;
|
||||
|
|
@ -654,14 +654,12 @@ void WMORenderer::render(const Camera& camera, const glm::mat4& view, const glm:
|
|||
if (gi < instance.worldGroupBounds.size()) {
|
||||
const auto& [gMin, gMax] = instance.worldGroupBounds[gi];
|
||||
|
||||
// Distance culling: skip groups whose center is too far
|
||||
if (distanceCulling) {
|
||||
glm::vec3 groupCenter = (gMin + gMax) * 0.5f;
|
||||
float distSq = glm::dot(groupCenter - camPos, groupCenter - camPos);
|
||||
if (distSq > maxGroupDistanceSq) {
|
||||
lastDistanceCulledGroups++;
|
||||
continue;
|
||||
}
|
||||
// Hard distance cutoff - skip groups entirely if closest point is too far
|
||||
glm::vec3 closestPoint = glm::clamp(camPos, gMin, gMax);
|
||||
float distSq = glm::dot(closestPoint - camPos, closestPoint - camPos);
|
||||
if (distSq > 40000.0f) { // Beyond 200 units - hard skip
|
||||
lastDistanceCulledGroups++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Frustum culling
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue