asset system refactor + some editor stuff
been wanting to redo how assets work for a while now.
until now scenes carried the asset definitions with them, and loading scenes would keep throwing resources into the global resource manager. worked fine enough , but it also meant resources could kinda just accumulate forever..
i seperated them now!!
assets.json
projects now have a project-wide assets.json catalog.
textures, shaders, meshes, materials, fonts, animation sets, etc. live there instead of getting serialized into every single scene.
scenes / prefabs / UI / animations etc. just store resource IDs and the definitions live in one place
besides making scene files considerably less bloated, this means saving a scene no longer serializes whatever random collection of resources happens to currently exist in the resource manager
lazy asset loading
having one project-wide catalog does not mean loading the entire project into memory.
scene loading now scans for the resources that scene actually references and loads those from the catalog
this includes stuff referenced by:
- entities
- maps / tile types
- UI
- post processing
- spritesheets / animators
dependencies get resolved too
so if something needs a material, its shader + texture get pulled in first. animation sets pull in their spritesheet texture, etc. etc.
now the the resource manager should only contain what is actually being used
asset lifetime stuff
added SceneAssetScope for keeping track of what assets a scene has acquired.
assets are retained while something needs them and can actually be unloaded once the last scope using them disappears
so changing scenes repeatedly should no longer turn the resource manager into
yummy more objects :O
forever….
persistent entities reacquire the resources they need when moving between scenes too.
there’s also handling for catalog entries being replaced / deleted while their old resource is still loaded. those can be marked stale and discarded safely once the old scene lets go of them instead of leaving weird zombie resources around.
engine assets still stay around like normal.
editor asset workflow
the editor now goes through the asset catalog too.
creating / importing / replacing / deleting things like:
- textures
- shaders
- meshes
- materials
- fonts
- animation sets
updates assets.json instead of depending on scene serialization to preserve them….
supported editor selections / script setters can also acquire catalog assets on demand and attach them to the current scene’s asset scope
old projects
old projects obviously still have all their assets embedded inside their scene files, so I added an ob_asset_migrator tool.
it can scan the old scenes and merge all of those definitions into a project-level assets.json.
there’s:
- dry-run validation
- conflict detection
- optional removal of the old scene
assetssections - backups before it starts rewriting stuff
uses backups because i dont trust myself enough .. might vaporize projects who knows…
docs docs docs
also updated a stupid amount of documentation for the new asset model … since of course..
there’s now a full assets.json format page covering the different asset types, dependencies, lazy loading, asset scopes, editor behavior and migration.
updated the scene / prefab / animation / post-processing docs too since all of those previously described assets as being stored directly in scenes.
also cleaned up the main README + docs index a bit and updated the feature list because quite a lot of it was outdated at this point….
theme presets
also did some work on editor themes.
split the built-in theme definitions out and added some interesting presets:
- Obliberry Dark
- ImGui Classic Dark
- Obliberry Light
ew imagine using light themes…
- High Contrast Dark
- Haxxorman Green
editable and all…
tldr: resourcemanager is now longer an infintly growing landfill…
Comments 1
FIRE
Sign in to join the conversation.