Questions about optimization

I have already read this. And this, I have also watched a couple of videos about optimizing your level.

1. I have many tunnels in my map that would greatly benefit from areaportal windows. What is the best way to do this?
Do I stretch the brush to the length of the tunnel, or do I make 2 seperate areaportals, one on each side. Or do I put one in the middle? or some other way entierly?

2. On the wiki it only says that many open areaportals visible can decrease performance, is it better to make one larger areaportal than multiple smaller ones?

3. Do func_detail take more or less performance impact per polygon than a static .mdl file?

4. Do areaportals only impact performance when a player sees it and models appear/dissapear or always when the player is close? even if looking in opposite direction.

Theres 6ish types of performance issues you might run into.

  1. Too many triangles being drawn
  2. Too much memory used by textures/models/animations/sounds
  3. Too much work done on shades (water, fancy refraction and transparent do this)
  4. Too much time spent thinking about what should be drawn (too many portals or gratuitous number of visleaves)

Unrelated things
5) Script/physicals calculation lag - spend too long thinking about the game
6) network latency

To find out if you need them, turn on mat_wireframe and have a look around. IF you see lots of stuff being drawn which you can’t see and/or you get low FPS when looking in a certain direction its time to consider optimisation.

Its a balancing act really. Too many area portals cause lag because they need to caculate when/what to draw (4) but when they’re activated they save on stuff being drawn (1,3). If your tunnel is curved to the point where you can’t see the other side through it then use hint/skip instead. If your tunnel is straight imo use 1 area portal fading in the middle.

Not sure about performance of func details geometry vs static prop. The difference is lightmapped vs vertex lit and other other stuff like caching the model, shaders on the material and draw calls. IMO seems like an arbitary microoptimisation, I’d go with model since func detail still cuts up nearby geometry and makes a mess (and a few tris) and you’re limited by t-juncts.

Looking in opposite direction doesn’t draw geometry.

Someone once explained it to me thusly.

BSP turns the map into a mesh (triangles) and assigns them to visleaves.
VIS decides which visleaves can see other visleaves.

sometimes you have to help vis decide by splitting them different (hint and skip)

  1. The way you asked this question implies that you don’t perfectly understand how areaportals work. I suggest you read more tutorials and look at a couple of example maps to get an idea about how exactly areaportals work. The answer to your question depends on various properties of the tunnel itself, but lets say “2 seperate areaportals, one on each side,” provided that tunnels are long enough (128 units or longer, lets say).

  2. This depends on the situation. If you have several windows on the same wall (same plane) close to eachother then its much wiser to use one areaportal for all of them, but the compiler automatically merges areaportals in this configuration anyways.

  3. Models are cheaper to render than brushes - always. Displacements are cheaper than brushes too (PER POLY) but are still more expensive than models.

  4. Areaportals only impact performance when they are set to a open state and are visible to the player.

1a. Put areaportals on both ends, area portals in that situation don’t “double” visibility computations, so there isn’t additional performance impact.
Specifically, because of how PVS works, an areaportal “behind” an areaportal is pointless, so only the ‘closest’ one is computed.

2a. Areaportals sealing off the same general area are “combined” and aren’t that expensive, they just need to share an axis.

3a. static models are far cheaper than brushwork, blow your model limits before your BSP ones.

4a. Areaportals have near negligible performance impact in practically all situations; but technically speaking, Areaportals only ‘cost’ performance when they’re “open”

I still think this is the best guide on optimization:

Thank you all for excellent information, I highly recommend the guide glitchvid sent, it is very helpful and is written in a way that makes it fun-ish to read :slight_smile: