How to optimize a map propperly

Discussion in 'Mapping Questions & Discussion' started by MegapiemanPHD, Jun 3, 2015.

  1. MegapiemanPHD

    aa MegapiemanPHD Doctorate in Deliciousness

    Positive Ratings:
    I've been working on a map for the past few months now and am almost ready to release it into it's next stage of development, but I've hit a wall. I cannot for the life of me understand optimization. I've read articles and watched videos but I've yet to be able to translate that knowledge onto my own projects.

    This is my current project:

    What I'm looking for is any and all information anyone knows about optimization as well as tips on how to apply that information. Most of what I hear are just people telling me to use Hints, Skips, Area Portals, func_details as well as other brushes or entities but I just don't know WHERE to use these things.
  2. henke37

    aa henke37

    Positive Ratings:
    Start with the func_details. That's something that you should be using continuously as you make the map. Ensure that only geometry that matters for visibility blocking is left as world geometry.
  3. iiboharz

    aa iiboharz Meme Queen

    Positive Ratings:
    Like henke said, func_detail everything that doesn't block vis as you map

    "Skip" isn't really anything to do with optimization it's just a texture that we use so that we're not making extra cuts with our hints.

    For hints (or any optimization task really), the best thing to do is do a compile of vbsp, load the resulting portal file and find areas where cutting visleaves would result in better vis calculations. I personally don't fully understand hints so I tend to use them sparingly but generally I guess you don't want a visleaf to straddle a huge area because then the calculation for that visleaf will cause the engine to be rendering way more because of that one visleaf.

    Areaportals are very useful for interior spaces and I'm sure they're very easy to understand so I'm not gonna go into more detail here.

    Occluders are something you should definitely try not to use too much, they cull any model/prop from rendering that would usually be behind it. The best usage is probably on big flat walls that have tons of props rendering behind it which can't be optimized any other way.

    Be warned that improper use of areaportals and/or occluders can result in negative effects (drastic fps drops).

    When you get to the detailing phase of your map it can be useful to set fade distances for props as it will definitely help cut down on what's being rendered at any one time and can possibly negate the requirement for an occluder. Props are more expensive to draw while fading however so keep your fade distances short whilst trying to avoid nasty pop-ins.

    Start small, work your way up as your map gets further along in development.

    Another big tip I can give is to try and keep your map's boundaries small. Open space is nice, but too much of anything can be bad. That's where I went wrong with tanker, its huge open skyboxes caused horrendously long compile times.

    Visclusters don't help with optimization and their primary use is to cut down on map compile times, however if you use them incorrectly you will mess up your map's vis and cause tons of issues, so it's best to take it slow and use them in conjunction with hints to get optimal compile times. In Tanker I used them to help shorten how long the vvis calculations of the large open areas was taking.

    EDIT: One of the best things you can probably do is download a decompiled version of an official map and analyse how they did their optimizations.
    • Thanks Thanks x 1
    Last edited: Jun 3, 2015
  4. hutty

    aa hutty

    Positive Ratings:

    These are the articles that helped me figure out optimization. In general, source engine optimizes levels by cutting them up into little chunks (called visleaves). It then figure out which visleaves can see other leaves, so that it only renders the part of the level the player can see.

    Visleaves are generated by carving every "world brush" into space. (and yes it is that carve algorithm). If you have a cylinder as a world brush, you will end up with hundreds of tiny visleaves. Which will both make the map slower, and make your compile time take years.

    To counter this, use func_detail on everything that doesn't block a line of sight. And I mean everything. A good example is gravel pit, where the B and A point buildings have too many windows to reliably block the visibility of the stuff behind them, so they are made entirely out of func_details.

    (but dont try to make displacements as func_detials or any entity for that matter, it will cause you compile to fail, and displacements are ignored visibility wise.)

    After func_detailing is done, the next step is hinting. The easiest way to do this is to jump in-game and turn on mat_wireframe 1 and mat_leafvis 1. Then look around your map look for places where the game is drawing the next room when it shouldn't be visible. (like corners and such). Look at the articles linked above to figure out how to hint things properly.

    In areas where you cant use hints, areaportals could work, I've never actually seen any drastic uses of areaportals in my maps as of yet, so just do what iiboharz said.

    Occluders are a last resort optimization tool. One example of their use in the wild is the wall that blocks the exit of 2fort's main spawn from seeing the rest of the outside. (part of the corner leading to battlements).

    I hope that helps explain things.
    • Thanks Thanks x 2
    Last edited: Jun 3, 2015