Need help optimizing a map with a big central courtyard (art-passed)

AlrexX [she/they]

do not forget your daily intake of booby pills
aa
Jul 31, 2019
98
54
The map in question: https://tf2maps.net/downloads/downstream.15574/

Recently I tested this version of the map and got some complaints related to framerates dropping massively when approaching the central area from spawn. I knew this could become an issue eventually, but I never realised the scale of the problem, since I didn't know I had my FPS capped to the default value of 300 and my PC has pretty high specs, so it has no problem reaching that value. So I uncapped my FPS, ran some tests and... Things are bad. Like, really bad.

For reference, this is me looking away from the central area at spawn. My framerate sits around 700 comfortably, which is to be expected since there's not too much to render.

20230526113633_1.jpg


Now look at what happens as soon as I turn around. Not even move, mind you, this is just me turning around on the spot. My framerate completely plummets to about 400.

20230526113639_1.jpg


And now look at what happens when I exit spawn and just look at this wall right next to the main exit. For some reason, looking at this wall specifically gives you far worse framerates than just looking through the door itself, and my framerates go as far down as 350, which is half of what my PC could manage on the first example. This is just unacceptable, and the fact that this is the state of things right now and I didn't catch it sooner is downright embarassing.

20230526113650_1.jpg


So now I'm kind of lost. I'm very new to this stage of development in a map, having spent years working on grayboxes and abandoning them after a few weeks, so when it comes to optimizing I have no clue what I'm doing. I know the tools to analyze what's wrong, but I'm not sure how to actually fix the problem, especially since I do know that this kind of map is one of the worst kinds to optimize, since it's really hard to block the player's view to different areas given how open everything is.

Using mat_wireframe I can see that in this last spot I'm rendering way more than I need to, so there's the problem. Now I need to figure out how to stop it from happening.

20230526113728_1.jpg

But that's as far as I can get. I tried to read a long optimization guide for Source maps, but it ended up frying my brain with all the information in it, so I can't think of anything else other than asking for help here. I'm really concerned because this is a project I'm really motivated for, and I don't want it all going down the drain because of an issue like this.

Hope the information in this post is enough, but I can provide the vmf if needed.
 

pogviuemper

L2: Junior Member
Apr 25, 2020
71
14
in open huge areas like in your map a pretty important method is prop fading: you go to all props' properties and change their "start fade dist" to the number of hu at which to start fading the prop, and change their "stop fade dist" to the number of hu at which to stop renderring the prop completely; note that most of props should have different fade distances for better performance. Be careful with how noticeable these fades are

Besides prop fading, func_areaportals are a very big deal. These are always connected to non-entity brushes from all sides and they make the game calculate what stuff to render in real time. But normal areaportals are not super useful, so there's a func_areaportalwindow. Areaportalwindows (apwindows) actually operate the same as prop fade, but they close off entire areas and not just a single prop. In its properties there's also a "rendered window": it's a brush entity that kind of replaces your areaportals with an actual texture rather than a void of a closed areaportal. To make apwindows look good, you 1) set its translucency limit to 0; 2) you make a func_brush with no collisions and with whatever texture looks good (usually, "toolsblack"); 3) you set "rendered window" to your func_brush and place the areaportal inside the brush so you can't see void from anywhere; 4) you set fade distances to whatever you want and place your brush+areaportal combo outside the view of the player (like, in the back of a prop). Now you place many of these apwindows in places where they're appropriate (like windows, building entrances, etc); though, you have to think logically which places are actually in need of these areaportals.
By the way, generally, every entrance/window on a map has a normal areaportal

Here's how I would use one of the apwindows (it should be in the back of the gates):
1414.png

There's also other stuff like working with visleafs and hints, but these are pretty hard to explain with a good example on your map.
I would highly recommend you looking into official valve maps (decompiled/official from sdk_content) to see how they optimize their maps.
If you're struggling too much, I can help using your .vmf file

Also, your map has errors for custom models, so you have to pack these assets inside a map: I heard compile pal does that easily
 
Last edited:

AlrexX [she/they]

do not forget your daily intake of booby pills
aa
Jul 31, 2019
98
54
Thanks for your reply, I've been adding regular areaportals & setting up prop fading and it's already helping a ton. Gonna work on adding a few areaportalwindows now.
Also, your map has errors for custom models, so you have to pack these assets inside a map: I heard compile pal does that easily
That's weird, I already used CompilePal to pack+repack the map, hopefully when I pack it again it'll fix itself :x
 

AlrexX [she/they]

do not forget your daily intake of booby pills
aa
Jul 31, 2019
98
54
I'm happy to report that with a combination of prop fade and areaportals framerates have improved massively. Comparing the previous version with the current one, there's parts where frames used to dip under 250 and now they stay above 400 relatively consistently. I imagine that'll be a huge help for lower end systems.
Still need to further improve some areas which are still problematic, but I think at that point I'm gonna have to use hints, so that's gonna take some learning.​
 

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,697
2,581
I should warn you that you should never use areportalwindows in doorways unless there is something closer than the minimum fade distance that's blocking every possible sightline through it. Otherwise you can end up in a situation where snipers can stand just inside the doorway and shoot at targets that are too far away to see them.
 

AlrexX [she/they]

do not forget your daily intake of booby pills
aa
Jul 31, 2019
98
54
I should warn you that you should never use areportalwindows in doorways unless there is something closer than the minimum fade distance that's blocking every possible sightline through it. Otherwise you can end up in a situation where snipers can stand just inside the doorway and shoot at targets that are too far away to see them.
Yeah I'm watching out for that, thanks for the heads up though. In the current version of the map I'm already trying to block off any long-range sightlines from within the doorway, since there's also the fact that it's a one way door that's right next to the resupply room so it could be exploited as a way to have risk-free sightlines, so the areaportalwindow there should be mostly fine. I'll watch out for any instances of OP sightlines where the apw blocks visibility from the other player's perspective.