mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-06-06 07:04:43 -04:00
Add shadow frustum culling to terrain and M2 depth passes
Both passes were rendering the entire loaded scene (17×17 tile radius) into a shadow map that only covers 360×360 world units — submitting 10-50× more geometry than the shadow frustum can actually use. - TerrainRenderer::renderShadow: skip chunks whose bounding sphere doesn't overlap the shadow frustum AABB in XY. Reduces terrain draw calls from O(all loaded chunks) to O(chunks within ~180 units). - M2Renderer::renderShadow: skip instances whose world AABB doesn't overlap the shadow frustum in XY. Reduces M2 draw calls similarly. - Both functions now take shadowCenter + halfExtent parameters.
This commit is contained in:
@@ -3444,9 +3444,10 @@ void Renderer::renderShadowPass() {
|
||||
if (useBonesLoc >= 0) glUniform1i(useBonesLoc, 0);
|
||||
if (texLoc >= 0) glUniform1i(texLoc, 0);
|
||||
|
||||
// Render terrain into shadow map
|
||||
// Render terrain into shadow map (only chunks within shadow frustum)
|
||||
if (terrainRenderer) {
|
||||
terrainRenderer->renderShadow(shadowShaderProgram);
|
||||
glm::vec3 shadowCtr = shadowCenterInitialized ? shadowCenter : characterPosition;
|
||||
terrainRenderer->renderShadow(shadowShaderProgram, shadowCtr, kShadowHalfExtent);
|
||||
}
|
||||
|
||||
// Render WMO into shadow map
|
||||
@@ -3476,9 +3477,10 @@ void Renderer::renderShadowPass() {
|
||||
shadowShaderWrapper.releaseProgram(); // Don't let wrapper delete our program
|
||||
}
|
||||
|
||||
// Render M2 doodads into shadow map
|
||||
// Render M2 doodads into shadow map (only instances within shadow frustum)
|
||||
if (m2Renderer) {
|
||||
m2Renderer->renderShadow(shadowShaderProgram);
|
||||
glm::vec3 shadowCtr = shadowCenterInitialized ? shadowCenter : characterPosition;
|
||||
m2Renderer->renderShadow(shadowShaderProgram, shadowCtr, kShadowHalfExtent);
|
||||
}
|
||||
|
||||
// Render characters into shadow map
|
||||
|
||||
Reference in New Issue
Block a user