Very simple question for the devs., as I cannot seem to find where this is being done in the source: how is culling being performed?
My practical tests have indicated that unit geometry does not seem to be being culled from each render cycle, even if they are off-screen. I have done some other tests, and it appears that map geometry may also not be being efficiently culled.
Culling the polygons that aren't in the viewport, or are X distance away (to preserve unit shadows) is a standard sort've optimization. I assume that either things are getting culled, but there's something else going on that's still requiring rendering the whole thing, or that it's not getting culled at all. The map thing really bugs me- it appears that maps just aren't getting culled, period, to preserve the map shadows. Surely those shadows could just be stored as several grayscale bitmaps and read in/out if the viewpoint has an angle on the sector? Just a thought- preserving the entire map geometry, for the sake of shadows, seems like a waste to me.
On a related topic, does map fog have any effect on culling, or is it just a visual effect?
Culling
Moderator: Moderators
Assuming you've looked good enough in the source and there isn't any CPU-based culling, the culling is probably done in OpenGL only.
gluPerspective() (in Main.cpp) sets znear and zfar values, IIRC the 3rd and 4th parameters. These are the absolute min and max Z values which will be visible (with Z being distance into screen).
If there really is no CPU based culling, then that may be a point of optimization for some version sometime.
E:
oh, and map fog is just a visual thing.
E2:
culling by polygons is something which should be left to OpenGL to do - only culling entire units would be a good optimization. Doesn't some quadtree thingie in spring already do this? Or is that just for selection?
gluPerspective() (in Main.cpp) sets znear and zfar values, IIRC the 3rd and 4th parameters. These are the absolute min and max Z values which will be visible (with Z being distance into screen).
If there really is no CPU based culling, then that may be a point of optimization for some version sometime.
E:
oh, and map fog is just a visual thing.
E2:
culling by polygons is something which should be left to OpenGL to do - only culling entire units would be a good optimization. Doesn't some quadtree thingie in spring already do this? Or is that just for selection?
This is what happens in version 0.70b3:
- for units, the code iterates through all the units and checks them against the camera frustum.
- for features, grass, symbol drawing in map, and pieces of map itself, the game area is seen as a grid of a particular block size. From the camera properties it is calculated which part of the grid is visible. This causes problems with large features, because they are supposed to be on one grid block only IIRC.
For the new map system I will make sure that large features are handled correctly.
Possibly some changes will happen to the current map system as well, but that's not really my goal.
I doubt that performance for rendering lot of features will increase a lot by optimizing the culling. However empty areas currently also cost CPU time, so that can improve. I'm restructuring that part of the code for the new map system anyway, so we'll see where it ends.
- for units, the code iterates through all the units and checks them against the camera frustum.
- for features, grass, symbol drawing in map, and pieces of map itself, the game area is seen as a grid of a particular block size. From the camera properties it is calculated which part of the grid is visible. This causes problems with large features, because they are supposed to be on one grid block only IIRC.
For the new map system I will make sure that large features are handled correctly.
Possibly some changes will happen to the current map system as well, but that's not really my goal.
I doubt that performance for rendering lot of features will increase a lot by optimizing the culling. However empty areas currently also cost CPU time, so that can improve. I'm restructuring that part of the code for the new map system anyway, so we'll see where it ends.