CLOSE

Archive:

2023
2022
2021
2020
2019
2018
2017
2016
Subscribe:Atom Feed

"Kick in the Perf"

Posted: 22 October, 2021

Tuesday 19.10.2021

Spent the entire day working on a new Dev Log! Yeah, I know, I normally try and skip through these, but I decided to try and get to know Resolve a little better, and since my You Tube channel seems to get more attention than anything else, it’s probably worth making an effort…

I didn’t realise how pokey Resolve was! The Fusion stuff seems genuinely powerful, and I started to have a bit of fun making little transitions. It’s genuinely interesting to see how a different industry does the same, basic stuff, like lerps. Whole new language to learn, and annoyingly, a whole new interface…

Does dawn on me that I should probably start leaning into Blender to make these little motion graphics. Maybe I should do an in-depth one on the Utility AI and make some fancy graphics in Blender… strokes chin

Wednesday 20.10.2021

Completely fell down a rabbit hole, today. Decided to go through all the levels and have a look at perf. First stop, to instance everything up.

I know, I said I’d hold off on this, but because the original actors are still in the editor and only the instanced stuff gets cooked, I figured “What the hell”. But I found out something interesting about the hierarchical instanced static meshes: the verts aren’t welded, so there’re little gaps visible at 4k.

And here’s another thing, there’s absolutely no runtime performance benefit that I could find (I’ve not looked exhaustively) between manually doing this in editor, and letting the auto instancing stuff do its thing on load… Except, it’s quite likely that the instancing on load is responsible for the dropped frames that happen when a level streams in… but I’m not sure of that atm…

So, I ended up ONLY instancing things where the meshes don’t need to be welded; like trees, bits of grass, fences, stuff like that. Anything modular, that’s supposed to line up precisely, I’m letting the engine handle on its own. Each of these has cull distances set and works as you’d expect.

After doing all this my FPS in cooked builds didn’t change at all. Hilariously, I’ve been CPU bound, the entire time…

Yup, I’ve been bitten by the TICK.

But… I think this is incredibly easy to fix: My UtilAI controllers can pause when more than a certain distance away from the player, which in turn can set actors to hidden, pause Anim Blueprint updates, and disable movement components. That’s 90% of everything that’s on the Hot Path.

I think the only other things in the world that move without using my AI are the fish, and tbh, if they updated once a second, no one would notice.

So, an interesting day. Learned a bit about profiling in UE4, and it’s an order of magnitude more complicated than in Unity, lol :D

Thursday 21.10.2021

Made some destructible brambles, mainly for East Ley, but they’ll no doubt get a colour change and be re-used everywhere, now that I have them. I like how they wiggle!

The rest of the day was spent on the perf issues I uncovered yesterday.

So, being bitten by the TICK was overdue. In the worst place, right by the player’s house (DOH!) there were 30+ fish, 4 wasps, 8 butterflies, a load of NPCs, and 30-40 spiders, all active and doing their thing. Kinda surprised it was holding up as well as it was, tbh. But yeah, it did need fixing.

I was going to put some extra code into the UtilityAi, to pause based on distance to the player, but ended up using the NPC base class instead. These now have params like, “should I pause” and if so “how far away should the player be?”, and a simple timer then checks, at a given frequency, what the current distance is using a straight-line check, ignoring visibility entirely.

Having the checks in the NPC means it’ll cover everything, whether it has a brain or not, and it’s also the easiest way to pause any movement controllers.

Amazingly, today I learned that every actor in the world has a custom time dilation! So, if you want to pause an actor, including freezing all anim updates, you just set the actor’s dilation to zero. Because of course you do! I’m just used to Unity being shit, and having a solitary timer for everything that you then must wrap, manually, a million different ways… (Custom Time Dilation doesn’t stop the Animation Blueprint from ticking, but that’s not a problem for anything I’m doing…)

After I got all that working, I did a quick profile in the editor and dug into the Session Front End profiling tool again, and wow, that’s a seriously nice bit of kit! Took me all a minute to work out that my game thread was crawling because my fish had colliders attached (they don’t need them) and worse, I was manually moving them (oops)... Yoink! After that, my frame was being eaten by Niagara.

The collision on the particles in Ytene was, unsurprisingly, eating up a fair wodge, but the overhead of so many emitters was also causing a problem. The latter was easily fixed by overriding the scalability settings. The former’s something I’m going to live with. There’re a lot of particles and they do need to collide with the player… but I did get their frame time down by half, which is “good enough”. There’s nothing else really going on in that level…

All in all, an unexpected detour the last couple of days, but a fun one. I’ve used quite a few engines, but I’ve never had the pleasure of instrumentation as good as Unreal’s! It’s really given me some confidence. Compared to the largely non-existent profiler and crappy draw-call stats I had to live with on Lumo, this feels like I’ve died and gone to heaven.

Friday 22.10.2021

Went through the build to test out all the changes from the perf work over the last few days, and I’ve got an absolute solid 60, everywhere, at 4k on my Dev Rig and Lounge PC, which is, er, better than I expected! There were a couple of things that needed fixing, but nothing related to what I’ve done this week…

After that I added some more particles to the East Ley shrine barrier, and in prep for doing the Level Sequence to unlock the barrow entrance, I added a new cheat to my Dev Menu that destroys all the stones instantly. Will save me some running about…