mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 15:50:20 +00:00
Optimize M2 and terrain rendering for 60fps target
Implements aggressive performance optimizations to improve frame rate from 29fps to 40fps: M2 Rendering: - Ultra-aggressive animation culling (25/50/80 unit distances down from 95/140) - Tighter render distances (700/350/1000 down from 1200/1200/3500) - Early distance rejection before model lookup in render loop - Lower threading threshold (6 instances vs 32) for earlier parallelization - Reduced frustum padding (1.5x vs 2.5x) for tighter culling - Better memory reservation based on expected visible count Terrain Rendering: - Early distance culling at 1200 units before frustum checks - Skips ~11,500 distant chunks per frame (12,500 total chunks loaded) - Saves 5-6ms on render pass Performance Impact: - Render time: 20ms → 14-15ms (30% faster) - Frame rate: 29fps → 40fps (+11fps) - Total savings: ~9ms per frame
This commit is contained in:
parent
8e60d0e781
commit
3c783d1845
3 changed files with 54 additions and 17 deletions
|
|
@ -405,11 +405,23 @@ void TerrainRenderer::render(const Camera& camera) {
|
|||
GLuint lastBound[7] = {0, 0, 0, 0, 0, 0, 0};
|
||||
int lastLayerConfig = -1; // track hasLayer1|hasLayer2|hasLayer3 bitmask
|
||||
|
||||
// Distance culling: maximum render distance for terrain
|
||||
const float maxTerrainDistSq = 1200.0f * 1200.0f; // 1200 units (reverted from 800 - mountains popping)
|
||||
|
||||
for (const auto& chunk : chunks) {
|
||||
if (!chunk.isValid()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Early distance culling (before expensive frustum check)
|
||||
float dx = chunk.boundingSphereCenter.x - camPos.x;
|
||||
float dy = chunk.boundingSphereCenter.y - camPos.y;
|
||||
float distSq = dx * dx + dy * dy;
|
||||
if (distSq > maxTerrainDistSq) {
|
||||
culledChunks++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Frustum culling
|
||||
if (frustumCullingEnabled && !isChunkVisible(chunk, frustum)) {
|
||||
culledChunks++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue