In game engine development, performance profiling reveals that frame time bottlenecks often stem from GPU-bound operations like lighting calculations rather than CPU overhead. The video demonstrates how increasing light clusters from 16 to 32 lights per cluster caused frame times to hover at 14 milliseconds, with profiling showing minimal CPU time (3ms) versus significant GPU time. The solution involves optimizing shader operations, such as reducing texture samples per pixel and improving light binning algorithms, which can halve frame times from 13ms to 6ms. This illustrates the importance of understanding hardware bottlenecks and implementing targeted optimizations in graphics-intensive applications.
Inmersión profunda
Prerrequisito
- No hay datos disponibles.
Próximos pasos
- No hay datos disponibles.
Inmersión profunda
MonoGame Code Time! w/Tom, working on Ascent!Añadido:
All right. So, where do we leave things?
I mean, I did some more work over the last couple weeks when I had time, you know. Um, life gets in the way sometimes. Uh, hell no. Some debug stuff. Just cleaning up some junk that I was working on.
Uh, so last time we were working on prefabs and I pretty much got that to work. Um, including loading and saving the scenes.
I think that I hadn't I hadn't actually set up the loading and saving the screen of prefabs on stream, but I did it off stream. Um, I worked a little bit on fog, but I never I didn't get to a good solution there yet. Um, there's some complications there because the the way that I want to do it is, you know, the same way as the light clustering is, you know, fog volume with the uh, you know, fog cluster information. So, I know in each cluster what the fog data is, it's at higher resolution than everything else or the the lighting. because fog needs to be higher resolution and have fog volumes, divine volumes and stuff, you know, with some swirlies in it and things like that. So, that'd be really nice. But, I didn't quite get there uh last week when I was messing with it.
But, I figure we'll continue on prefabs right now cuz I don't feel like beating my head against the wall with math uh today uh after a long week. So, let's see.
Reset up here.
A lot of things to close out.
Nope. No chat. Get chat up.
Closing up all the uh extra junk on my desktop.
I can swear my maybe my volume's too loud.
Yeah, I saying.
Turn it down a little bit more.
So now, so Microsoft released the Xbox GD released the Windows GDK yesterday.
Yeah. Um, I've always been confused by the naming of that. Uh, and some of the GDK has been public for a while. Um, but I think this is the shared GDK that works on Windows and Xbox and it's all in the public. Um, which is nice. You know, that's a positive, right? Um, I don't know if that'll return the days of old XNA or anything. Um, but we'll see. Sorry, I'm still cleaning up my desktop a bit here. Just have too many things open that, you know, I can't leak on stream.
Uh, and how many browser windows did I have open?
>> About a million.
That happens, huh? Million browser windows. Have three remote desktop windows. That's not cool.
Don't close those things.
Does anybody have one of those uh Microsoft uh or Xbox handheld devices?
We're looking at grabbing one of those things for some testing on a project.
All right.
Yeah. I mean, in theory, Xbox stuff can be pretty much fully public. There's uh in and ours is as well.
like at least all the rendering is, you know, the uh there's a little bit that isn't, but you know, in theory, all of it can be public. There's really all right.
Let's see.
Oh, submitting your PS5 buildification tomorrow. Network complicates everything. Yeah, network complicates everything. That's always the truth.
Yeah, the raw ally was what we were thinking about, but I was thinking about getting that MSI claw because you want something that's lowerend that can uh something that's lowerend that can uh verify that something's going to work well on the higherend devices instead of getting like a bunch of different devices.
Figured if it runs on the low-end claw, then it'll run on everything.
All right, so finally got my desktop under control, so that's good.
Uh, all right, there we go. Sorry about that. Took me a little while.
Kill some stuff.
All right, share my screen finally.
Oh, your PS5 port is only running at 1020 FPS for some reason. Yeah, I mean those are the things you have to figure out, right? The profilers there are pretty good.
I would run the profiler. That will tell you a lot.
All right. So, um, see, I was walking on some fog stuff that didn't quite work out. Wanted to do a couple things today. One, I want to try to get uh I just dumped a bug.
Sorry, I was running a release build.
Um, let me make sure the fog stuff that I had there is kind of off because it's kills performance at the moment.
All right. So, let me just run it real quick.
So, one thing is I've been wanting to increase the light the number of lights processed from 16 a cluster to something a little bit bigger, you know. So, I went to 32 and the performance isn't the greatest.
Some is probably the limitations of the shader that I'm using. Some of it's that, you know, um how my lights are set up. You know, things are looking pretty good. Um but and we're still working on getting the um Oh crap, I don't have the edge on, but this works. You can see that like here the frame rate is just, you know, frame times hovering at 14 milliseconds. And I'm pretty sure that is all um I think that's GPU time that's actually being the problem there if I remember correctly. Yeah, like this direction 5 milliseconds. Now there's a ton of lights right here. Let me just run a release debug build.
So I have a bunch of stuff off in release builds that probably don't need to have off. At least not for this. Just a test.
Can I fix that while this is going on?
Nope. Can't.
So, it's fallers like uh Monogames X Xbox stuff. Um I mean it is uh you know if you come into our native code and look at native code DX12 this is pretty much all the Xbox stuff you know this is all shared with Xbox essentially you'll in fact you'll see some some uh Xbox defines in here if I remember correctly somewhere.
Uh oh, it's uh it's like in a header.
Yeah.
Um wherever the freak that is. Oh, there it is. So, you'll see some Xbox defines and places for stuff that is specific to different Xbox versions and stuff. It's all been very public for a while. So, and other repos do the same sort of thing, you know. Um, what's not in there is I think it's just some Let me check real quick and see what's not in there.
So, I'm curious.
But all that stuff can technically go into the public at this point, but you know, it's not like there's anything super secret in there that that's that's interesting.
like whatever what else is in there that's not in the public.
Uh so all graphics has been moved into there into the public.
Um look the wrong place.
That doesn't help.
Okay, that's the wrong one, too.
The heck is it?
That's weird. I could have swore that Salt and Folic already.
Anyways, um the stuff that's extra there is there's a little bit of code around gamepads, you know, we can push that into the public, you know, but it's really not, you know, that interesting.
Um, and it's very specific to, you know, the Xbox implementation. there's no reason to use it on Windows. Um, the X audio implementation is completely shared, you know, with uh with Xbox. So, for the most part, all the Xbox stuff is really shared. I mean, we don't have like specific Xbox saving APIs or anything like that. Um, that'll change, you know, and that stuff will probably go back in the public. And we don't have any network code or anything else like that.
Uh, the achievement APIs. I think that might be in the public, but it's not part of Mono Game, so not a concern.
All right. So, what I just do here is get to show.
So, like you see all these overlapping lights that's kind of you see how big those lights are. You know, I was looking to set up the lighting and I was like, well, what's the realistic falloff? And it's using a realistic fall-off. Um, which when you do that, it's kind of exponential if I remember correctly. And it means that your lights are gigantic, but they only affect the very center of it. And I think I need to stop doing that because that's so not efficient for culling and the like. You know, maybe I can be smarter about my volumes, you know, but it's just not efficient for culling. Um, and it means that, you know, it's looking here and it's going like, "Oh, there's a million lights that are overlapping like, you know, there's there's clusters here with 30 lights, you know, um cuz all these lights here are overlapping like, you know, this little cluster on the center here has like a million lights overlapping. Um, and the clusters are a volume, so there's depth. But, you know, uh, there are places where there are that many lights overlapping, and it really shouldn't be. So it's something and I think there might be some errors in our clustering that might be you know being overly aggressive on the clustering. So that doesn't help either.
So that's something that I wanted to improve a little bit. But first I wanted to check out and see you know how much of this is um how much of this is. So I'm there vsync off.
I'm just going to do a runtime hack here. It's just sitting here sitting for frame time 13 milliseconds. I just want to see what happens if I come in here to the cluster and stop cluster updates.
I don't have a button to do it.
That'll do it.
Just curious, you know, how much time might be tied up in that.
very little to anything. So, it's all in the GPU. So, even if I optimize the CPU side of things, which probably does need to be optimized somewhat, you know, it's all the time is tied up in the GPU. It's not any CPU time. Really need to put in CPU time into this whole thing. Uh so, I can see that more clearly.
Um that would help with things. I think I started to do that but I didn't get it finished or something.
Let's do that real quick while we're thinking of it because that'll be nice to know.
Uh where did that go?
Yeah. So that's what's happening there.
I think how this works is Yeah.
See, it's not tracking like um it's updating here. It just checks from from update to update. So, if I wanted to track actual frame time without the I'd have to basically skip the time that's in the present, uh which is going to be way up in game.
I think I did this actually for um I think I did this for the profiler.
Yeah.
Yeah, to do that I'd have to like capture the time here.
I can probably do that though.
No, it wasn't many profiler. We just kind of hacked one in there directly.
Uh, that's probably something I should probably look into adding.
I think you mean this thing, right?
Yeah, I probably should probably look to add like a third party profiler. That's kind of nice.
Just integrate it with the thing better.
So, let's see if I can do this real quick. Um, so this is working without a timer. And what I probably need to do is uh Okay, screen manager does this.
It's not in a very Yeah, I want to do the same thing, but I kind of want to in add it into the FPS tracker, but it's kind of like stuck there. Just doesn't have to be Let's make the FPS tracker private constructor have a public instance.
then I can access it from anywhere.
Yeah, I probably didn't have to do it that way, but this is good enough for my purposes.
Should probably stop it, huh?
So, let the compiler tell me where it's broken.
Uh, what? Oh, makes this stuff a little bit longer, but who cares?
All right, that allows me to do what I want to do here, which is um Um, so I think what I want to do, this other junk's kind of in the way, but whatever.
That profiler stuff doesn't work very well. So, come on thing. Help me out here.
Come on thing.
Is Discord currently down?
That's interesting. Is that like a global outage of some sort?
Just going to call it CPU time. Not going to fret too much about this.
Very very simple.
Sounds cool.
That should work.
Huh. That's interesting. So, it's totally down.
Hey, what it do? Oh, I see what it did.
me.
Wait, did I do that wrong?
Oh, wait. I think I'm calling I'm doing it wrong. I need to get the elastic and stop it.
There we go.
That's interesting.
I mean, I guess the elaps milliseconds is nothing in this case.
Here's where we should see it. There we go.
Very simple, but it works.
So, CPU time is absolutely nothing.
Have I ever implement implemented crash pearl like bugsplat like bug splat? No, that sounds vaguely familiar. I mean I used to be I used to research crash porters and stuff like that when I was working in app development.
This is a very long time ago. So totally different era. And we had tools like that that you could build in that would automatically dump out, you know, capture errors and report them. And there's different tools out there. And, you know, some games to use them and others don't. And last time we shipped something that we had to build a bug reporter um was Grandia. We worked on the Grandia remake, not remake, but you know, remaster from a few years back.
And it was just a custom C++ you know app because it was based on the original Grandia code. Um and uh we needed crash reporting of some sort. So we put in some crash hooks. Again we're just on Windows that is uh on Windows we needed crash reporting. Put in some hooks for crashes and we dumped out good information and we you know pushed that stuff through the Steam API and that worked well enough for us to get good crash reports on things. U but the consoles all have their own crash reporting systems and stuff.
So, it's not something you have to worry too much about.
So, yeah, you know, it's not it's not uh that big deal. Uh so, it just depends on what you're trying to do.
I mean, ideally, you know, you don't have that many crashes and you you can reproduce things, but crash reporters do help. So, one thing that's not helping us here is the fact that my window my desktop is at what? Like, yeah, I mean, it's not 4K, but it's still at a high resolution. And I had this window really big on there, so that's probably hurting my fill rate.
I'm also in a windowed mode instead of actual full screen, so that probably didn't help.
So yeah, I mean that's when our frame rate starts to tank is under these conditions. Um, again, CPU time is not the problem. So anyways, that's good to know. God damn it, that rocket.
Uh, all right. Nice little improvement there, but isn't really our problem.
problem definitely is not that.
All right. So, so that's working. Let me just do one more thing to sanitize or just sanity check here. So if I do this, it should be this. It should basically match up with the uh with the frame time.
Looks pretty similar.
Looks like it's matching up.
See, you know, I don't need to I can get fractions of milliseconds if I do it the right way, right? I think I can.
I'm just surprised I don't get uh Okay, there we go. I think when you do milliseconds, it's returning an integer value. So that's why we're not getting fractionals. You see how these kind of match up now.
Uh and then if I come in here and move this guy back to represent which present will happen inside that end draw get just CPU time which it's a little bit better now that it's fractional hard to read. That's why I kind of have the other one set to like update periodically instead of all time.
That's good enough though.
It's good sanity check that things are not flipping out.
My CPU is pretty old, too. So, it's not it's super fast CPU. This gives me a better feel for like performance of things. 3 millisecond CPU time.
Everything's tied up in the GPU. So, I know that any improvements need to happen on the GPU side, basically. which my GPU also isn't super high-end. Let's uh go look at that. Uh just curious where our my fog I mean I know my fog CPU code was was bad. Let's see how bad it is.
Just curious.
It's doing a lot of stuff on the CPU. It shouldn't be. Yeah, that's pretty bad, right? It's basically now dragged down by it. So that's how bad it was. I knew it was bad. It's like I'm testing stuff and the I'm doing the work that I should be doing on the GPU on the CPU to start with and then then I'm going to transfer that work to the GP to the CPU.
Sorry, I did that wrong or to the GPU.
I'm going to transfer that work to GPU once I get things working.
Just taking one step at a time. All right. So, so yeah. So, we left off. had these prefab concepts where I could come in and uh why can't I resize that? It's very annoying.
Uh I could add a prefab. That's prefab right there.
And then I can come in and select one of them. So, there's this prefab, you know, and then there's uh this hallway. That's another prefab I made that has like the light built in.
Has all the lights in it. So, those are two different prefabs that I know I set up. Undo redo should totally work on it as well.
Yep.
So, if I go look in the folder, what the heck that is content assets uh prefabs folder. So, there's two prepads. They're just XML files. Um, here's one of them. It's just a scene just like a regular scene. So like a regular scene looks like uh in levels.
Um so here's that level that I'm in.
See like scene children spawn scene children, you know. So there's how it all works.
So with it working this way, they basically in theory they can be loaded like scenes. So one thing I wanted to do was be able to get into a mode where it's easy to edit the existing prefab, you know, by basically unloading the scene and loading another one. Um, which I haven't tried to do yet, but I think it's worth trying.
Um, so I think it might be worth doing that, you know, where we can go.
I guess how it would should work is, you know, file open. I guess we should be able to change levels.
Raw 732 will be doing a showcase at the Too Many Games Expo. Too many Games Expo. Where's that at? Um 22628.
Awesome. We appreciate it. You know, uh getting the word out that those are that you're not just another Unity title. Um I was looking at stats on Steam the other day and like the amount of Unity titles on Steam is kind of ridiculous.
It's vastly beyond GDAU and Unreal. Um, they really screwed up when they did their whole weird, you know, I'm going to charge you per install All right. So, I want to add a file open in here that will open scenes in the thing. So, let's do that.
So, it's file save. Let's go to file.
Let's make a file open.
Search the word save. Maybe I get lucky and it's in here. Should be right. Yeah, there it is.
And you put three little dots behind it to signify to the person that is looking at this like, oh, you intend to let me select something afterwards. Uh, and then how to select it is the next question.
I can do a file dialogue, but I really hate that.
Yeah, the the pull request on their repo is crazy. And they've been hit by, you know, they've been hit by a lot of AI junk as well. And that's got to really suck. Um, so how I want to do this probably I mean I hate to have to write a new UI but kind of do need to.
I mean I mean I could just select you let you select it like through a file picker.
That kind of sucks.
Um this is the boring stuff. Uh I'll use the toolbox as a example or as a starting point. All right.
Gross. That thing has no copyright info. God damn my mouse cursor or my mouse. It's a good mouse, but like it'll sometimes the wheel wants to roll and as I'm clicking it's like, "Oh, you clicked and you rolled or I'm holding down control and suddenly starts zooming for no reason."
It's probably my fault, but still hate all these junky things that are in there for no reason.
Uh, all right.
This box sounds great.
Not sure what that is. Is that resizing?
This is weird stuff. I'm not sure what that is.
Okay, let's do that. And then let's see if we can just not going to mess with that, you know, setting it up just yet.
I just want to open it.
It's probably something that makes it motive, right?
Uh, that's what I want to do.
Pretty sure that's what I want to do.
It's going to totally screw everything up. That's fine.
Yeah, that's true. LM's being called uh AI. Yeah, I don't know how that happened. It definitely happened. How?
I'm unsure.
Is kind of weird though.
Would think that that's not the case, but it is. All right. So, file, open.
Hey, look. It opened a little dialogue up here. See if I can stick a close box button in there. Looks like it consumed all my input, which is what I wanted to do. Like, I can't escape the editor. I can't do anything. It's what I wanted.
Needed to be just like that. That works.
All right, let's add a close and a uh which I guess that just means adding a button.
Or can I just add a I wonder if it has a feature for it. I bet you it does.
Um, yeah, maybe it doesn't have a close button. In fact, I think there's an example of a close button already in here.
With Gum, the the UI system we're using here is Gum. And uh, with it, I don't know enough about how it works. So, a lot of times I just have to kind of look for examples in the existing stuff. Uh the developer kind of jumped in here and did the initial implementation so he knows it better than I do. Uh yeah, not a good no examples of a close button. So I just need to make a close button.
Oh, this popup was an example of it.
Let's just add something in here.
Huh?
I think that's all I need to do.
It's great. Yeah.
Uh, yeah, I guess so.
Oh, nope.
Let's see what happens. Let's see what happens.
Oh, so this is not going to work.
Guess close doesn't really do what you expect it to do.
Probably need to remove it from parent or something more complicated than that.
Hey, look, that did it.
Not sure why it's uh doing that, but I'll take it, I guess.
And why aren't these resizable?
Rescizable just on the top. I think this is that this junk here.
Let's see.
Yeah, that's what that chunk is. I see.
I can fix this thing then.
Not sure why that's happening, but whatever.
Progress.
So, I'm going to do a hack here to grab all the um little bit of a problem here that you know how the content builder works.
Well, we'll deal with that in a minute, but like it's trying to save itself to the output cont. It's trying to save to to the source content path, but the game isn't running out of the source content path. It is running out of the built content path. But, you know, it's possible that in in editor modes, we want to read at least the XML from the source content path. you know, um, but some of this is going to be fixed. Harry did some work for us so we can set up the content server stuff and that's going to help us a lot. So, when we get there, we'll get to that. Uh, I'll pass that through so it has it since it's already knows how to get it and I don't want to have to do this again.
And I'm going to basically uh going to scan And for that all the level files.
Nope.
Come on.
Uh read files.
He doesn't need to look in subdirectory.
So let's not do that.
Uh instead of doing this, I'm just going to do um I guess there's no other choice but to do something like this, which sucks.
Add See what happens.
I can delete that. But h seems like the internet's been going up and down, huh?
Keep seeing something and people dropping out of the thing.
And I know the stream's pretty boring, but I don't think it's that boring.
Okay. Well, that didn't work. But maybe that would work.
Well, maybe it's not bad.
Now, having the scenes would help.
Oh, it's the order.
Yeah, definitely do it.
probably do it again.
Hey, look. It worked.
It only picked up two of them. Oh, I think it's because the levels are not named dot.
No, it is called Oh, they're in subfolders. That's why. But I put them in there. So, that's what I wanted. I'll take it for now.
All right.
I don't know if that's actually going to do anything. We'll see.
Yeah, I didn't think so.
Wish I knew if they had like a title bar concept there. Maybe they do.
Uh, so far I've seen nothing with the title bar, so maybe it doesn't exist.
Probably be just as easy to fix that just doing this. Uh, I mean, I don't know.
It's probably not the right type.
Still don't understand the difference between a a visual and a I got something sort of working. I don't care about the finer, nicer details. I just want to get something that works.
Um, all right. So, this is giving me basically what I want.
Um, what I probably want to do is hook into double click.
Oh, I don't want to insert a function.
ly center of an arcs.
So, let's not do it that way. Let's add a button at the bottom that is open.
I think that'll be better.
Let's do it down here.
That just will make everything a lot easier.
Not fancy, but it works.
Super basic, functional, which is all that matters.
So here it needs to do list box.
I assume selected index would be it could probably be null or or not null but probably negative one.
do that otherwise make an action here probably.
Come on. That fingered that pretty good.
Stop it now and fix that.
always forget action is the return.
Okay. Yeah.
Let's call it that.
Dean, Devonish, rot.
I'm sorry. I'm horrible at uh Indian names and of that region. Um, okay. You know, things are hard like everybody. Things are never easy.
Uh, let's see. Sorry, I noticed I was quiet for a very long time.
Let's see. Question. Where do you think a person who knows just know C++ should look in the world to get better? I mean, look, I don't know. Um, looking doesn't seem great. Great. I mean, there's some good streamers that talk about C++ and there's one guy I think I saw that like reviews C++ code and kind of gives tips and stuff and that could be interesting to watch, but end of the day, you have to actually do something with it otherwise it's not really that interesting, you know. Uh, I think you have to actually uh actually work on stuff.
Um, I think that's how you learn the best and how you get the most experience is you do things. So, take your knowledge and do something with it. You know, don't just uh if nothing ends up selected.
I had to verify something here real quick.
Okay. Doesn't do anything there. Good.
All right. So, I have basic dialogue that works. So, next step is to have it actually open something. So, that's a whole other thing. So, I think uh let's see. So, the scene is the thing that actually loads everything.
And I do see what's the right way to do this. So, scene is the thing that does the actual loading of a scene.
Uh uh uh not going to worry about things like saving the existing scene or anything like that. I just want to worry about loading So, I'm just going to take get the scene and call load and we'll see how things turn out.
I think that's the easiest way to handle this, right?
Um because that directly calls that as long as I structure it the right way, it should load it the right way. So, we'll see.
I guess I should probably make it unload a scene first, right?
What does it do to unload a scene? Does it Maybe I've never had a feature to unload a scene.
It should be pretty straightforward though.
There'll probably be some dangling references to stuff that I'm not expecting. But I think basically I need to basically make sure all my removed is called on everything.
I basically need to go through all the entities and call remove on them one at a time.
I think that's probably the right way to handle that calls remove normally.
Create action, delete action, prefabs, projectile manager.
Okay.
I'm going through all the entities and close the scene. So, let's let's just add a function for doing that.
Void.
We call it unload.
call entities to list which it's already a list but what that does is make a copy of the list so that I don't mess with that probably the slow way to update everything but it ensures that everything gets cleaned up uh and in the end everything here should be empty in theory I could probably put in some assertions for all that. I'm just going to say seen dirty false. It's not dirty.
Can we even use that?
Oh, it's used for that, right? For updating the scene information because it does a drawable sort and a couple other things.
So, yeah, I mean, that's perfectly fine.
I don't know how the game's going to react with an empty completely empty scene. So, we'll see.
It's going to load the scene. Let's start there and see what happens.
I don't know what's going to happen when I do that. So, let's find out.
I mean, one thing I'm a little worried about this going to unload the player, and that could be bad, but let's find out.
Sometimes just trying it is better than hypothesizing.
So there are how many entities? 75 entities in the scene. Now there's zero.
Nothing left in the lights or anything else. And I'm pretty sure at this point I mean it's out of the entity list, but I think the object still exists. It didn't crash. So that's something.
Uh if I create something still works. That's cool.
I can't fly around though because my entity is gone. My camera is basically stuck in the last place it was.
So that's funny.
But all the other systems are working.
So I just need to make sure that I don't unload the player. I guess basically it's the one thing I can unload when I unload the scene is that that's totally funny.
Oh gosh.
Let's see.
Yeah, I guess the network went down or something because I don't know if it was me or the internet because it went down to like three players to three viewers and then everybody came back.
Could just be the streaming service.
All right. Am I still here?
Yeah, I'm still here. Okay, so that's all working still.
All right. So, that worked.
It created everything. Oh, what am I running into there?
Invisible geometry.
Oh, wait. What about this thing?
How did that end up there? Oh, I think there's some code in there that says if there isn't one, create one.
Is it running into that?
Yeah, there's some collision there. I bet you there's some collision object that isn't getting cleared whenever it gets seen as destroyed. Um, have some debug helpers for this.
Helpers don't render the collision. It renders the uh See how the clustered lighting works there.
My light volumes don't really show very well what's happening. The each bullet spawns its own light. So that's why it does that. It probably doesn't need to do that.
So it makes it generate multiple lights.
And then you can see how like they're going on forever. So that's probably not good either that they basically don't die after a certain amount of time cuz like I'm just adding more and more lights into the scene.
Uh, tan guy sheer shiner shiner shiner.
Hello Tom and hello everyone. Thank you for these lessons. I mean, I don't know if they're that you tell me if it's useful. I don't know if they're great lessons. They're lessons.
You know, me cobbling through stuff. So, yeah, that's kind of bad. I need to fix those things to actually die after some time because that's kind of ridiculous that those are still going. There's still 20 lights out there in the scene for no reason.
That's probably not great for performance.
Um, but whatever. All right, so closing a scene works. Let's open a scene.
So, I'm going to Come on. Uh, editor.
So, this is not going to work because I'm going to be passing in the full scene. And what I really need to be passing is the is the uh what does it need? It loads it through load scene file name. So, it just calls open stream. So it assumes that the scene is uh yeah, it doesn't go through the content pipeline. It just loads it directly from disk.
um because it's just a raw XML and we talked about like we could serialize that into a binary format, make it fancy or whatever, but it's not important right now.
So, open stream that. So, I need it to be relative to the content folder basically.
So, and that's what happens here when we when we open this thing.
It's you know I have the content path.
So I need to store this content path and then remove it.
And then I think and let's see. I have hit or miss luck with this.
Let's see if that does what we expect it to do. I don't trust that it will. I think it'll probably leave a slash or put a dot dot something in there, which I don't necessarily want, but it's probably better than just trying to manually hack it or do something kind of lame like subtract the length of the string or something like that.
Don't like junk like that, but you know, it's doable, I guess.
need to make this window center and be bigger size. So I'm going to load this other level open.
So content path is ascent demo. It's that relative. Hey, it did exactly what I wanted it to do. Imagine that. Let's see. Unload then load. Load scene.
It did not open.
Why didn't it open?
File not found. Why would it is a file not found?
Um, let's check. I wonder if it's I wonder if it needs a leading path marker. Maybe it doesn't need any relative content.
I forget. Just going to set a break point there and see what happens when it loads the scene normally.
Uh, what did it not like?
That looks the same, right?
Store this.
And that looks the same, too.
I mean, slashes and junk, but notice it's loading the same prefab multiple times.
That's not good.
Oh, I see that is the reason it is grabbing it relative to the content path and this is assuming that the path is underneath it. Yeah, I think I see what the problem is here.
Yeah, it's it's relative to itself.
I don't know if I can go any further further here. Yeah, it's looking relative to this and my open isn't trying to do that. It's trying to read it out of the other path. It's trying to read it out of this path which isn't where it's looking.
Wants to look the other path and it can't read in this other path because it's way down in here.
Oh god, this Oh, Microsoft. This command line resource So annoying.
Oh, but that's the content builder anyways. But it it was looking in there, but really it needs to look way over here. So I can't This is where it gets a little tricky because it's like, well, what file am I loading? Am I loading the output one or the input one? And I think the output one is the one I'm loading, but it's not very flexible for what I'm trying to do here. Um, I think what I need to do is All right. I think I need know what I need to do because I need to be able to work both ways. I think um It's all really tricky.
I mean, this is where the editor has to know that there's a runtime in an editor kind of case.
The 20 games challenge. Not heard of that before.
Let's look at it real quick while we're here.
Cool.
It's a fun little project.
Pong, Flappy Bird, Breakout, Jetpack, Joy Ride, sort of a Flappy Bird.
Kind of jumps around a little bit, River Raid, Space War.
Yeah, that's a fun list.
Yeah, starts to get kind of hard down here, huh?
Roblox I'm not sure why you're talking about Roblox.
Hang on a second. Something came up.
All right.
Sorry, he's having to put out a fire.
All right. Sorry about that. So what I think I need to do is I need to do something like this. If this is really only for editor AI then up here. Um, all right. So, that fixes this in editor mode. Say if it's a rooted path, just open it directly, but only in editor mode. And then in here, I can fix the call here to not do this relative which I don't love, but it's something.
Sean Smith.
Um, yeah. Tell me everybody like let me know what you think about this time schedule. I moved it back because it seemed like, you know, it was pretty early in the day for some people. Um, but I'm willing to change things around.
So, let me know. But thanks for checking in.
So come in here. Go file open. This first one go open. It's going to have full rooted path is rooted. Yes. Open scene.
So it did it. It's going to load.
Okay, it loaded. So there we go. We have scene loading now.
seems to be working fairly good.
Nothing blew up at least.
Again, it's just loading an XML file.
There's no other data files it's reading from there. So, it's it's pretty safe what it's doing.
Yeah, it's it's leaving some collision data and stuff like it's not cleaning up some of its collision information.
There's like some stray collision in here.
Probably should make sure it also clears undo redo when I'm doing this.
There I'm back to the original level.
So cool. So loading scenes works now, which also means that loading prefabs should work.
So if I come in here and take like this flicker box or this whole prefab should open just the hole.
And in theory, I should be able to change just the hall.
See, it keeps adding in this one global.
Uh, it adds this in. Like there's some code in there that says if there isn't one of these, add one because it needs it. And uh, I need to fix that so that this one isn't saved or because I don't want that to be in prefab.
so bright because this has like a very bright default uh lighting.
So yeah, interesting.
So yeah, so this is working. I just need to make sure save works in a reasonable way.
Um, so let's test that. So we have this opened.
I'm going to move this over here. Or what's something more visible, I guess?
Uh, let's add a second light and duplicate that guy. Move him over here.
And I don't think these aren't attached or anything. It's loaded as a scene.
They're not they are attached. It is a prefab, but they're prefabs don't necessarily make things relative to each other. And I never fix the relative stuff to to do the right thing. Um, I don't remember what the keyboard commands were for attaching things, but you know, let's leave this alone. Let's see what happens when we do it this way.
Um, also means you can put things in prefabs and they don't necessarily parent, I guess, which is maybe bad. So, I'm going to hit let's test save uh real quick.
Oh, that's bad.
level file. So, it's going to save it to level file. So, that's not a good way to store, you know, what current level we're on in game manager.
Um, let's go fix this real quick.
I mean this is only really needed in uh in the case of the editor really guess this uses it. Who signs it? Set level files assigned by something I guess.
Yeah. The startup process says game manager. Set this as the level that you're loading.
So that's fine for that.
I mean, I could keep it there and that doesn't hurt anything like like actually it's because of this. It's like very much like oh this is the folder to this It's really the level name.
Okay, I need to clean this all up.
Um yeah, cuz this is the level directory. Then this is the name of the level folder and this is the name of the level file itself.
So yeah, not super awesome.
Uh, What's the best way to do this?
Uh, okay. Let's do it this way.
Let's fix level file to be the actual level file.
It recalls this needs to actually set the correct level.
Just move this way out here.
So that that works that way.
This just works this way.
And it means that this can call.
Not the greatest, but I'll take it.
At least it ends up with the right name, right?
All pretty gross though.
And you would think maybe the scene should sold on to what level it loaded.
That might be a little nicer.
Also, I guess I need to fix this other I don't need to do that anymore.
because that is Yeah, I need to check into this real quick.
Yeah, that made a mess of things, right?
Yep.
I think all it needs directory I think I just need this.
Nope, that's not the right place.
This is making a bunch of assumptions as well.
It um yeah, the structure is just in a different place. That sucks. That sucks.
Okay.
hacking here. this it's going to be uh I need to call the we know that this is going to have a relative path uh or it should have a relative path to the to the file.
Gross. Don't love it.
Here's the fun part of gamedev.
It's all based around this two different path problem.
So I need the right path to save it to.
That's one thing. And then there's a different path that needs to be in level file because level files path is going to be Yeah, I just have to clean it up on both ends. Like this isn't going to work exactly because that's not going to have the asset the content folder in it because it's removed.
So let's make this path relative to content. So content always has to be appended to it but nothing else.
So let's do that. Let's going to be easier because we can move where the contents at.
Okay.
So, it's going to be this.
So, that makes sense.
I just need to fix this.
to be that.
And then here needs to do.
I think that's going to work.
that freaking thing.
It seemed to work.
Okay, it loaded.
If I hit save, that looks correct.
I think it put it in the right place.
Let's verify.
three. Is it modified today? Yep, it's modified now. So, it did the right thing there.
So, that worked.
And the question is, if I come in and open, does this do the right thing?
content assets level one gets that the content source path makes it relative to this. Okay, but it still needs to remove it needs to remove content and assets.
So, I need to take this and Okay, do this.
Sure, that's going to be broken for right now, but that's fine. We'll do it again. Probably could have done it all again, but whatever.
Wait, no. Was that right?
Yeah, that's correct.
I think that's correct.
We'll find out.
Come on. Why did you open? There we go.
Directory is a demo directory demo assets demo content assets levels level one level.
Okay, that looks right.
Loaded properly.
And I'm going to make one of these lights flicker.
Save it.
Um, it's always nice to make things feel more alive.
And this thing is bright.
I need to fix this color picker so badly.
It's such a shitty color. It's made it darker. Did that.
Um, hit save. It's going to come here.
Directory content assets key venture level file complete level file content assets levels level one level. If I look in here one level that should change.
Yep. Changed.
Okay. So, it's working. It also means that I can come and hit open and open a prefab.
Problem is the prefabs still don't load from the right place.
Like I need to make it a special case.
The prefabs have to load from the asset path when you're in editor mode and not from like all of the all the assets have to load from the asset path in editor mode and not you know from the built assets.
I mean the textures the other stuff that could come from the built assets but this coming from the built assets. I mean until we have the I mean this will be solved by the content server because once the content server is running it'll fetch things for us when they're dirty.
So I can open that scene.
It will set the level file prefabs hall. Yep. So it's level file.
And when I come in here and grab this guy and duplicate him, bring him over here.
Something like that.
File. Save. Prefabs hall one. I should see prefabs hall one change 24.
It changed I think. Did I have it open?
No, I didn't.
It changed.
That said, when I open it, it's not going to open it from the right place, but I have to load the scene again to see that changed. So, let's when I do this, you're going to see the content builder build because it's going to build the it saw that that XML is changed. It should build the XML here, which is just a copy. Yeah, hall and level got copied across.
So, it does the right thing.
All right. So, we should see Yep. Look at that. So, the prefab worked. It has that there.
So, yeah, that's awesome. So, you can now load and save prefabs.
There's still some problems related to content copies that, you know, I think I'm going to let the content builder solve and uh and not me doing some manual work here. Yeah. So, this is working. Um, it's doing what I wanted it to do, which is, you know, allow me to open up a a prefab, make some edits to it. The problem is that currently it doesn't uh it's not live. I can't go and edit this prefab.
Like, it'd be nice if I could select the prefab here.
Need to fix that selection. It's very I mean, I understand what's happening because I can I know how it works, but most people won't. See, there's two icons overlapping here. When I select one, the one that I select goes away.
That's probably not the best. It should probably stay there, but maybe change the icon in some way.
Um, maybe it should pulse or something. Um, and then so I know I'm selecting the mesh and not the prefab. So I'm selecting the mesh within the prefab.
Um, but if I click again, it's going to select the prefab and not the mesh.
Oh, and it hides the the icons for the rest of the prefab when you select them.
So yeah, I can probably do something better about that selection process there.
So now I'm moving the prefab, which moves everything, which I guess Wait, is that That's interesting.
I guess the prefab is But I didn't think it was before.
Oh, I think maybe the prefabs like it always attaches everything with the prefab. That's interesting.
Rotate it.
It's working.
Need to go look at that real quick.
Okay. The um it's interesting. It's technically not parented to it.
But I think they're all parented to the prefab. Yeah. So that's the thing is like these were parented before as children here. They don't technically have to be now that their parent is the prefab. They don't need to be attached in this way. They can be free, right?
Uh but since we removing the prefab, I guess that's the difference, right? Like if I come in here and undo what I just did there.
Wait, I can't undo.
Why can't I undo?
I'm not sure why undo is not working.
Sometimes it gets blocked. I think it's like a text edit or something in here.
Screws me.
weird. Anyways, um if I move the mesh, you'll see the mesh moves, but the other light doesn't because this light is this one down here, and it's not parented to the static mesh. So, I can move the static mesh within the prefab because you can modify the prefab. You know, it doesn't save properly in this case, but you can modify the prefab this way. But this isn't parented, so that's why it doesn't move. But if I move the whole prefab, it all moves together because they're all relative to each other.
Actually, it keeps the original prefabs relative information. So that's why it does it that way. Okay. Interesting. All right.
So yeah, John Smith, by the way, the aesthetics of the game grown immensely. Thanks. Um uh or you had some other posts. uh path combined in line 329 should be further subdivided between content and assets otherwise it will work on Linux Mac I don't know if this applies to the scope of the project uh should be further subdivided between do you mean the path dividers I don't know I'm not sure I mean that's something we definitely need to work on and make sure that it works there uh but I haven't I haven't spent time on that I'm a Windows person not a Mac Linux person So, it's hard for me to give judgments on those things, but this is basically working. Um, what it definitely needs is it needs to I mean, there's a couple things that need to happen to make this system more robust. I need to have a binary representation of the uh prefabs that allows for easy cloning of them.
you know, an in-memory binary representation that allows me to clone a prefab very quickly because currently when you look uh we saw that earlier when I load a scene here.
You'll see that it's like file name.
Okay, we're loading the level. That's fine. Then it's like, hey, I'm loading flicker box. That's a that's one prefab.
Here's another prefab. Hey, it loads the same prefab again. It's literally loading the free that's loading it from disk. So, it's deserializing the same prefab multiple times for no reason. Um, the system could be smarter about that.
the prefab system could be smarter about that and say, I'm gonna load it one time, but I have a I need to be able to clone the created prefab so I can clone instances of it without touching disk again.
So, what you really want is a tight a compact form of the information about the prefab without having hitting disk, you know. Um, I could start by just, you know, loading the XML in memory, but you're still parsing XML and that sucks.
You want instancing to be instant and not something that takes some time. Um, so you really want the prefab system to kind of cache those things in memory so you can quickly create new instances of things. Um, you don't want to have like a a prototype that it copies because you know C uh I I've not had great experiences with C uh clone you know systems where you do object.clone clone and it makes deep copies of things. Like I've never had good luck with those things. They're kind of fragile in my opinion. They they based on reflection, which isn't the greatest. You know, we have a reflection system built into the game. You know, um if you look at how the entities work, they have these uh editables in there, and that's basically what it loads from disc. So, I already have a system. I just need to take advantage of that to build a binary representation in memory.
Then that binary representation is used to make instances of things that can do them really quickly because it's just saying, you know, what's the type? Here are the properties. Set the properties go. You know, it's it's a very quick way for it to work instead of the slow path.
So yeah, that's what I'm hoping is that I can fix it to have a fast path for that. That will make it keep from loading it those things multiple times.
even though it's not a big deal now.
It'll become a bigger and bigger deal as you build bigger levels with more stuff in it. All right. So, did we learn anything today? No, not too much. I guess we got ourselves a nice little uh not nice, but an okay. Hey, we know what our CPU time is now compared to our frame time. We know our frame time is pretty bad. Um, we know it has nothing to do with debug release. It has to do everything has to do with shaders.
um and the amount of stuff that's being rendered. In fact, I think it's probably all tied up in the lighting. And I'm sure that if I disabled the lighting path or had the lighting path uh not generate as much lights, like so it's going 15 milliseconds, 14 milliseconds, right? If I come in here and go to our light clusters and instead of storing uh let's see, here's the code that bins a light Uh I'm going to do something very simple.
If I have it skip putting things in clusters if the count uh didn't like huh I don't stamp.
That's a just a list, right?
And of course, it's Oh, what the am I doing? My brain's not working, I guess.
Duh.
So, the count's greater than zero, it's going to skip. So, it's only going to bin one light per per cluster. So, what does our frame rate look like now? So bidding one light per cluster brings our frame time down to seven. You know, that's the problem is the the loop that it does for every light is too expensive. And that's where all our frame time is being tied up in. Um I don't have shader debugging on, do I?
Make sure that that's not happening because that would definitely not make it uh as performant.
Builder Yeah, I don't think it is.
So, it would have to be here if it was.
So, yeah, it's not running debug shaders, but this is the frame rate we get. So, almost all the time is tied up in the light shader. um like so it was like 13 milliseconds before and now it's six. So it's like half the time is based on the number of lights that are there.
And in fact I bet if I increase the number of lights uh I'm going to go to two get some more lights in there. Didn't affect the frame time too much. 7 milliseconds versus like six.
I'm going to go to six there. Frame time down to nine milliseconds. So, as I'm adding more lights per cluster, it's starting to get more and more expensive.
You can see like that's a light. You can see that like we're that's like it was able to fit it into the cluster, but if I turn a little too far, you see this is where I think the bidding isn't working properly.
Like I think that the binning isn't working properly and that's why those are being omitted there on the sides when they shouldn't be. So it could just be a binning problem that is causing it to have more lights in a cluster than it needs to have. If that's wrong, if that math is just slightly wrong, it's enough to maybe screw things up pretty bad.
Yeah. So that's that's the problem is it's it's definitely the uh the light shaders time. So, I need to look at my bidding and make sure that's all really tight because if that is not perfectly tight and the math is not exact, it is going to be bad. And uh then I just need to look at like the actual cost, the actual lights. You know, at the moment, I haven't really done too much to uh to improve it. But, you know, this is the uh this is the processing it does for every light. You know, it samples this texture two different times.
Um, that's probably bad.
Three different times.
So, that's not good. Probably be better if it sampled that like one time, right?
Um, yeah, these samples are are definitely not helping me guaranteed.
Three samples per pixel, you know, just for lighting information per pixel per light, right? So, this is probably the worst of it.
So, that's probably a big chunk of it.
Um, the math is probably not as big a deal even though these could probably be very expensive or kind of expensive. I think the math is less of the deal. But also, there's some optimizations here probably that I'm not handling. Like this normal um I guess that normal is per light.
So that normal is for the scene, right?
like the normal is the same for every light. However, when it comes in here, it's doing uh light direction doesn't need to be done, but view direction and in this don't need to be done.
So, it's kind of like it could probably be more optimal. And I don't know if the if the shader is optimizing this far ahead. Maybe it is.
Maybe it's doing a better job optimizing it than I'm thinking.
That'd be nice. That's something we have to check, right? Um, but yeah, that stuff's probably not the greatest. But this is probably a bigger deal. Like distribution half is light direction, P direction. So, that does need to have to be calculated per like what's in here that probably doesn't need to be per pixel. This is probably all very expensive and I could probably be doing this with lookup tables better than everything else.
I'd have to really look at the optimized shader just to see like are there things that I could be doing better. But probably the biggest thing the shadow sample is actually pretty cheap compared to everything else because it's just a single shadow sample. Um I think it's actually currently a single shadow sample. I forget. Uh, it's in our shaders.
It does some math. Um, because it has to look up the right shadow and thing, but it's it's fairly straightforward. Um, this PCF sample, I think, is actually doing a pretty cheap thing or nothing at all.
Yeah, it's doing a fairly I mean this is kind of an expensive PCF but um actually it's pretty small just like three samples. Um we could probably be doing it better more optimized version gather function instead of just a regular simple texture.
Um so yeah, these could be better but you know this is probably hurting me the most that you know I'm looking up so much lighting data. Uh, sorry, wrong thing.
This is probably what's hurting me the most, you know. So getting a getting some of this stuff out of here or trying to optimize this or pack this in a better day better way.
Yeah, packing that into a better into a better format might help a lot. Anyways, or really maybe it should be separate textures. That might actually perform better than doing three samples of the same texture because I think it could do in parallel if I think if I remember correctly. Anyways, so yeah. Uh I think that's it for today.
Um sorry it was kind of boring. Oh, I just didn't have any great ideas for today and I was kind of stuck with stuff and kind of wanted to do simple things today and not anything complicated.
But thanks for watching. Uh, as always, uh, you know, follow us on Twitch and YouTube. We're trying to increase our counts. Um, where we at on Twitch now?
Um, and I can never tell where we're at, so I can't ever read the thing is. some of these websites, everything is so Oh, we're at 105 followers out of uh Oh, we have a goal to get to 110. We just need five more. Five more followers.
We'll get there.
Uh YouTube's been doing pretty good lately. We've been putting up some new videos, uh some new shorts that are pretty exciting. Uh go check those out.
Uh also donate to Monogame that helps us get move things forward. We have a lot of cool stuff coming and you know donation of not just money but your time looking at issues, reporting issues, suggesting features, those all help us.
So for sure do that. All right guys, thanks. See you guys later. Bye.
be peepoo.
Videos Relacionados
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
Re: 🗣️📍theprophedu📍2026 GST 103 CLASS (E-EXAM REVISION)
theprophedu
636 views•2026-06-04
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Instagram accounts got PWNed
EricParker
13K views•2026-06-03











