Sven's Avatar

Sven

@embersarc.bsky.social

hobby gamedev working on a spaceflight simulation game

403 Followers  |  337 Following  |  100 Posts  |  Joined: 20.10.2024  |  1.9804

Latest posts by embersarc.bsky.social on Bluesky

Same scene but with 220 instead of 20 FPS.

Same scene but with 220 instead of 20 FPS.

With an improvised workaround we're back to a decent frame rate!

13.10.2025 10:32 β€” πŸ‘ 5    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Preview
Memory leak in `EntitySpecializationTicks` and `SpecializedMaterialPipelineCache` when multiple materials are present Β· Issue #21526 Β· bevyengine/bevy Bevy version and features 0.17.2 What you did This came out of a longer debugging session I "documented" in a bluesky thread. //! Example to reproduce memory leak issue. //! use bevy::{ pbr::{Exten...

Hyperbole aside, I was able to reproduce it in just a few lines of code: github.com/bevyengine/b...

13.10.2025 10:32 β€” πŸ‘ 3    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

back at it now and boy do things look broken beyond belief

12.10.2025 22:10 β€” πŸ‘ 4    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

With that fixed, EntitySpecializationTicks is another map that just keeps filling up. The reason might be related. Time for a break for now though.

12.10.2025 14:40 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

Ah I had this backwards. Them being removed means that the `contains_key` check can return false and the cleanup later can actually happen!

12.10.2025 13:40 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
Post image

Through trial and error I found that running the early sweep before the specialization function actually fixes the issue.

But that doesn't make sense. The early sweep only removes cache entries and doesn't add any. So something else must be going on there.

12.10.2025 11:43 β€” πŸ‘ 3    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
Post image

Why are those material instances not present?

There are three systems that modify them. The extract and the two sweep functions. The extract function is the only one that can add the instances. The sweep functions only remove them.

The ordering appears correct.

12.10.2025 11:40 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
Post image

Now there *is* code to remove the cache entries when a mesh is despawned. In my case however, the loop early-exits most of the time at the first `contains_key` check and so doesn't get to remove the entry in the next step.

12.10.2025 10:11 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
800000 entries and growing...

800000 entries and growing...

Printing out the number of cache entries shows that they grow indefinitely with each spawned terrain chunk. Despawning chunks however does not seem to remove their cache entry.

12.10.2025 09:32 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
Post image

Luckily bevy is open source, so we can just take a look. Those functions have one thing in common: They all access the `SpecializedMaterialPipelineCache`.

12.10.2025 09:25 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
Post image

Inspecting a frame in the profiler we find those three function calls taking about 50ms. How do they spend all that time?

12.10.2025 09:21 β€” πŸ‘ 3    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
18 fps with a tiny window and not much going on.

18 fps with a tiny window and not much going on.

I realized that the frame rate of my game was going down the more I played.

Let's debug!

12.10.2025 09:15 β€” πŸ‘ 11    πŸ” 1    πŸ’¬ 1    πŸ“Œ 0

For orbital motion I have a separate physics engine that models trajectories with patched conics. So it boils down to a bunch of two-body problems that can be solved with the Kepler equation :)

30.09.2025 06:04 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
The egui "before" image. Looks fine.

The egui "before" image. Looks fine.

The Bevy UI "after" image. Looks similar but overall a bit more polished.

The Bevy UI "after" image. Looks similar but overall a bit more polished.

The egui -> Bevy UI rewrite is complete!

Quite happy that it was possible to reproduce the look and feel from before and even improve on it a bit :)

#bevy #gamedev

29.09.2025 17:07 β€” πŸ‘ 34    πŸ” 2    πŸ’¬ 2    πŸ“Œ 0

It's definitely easier to use. Functionality wise I haven't had issues with either so far.
Not sure about height maps, I use plain trimeshes for the terrain chunks.

23.09.2025 16:44 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
A demo of the UI without the rest of the game.

A demo of the UI without the rest of the game.

Currently porting the GUI from egui to #bevy UI and quite happy with it so far! The only thing I'm missing is the ability to render arbitrary meshes as part of the UI.

Image nodes are super useful. I'm using one to show the navball which is a 3D scene rendered to a texture.

#gamedev

23.09.2025 16:04 β€” πŸ‘ 30    πŸ” 2    πŸ’¬ 0    πŸ“Œ 0

You're absolutely right! The landing pad is about 75m wide. I should add a banana for scale or something.

21.09.2025 21:48 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
Post image

I switched to the Avian physics engine! Its excellent documentation made this a pretty simple process.

The physics now run at a fixed rate, independent of the frame rate. This helps a lot with determinism and things keep their velocity, even if the rendering isn't fast enough.

#bevy #gamedev

21.09.2025 21:07 β€” πŸ‘ 37    πŸ” 6    πŸ’¬ 2    πŸ“Œ 0
Video thumbnail

I added a hover mode to the spacecraft controller! It tries to keep the craft level at a fixed altitude so that the player can precisely maneuver across the ground.

Oh and also it's now possible to load in any 3D scene with colliders, like this makeshift landing pad.

#gamedev #bevy

13.09.2025 17:15 β€” πŸ‘ 23    πŸ” 2    πŸ’¬ 1    πŸ“Œ 0
A planet seen from a couple hundred kilometers above the surface. There is an ocean now and its color changes based on the height (or depth) of the surface below it.

A planet seen from a couple hundred kilometers above the surface. There is an ocean now and its color changes based on the height (or depth) of the surface below it.

The same planet from further away.

The same planet from further away.

Finally got around to adding oceans to the planets!

It's just an additional opaque mesh on top of each terrain chunk. But changing the water's surface color depending on its depth is so simple yet so effective at faking actual translucency.

#bevy #gamedev

04.09.2025 17:10 β€” πŸ‘ 34    πŸ” 2    πŸ’¬ 0    πŸ“Œ 0

Actually I was on holiday in Stockholm, great city, might have eaten too many Kanelbullar

Back at work now cooking up some cool features, stay tuned

24.08.2025 14:24 β€” πŸ‘ 3    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Video thumbnail

Apologies for the lack of updates, I was chilling at the top of the highest mountain in the solar system

#gamedev #bevy

24.08.2025 14:24 β€” πŸ‘ 31    πŸ” 5    πŸ’¬ 1    πŸ“Œ 0
Instead of being completely filled with color, the terrain chunks are black with a little colored square in the center.

Instead of being completely filled with color, the terrain chunks are black with a little colored square in the center.

One reason I enjoy shader programming is that at least bugs are entertaining

07.08.2025 19:57 β€” πŸ‘ 11    πŸ” 0    πŸ’¬ 2    πŸ“Œ 0
Video thumbnail

Currently writing a controller to enable some cool takeoff and landing modes. The idea is that the controller should make such maneuvers relatively easy and intuitive as long as the ship's construction makes them physically possible.

#gamedev

04.08.2025 21:33 β€” πŸ‘ 39    πŸ” 6    πŸ’¬ 3    πŸ“Œ 0
Before and after view of a moon's terrain. The "after" image contains some green rocks spread across the surface.

Before and after view of a moon's terrain. The "after" image contains some green rocks spread across the surface.

Experimenting with some close-up terrain detail textures. I like how putting some green rocks on the closest moon to the gas giant ties the scene together :)

#bevy #gamedev

03.08.2025 11:36 β€” πŸ‘ 24    πŸ” 4    πŸ’¬ 0    πŸ“Œ 0
A spacecraft shaped like a lava lamp turned on its side with some fins on the back.

A spacecraft shaped like a lava lamp turned on its side with some fins on the back.

Working on a new aesthetic for the spacecraft model. The technology in the game should be more of the "far future" kind. This will do for now.

#gamedev

02.08.2025 20:09 β€” πŸ‘ 13    πŸ” 2    πŸ’¬ 0    πŸ“Œ 0
Before and after comparison of the moon from far away. The "after" image has much higher detail in the color and normals. The polygon count is still low but that is not visible from this distance.

Before and after comparison of the moon from far away. The "after" image has much higher detail in the color and normals. The polygon count is still low but that is not visible from this distance.

The solution: Just fall back to the color and normal from the texture I generate for the map view. More detail without having to increase the polygon count!

#bevy #gamedev

31.07.2025 19:15 β€” πŸ‘ 11    πŸ” 4    πŸ’¬ 0    πŸ“Œ 0

The new terrain system had one drawback: The generated lower detail chunks did not have enough texture detail. A quick fix would have been to just subdivide them more, but that quickly blows up the memory and we do not actually need the additional geometry.

31.07.2025 19:15 β€” πŸ‘ 3    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

I should stop taking screenshots on a bright screen in a dark room.

But hey at least the brightness is somewhat appropriate for the distance from the sun.

29.07.2025 14:22 β€” πŸ‘ 4    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

No overhang support unfortunately. I had to pick my battles and decided against them in favor of a much simpler and more performant solution.

28.07.2025 20:53 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

@embersarc is following 20 prominent accounts