Skip to content

On-demand part and model textures via unity mipmap streaming - #418

Open
Phantomical wants to merge 6 commits into
KSPModdingLibs:masterfrom
Phantomical:streaming-mipmaps
Open

On-demand part and model textures via unity mipmap streaming#418
Phantomical wants to merge 6 commits into
KSPModdingLibs:masterfrom
Phantomical:streaming-mipmaps

Conversation

@Phantomical

Copy link
Copy Markdown
Collaborator

This PR uses unity's mipmap streaming feature to stream in part and IVA textures on demand. This means that you get to set a memory budget and unity will take care of automatically streaming mipmaps from disk to vram depending on what parts are currently visible.

Here's how it works behind the scenes:

With a few edits to these two we can:

  • enable mipmap streaming on all textures we load, and,
  • calculate the appropriate UV distribution metrics for all meshes loaded via mu files.

As it turns out, that's basically all you need to get mipmap streaming working. We can set QualitySettings.streamingMipmapsAddAllCameras, then toggle whether it is enabled using QualitySettings.streamingMipmapsActive.

I don't have a profile in front of me right now, but the overhead for this looks to be about 0.5ms/frame. On the other hand, for an install with many part mods it looks to be able to save up to ~5GB of VRAM.

A testing build is available here for those who want to try it out
KSPCommunityFixes_1.41.1.zip

Mipmap streaming (safety valve): bake m_StreamingMipmaps into eligible
bundle textures, enable QualitySettings.streamingMipmaps* sized to a
fraction of VRAM, pin every streaming texture full-res on load, then
release mesh/part textures at their bind sites (ModelInstructions plus
two PartLoader postfixes) so only renderer-owned textures drop mips
under real pressure. Eligibility gates on >=4KB mip chain and mip-level
block alignment under the deepest reduction.
@xCuri0

xCuri0 commented Jul 30, 2026

Copy link
Copy Markdown

Some IVAs have blurry textures on displays, besides that can't find any obvious issues.

Screenshot (3385)

Still it's way better than before I couldn't install more than one IVA pack without the game crashing from out of memory now can use multiple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants