SUMMARY
A while back I spent some time thinking about all of the things required to create an atmospheric snow map from a programming point of view. People are always quick to say the game is not optimized. This is just a small example of how much is going on in this engine. Hopefully it will let people give Relic a little break and help new mappers optimize their own snow maps. Maybe we can break the snow maps are terrible stigma.
TRIANGLES
Objects drawn in 3D are made up of TRIANGLES. Each vertex of the triangle requires complex math to rotate and scale it from a 3D world to the screens 2D coordinates. The more triangles the longer it will take to draw a scene. Example Quake 1 enemies were around 100 tris. You maybe had 1k to 3k triangles in a busy scene. Modern games, there are more like 100K+ tris per scene.
Here is a shot of the terrain for Angoville. There is no Snow. Notice how the terrain is cut up into 1M square (2 tris). This is very similar to the vCOH terrain.
Here is a shot of Vielsalm with snow. Where there is snow, Relic is drawing a much more dense triangle mesh in the Worldbuilder. More Tris = Slower FPS rotating and scaling the tris to the screen.
The extra snow tris are used for the snow, footprints, and tracks. Figuring out where to draw the prints and then actually doing it is another added calculation for snow and mud maps. Add to that calcs for when explosions occur and the snow gets deleted/removed.
So as a mapper, you do not want to paint snow everywhere on the map. Any place you do not need snow to leave foot prints or tracks, you should not paint snow there. Places like roads, open cobble stone areas, paths, etc.
Here is a snow depth photo of Novgorod Outskirts. The YELLOW areas are snow. The BLUE areas are roads etc and do not have any snow. Since this is a 1v1 map it may not make a big difference in performance. but for a large 4v4 map, it may just keep the FPS late game.
VIDEO CARD FILL RATE
A 3D object is drawn by filling in the triangles with a texture. Sometimes multiple textures per triangle (there are textures for color, specular lighting, depth, etc.).
When the card draws a triangle it has to:
- rotate and scale the triangle.
- interpolate down the edges of the triangle.
- Load several textures into the videocard cache memory.
- Interpolate across the triangle and textures.
- Check the Z buffer (see below).
- A shader program looks at the textures and calcs what the final pixel color will be depending on lighting, etc.
- If the pixel has transparency, the card has to go get the current pixel out of the frame buffer memory so the new pixel can be blended to it.
- Write the new pixel into the frame buffer(screen).
The speed it can access its memory and do all these calcs is generically its fill rate. How fast it can draw to the screen.
Z BUFFER
The key to speed is to never draw a pixel more than one time. Videocards use what is called a Z buffer. Every pixel that is drawn also has its Z axis distance stored in memory. Before the pixel is worked on, it is checked to see if it is in front of the last pixel drawn at this location. If it is behind the last pixel, it is skipped and a lot of time is saved. This calc is what you see when two objects are in the same space on the map and the pixels start dancing around where they overlap. You are seeing the lack of precision in the floating point numbers.
Depending on how Relic draws the terrain mesh they may only be drawing each pixel on the screen 2 - 3 times. Even thought there are a lot of triangles it still gets drawn pretty fast. I also guess that Relic breaks up the terrain into 32x32m chunks to aid object culling and texture memory but that is another topic.
SPRITES AND PARTICLES
Particles in COH2 are clouds of smoke, fire, sparks, dirt flying in the air from explosions, etc. A sprite is a square (2 tris) rotated to always face the viewer. So each thing of smoke and fire is a square drawn to the screen. These particles are Transparent which means they always get drawn and always have to access the frame buffer for blending.
In the example picture, a green cloud Action Marker is placed on the map. It constantly spews out sprites that start small and grow. Each pixel of the screen that has a cloud on it has to be redrawn for each cloud. You get 10-20 clouds overlapping each other, and now you are drawing the screen 20 times. Meaning your fill rate will be 1/20th of what it could be.
On top of that, many sprites use animation textures such as this fire example. This means the textures are larger and take more time to get access to in the videocard memory cache.
There are a few of these effects that really kill FPS. So test your map when using these. Sprites are also the things that kill peoples FPS when a lot of explosions are happening. But you cant control that.
FALLING SNOW RAIN
Another transparent particle that causes lots of screen overdraw and reduces fill rate is snow or rain. Again 100s of sprites are drawn on top of the normal terrain scene. In the pic below the left is how it looks in game. The right is set to ADDITIVE mode in the worldbuilder so you can see how many sprites are actually being drawn. After seeing this you can imagine when COLD TECH is enabled and a blizzard rolls in, your FPS will dive hard.
SNOW SHADER CODE
When you paint snow on to the terrain. The snow must be converted to a texture and is used in the shader program to decide if snow is painted on top of the object being drawn. This adds another memory access and calculation in the videocard shader program. The program will need to decide if the object gets snow or not, what angle the triangle is since snow only lands on upward facing objects, and if the heightmap texture changes that angle, etc That is a lot of extra calculating for every object on the screen.
The snow shader also looks at how deep the snow is and changes what texture it is using to paint the snow. Since each texture is usually at least three texture components this could mean dealing with nine hi-res textures in the shader code. That will not be a fast operation.
Here I erased some snow to show how it looks in the worldbuilder. This calc is done on all objects on a snow map so more or less snow probably makes no difference. The amount of snow should make no change in FPS. Its just one more step in the long list of slow things added for snow maps.
ICE
Another FPS killer is water and ice. Most games that draw water need to draw the whole scene upside down to create a reflection. For snow maps add drawing ice to that equation. A shader would need to decide if these pixels are water or ice and which ice texture to use based on the amount of ice damage. Again looking at many more textures than a normal terrain or object would require. Also add the calcs to decide of a player or projectile is on ice. And how much damage the ice has taken. Maybe Relic has figured out a way around drawing the whole reflection scene as this does not seem to hurt FPS as much as it should in theory.
THE END
By late game, there are more pathing calculations for units, more objects (triangles) on the screen, more projectiles that need to calculate if they hit something on the map, visibility calcs, pathing code becomes very hard and time consuming, etc. And of course anytime something blows up and is on fire 100s of sprites are added to fill your screen and kill your FPS.
I hope some of that makes sense. Only Relic knows for sure what their code does. But this is my best guess. If anyone has some cool insights I am wrong about or may have missed please comment!
WHY DO SNOW MAPS KILL MY FPS
15 Feb 2020, 03:55 AM
#1
Posts: 2145 | Subs: 2
20 Feb 2020, 05:54 AM
#2
Posts: 789
Bruh. My brain hurts.
Lots of cool & interesting though
Lots of cool & interesting though
24 Feb 2020, 21:01 PM
#3
Posts: 3423 | Subs: 1
I've had issues with the snowfall effect before. Not snow on the ground but the active effect of snow falling like on Alliance of Defiance
I think that's snow anyway, could be ash or something
I think that's snow anyway, could be ash or something
16 Nov 2020, 19:43 PM
#4
Posts: 2145 | Subs: 2
One thing I forgot to address in the snow discussion is getting a bugsplat.
ASSUMPTIONS
Since people tend to get more bugsplats and see thru pink buildings after snow maps, I assume that the terrain adjustments are the issue. Totally a guess.
People who play 1v1 seem to get fewer bugsplats than people who play 4v4.
THEORY
Long 4v4 games and snow maps share this thing in common: a lot of real-time terrain adjustments.
Every time an ordinate explodes on the ground the terrain height is adjusted. So the longer a game goes the more terrain adjustments are being made.
Every time a unit or vehicle moves across the snow covered terrain the terrain model is adjusted. Since the snow terrain uses a lot more triangles than the normal terrain it amplifies the problem. And you are much more likely to get a bugsplat after a snow map is played.
I am guessing there is an issue with the code (Relic,Driver, etc) that is not handling these real time 3D model adjustments correctly leading to a memory leak. Perhaps an array/model is being allocated and never being disposed/deleted.
ALTERNATE THEORY
Long 4v4 games and snow maps share this thing in common: a lot of real-time texture adjustments.
Every time a shot lands a texture splat is added to the terrain where the explosion hit. We can handle this in two ways:
1) Add the splat to a growing list of splats that need drawn. The more action the larger this list gets and the slower your FPS will be. Depending on how the splat is drawn we could be creating new 3D models after each hit.
2) If the terrain is all cut up into 32mx32m chunks then an existing texture needs to be modified in real time. The overall FPS is unchanged since we are still drawing the same amount of textures/terrain. But there is a chance for bad code creating a memory leak here.
SUGGESTION
I am probably way off in left field on all of this and it does not matter to us as players. But it may help you decide how many games to play before a restart.
After several short 1v1 matches you should restart.
After a long match or a snow map you should restart.
Of course the 64-bit patch may fix the real issue and this will all be moot.
ASSUMPTIONS
Since people tend to get more bugsplats and see thru pink buildings after snow maps, I assume that the terrain adjustments are the issue. Totally a guess.
People who play 1v1 seem to get fewer bugsplats than people who play 4v4.
THEORY
Long 4v4 games and snow maps share this thing in common: a lot of real-time terrain adjustments.
Every time an ordinate explodes on the ground the terrain height is adjusted. So the longer a game goes the more terrain adjustments are being made.
Every time a unit or vehicle moves across the snow covered terrain the terrain model is adjusted. Since the snow terrain uses a lot more triangles than the normal terrain it amplifies the problem. And you are much more likely to get a bugsplat after a snow map is played.
I am guessing there is an issue with the code (Relic,Driver, etc) that is not handling these real time 3D model adjustments correctly leading to a memory leak. Perhaps an array/model is being allocated and never being disposed/deleted.
ALTERNATE THEORY
Long 4v4 games and snow maps share this thing in common: a lot of real-time texture adjustments.
Every time a shot lands a texture splat is added to the terrain where the explosion hit. We can handle this in two ways:
1) Add the splat to a growing list of splats that need drawn. The more action the larger this list gets and the slower your FPS will be. Depending on how the splat is drawn we could be creating new 3D models after each hit.
2) If the terrain is all cut up into 32mx32m chunks then an existing texture needs to be modified in real time. The overall FPS is unchanged since we are still drawing the same amount of textures/terrain. But there is a chance for bad code creating a memory leak here.
SUGGESTION
I am probably way off in left field on all of this and it does not matter to us as players. But it may help you decide how many games to play before a restart.
After several short 1v1 matches you should restart.
After a long match or a snow map you should restart.
Of course the 64-bit patch may fix the real issue and this will all be moot.
PAGES (1)
1 user is browsing this thread:
1 guest
Livestreams
103 | |||||
14 | |||||
885 | |||||
49 | |||||
8 | |||||
7 | |||||
2 | |||||
2 | |||||
2 | |||||
1 |
Ladders Top 10
-
#Steam AliasWL%Streak
- 1.831222.789+37
- 2.35057.860+15
- 3.1110614.644+11
- 4.623225.735+1
- 5.276108.719+27
- 6.306114.729+2
- 7.919405.694+3
- 8.262137.657+3
- 9.722440.621+4
- 10.1041674.607-2
Replay highlight
VS
- cblanco ★
- 보드카 중대
- VonManteuffel
- Heartless Jäger
Einhoven Country
Honor it
9
Download
1236