Closed JeodC closed 2 months ago
It's unclear to me without diving in the rendering code why decreasing the maximum number of horizon pieces increases the render distance. What happens there?
It's unclear to me without diving in the rendering code why decreasing the maximum number of horizon pieces increases the render distance. What happens there?
The horizon distance change has nothing to do with the render distance. In the current terrain.h
file though it looks like this:
// Sky defines
#define MAX_STARS 600 // how many stars in our sky
#define MAX_SATELLITES 5 // max satellites in our sky
#define MAX_HORIZON_PIECES \
16 // how many segments of the horizon
// there are around our sphere
The change just brings it inline like the rest. I'm not sure if it was broken or not, with the random backslash after a ton of spaces, but it was inconsistent.
I was talking about the MAX_CELLS_TO_RENDER
change, sorry. The other change is fine.
I was talking about the
MAX_CELLS_TO_RENDER
change, sorry. The other change is fine.
It's an increase, not a decrease. Original value was 8000, and in TerrainSearch.cpp
:
if (*ccount >= MAX_CELLS_TO_RENDER) {
mprintf((0, "Trying to render too many cells! Cell limit=%d\n", MAX_CELLS_TO_RENDER));
#ifndef NEWEDITOR
Detail_settings.Terrain_render_distance = 80.0 * TERRAIN_SIZE;
#endif
return;
}
That's within the CheckCellOccupancy
function. If it evaluates to true, it stops rendering the terrain cells. If it's false, terrain gets rendered. The problem is that if it does evaluate to true, the game's render depth setting gets reset to 40--even if the player had it at 100. The solution to the issue is to increase the MAX_CELLS_TO_RENDER
variable--it's unclear why it was set to such a low value in the first place. The alternative is to comment out this safety check entirely, which would allow excessive rendering and potential stability issues.
It's also used in static ushort LOD_sort_bucket[MAX_TERRAIN_LOD][MAX_CELLS_TO_RENDER];
-- increasing the value increases the capacity of this array, which lets it store more cells for rendering.
Here's a screenshot of the same level from the retail edition:
Thanks for the clear explanation!
Pull Request Type
Description
Bump max cells to 32678 from 8000, allowing a much larger render distance for outdoor terrain. This commit also fixes MAX_HORIZON_PIECES, which may have been broken during a clang-format.
Testing on Level 7 yielded no performance loss, and in fact revealed an existing bug with z-ranges where blue electricity effects from disabled turrets are visible overtop of terrain.
Related Issues
Fixes #280