Assets Integration in Blender #46049
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
38 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#46049
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Foreword
This is an updated version of the design proposal for integrating asset concept into Blender, as well as report of current work done so far and roadmap of future development.
Some areas are already quite well defined (and partly implemented), others remain more fuzzy. Design always evolve while you actually implement it, anyway, issues you did not foresee need to be fixed, new ideas come while writing (and using!) code, etc.
Any comment/critic/suggestion is welcome. This page will be regularly updated as work progress, unless some radical change in plans happen, in which case a new version shall rather be added.
Also, a “code design” part is available at the end - this one is really technical and can totally be skipped if you’re not interested in dirty implementation details.
Abstract
Here are the key ideas behind current proposal:
** However, we introduce the concept of 'virtual library', to allow mere image/fonts/videos/audio files to be directly considered as assets too.
Asset
What is an asset? Nothing and everything. From Blender PoV, there are no assets. Blender only knows of datablocks (objects, meshes, materials, textures, images, etc.). From user side, an asset can be anything he would like to manage 'as a whole', to store it somewhere for later reuse, to share, to import, etc. Can be materials, objects or groups defining a character, …
And there are also some really advanced and specialized asset concepts, like e.g. parametric ones used for 'interior design' (to build your own kitchen from basic pre-defined 'bricks'), with complex behavior each time you add or even move those 'assets' in your scene.
Blender cannot define an 'asset' type (datablock) that would handle all that kind of possibilities. It's just out of the scope. Thus, the concept of asset shall be as shallow and minimum as possible within Blender.
"What" is an asset, how it behaves, etc. is defined by the asset engine.
However, there is something about assets that must be defined from Blender side: a minimum set of metadata, used to identify and list them. Here are currently proposed ones, based on mere file metadata (i.e. what we already have in current file browser):
** repositories have an optional path.
assets have a name and description. assets have tags (for filter/categorization purposes).
** assets have preview.
** variants have a name and description.
revisions have no name (their uuid shall be enough usually). revisions have a comment (e.g. commit message).
** revisions have a timestamp.
views have a name and description. views have a timestamp (which shall be the same as the parent revision one) and size info.
Repositories, assets, variants, revisions and views all have uuids (128bits numbers).
Blender identifies an asset by its asset engine and its repository/asset/variant/revision/views uuids.
It should be noted that while this five-levels tree data structure does define to some extent an asset storage layout, it is absolutely not required to follow that layout. For the most part, Blender does not care at all about what those five levels actually are, nor what they actually mean, so asset engine are free to use them pretty much as they like, generate dummy data for levels they do not use, etc. The only strong, mandatory requirement is that the asset engine should always be able to return the path to a single, unique data-block to link, given a set of five uuids.
We may also want to add some kind of 'priority' concept to Blender's data-blocks. The idea behind it is that you may not want to see by default all your loaded data-blocks in the Outliner and/or ID listings. IDs would then get a priority level, and user could chose up to which level to show/list IDs. Asset engines could use this trick e.g. to only show the main item of their asset, and 'hide' dependencies from user by default.
I’m not quite convinced we really need this, however, afraid it would end making both programmer's and user's life harder, by adding yet another parameter to handle…
Asset Engine
Conceptually, an asset engine is similar to a render engine. Blender defines a generic "asset API", and each engine implements it as it needs/can.
An asset engine does not handle loading of data itself (as in, it won't directly give Blender a new mesh data-block, etc.). It is mostly here to gather metadata available (see above) and present it to the user through the API. It can also be used to expose data only available remotely, and ensure it's made available locally (as .blend files!) when user actually decides to use it. It may perform some actions on 'assets' once appended/linked, but it does not handle appending/linking itself.
In other words: it is similar to some kind of specialized file system/database, a bridge between a given asset management system and Blender.
This allows three things:
This implies asset engines are always able to provide real valid paths to their data on request, directly usable by Blender core code.
Aside from that, an asset engine can be:
We can also imagine more exotic applications, like a procedural object generator (pretty similar to 'add objects' add-ons, but it would benefit from a full space to show/list and pre-configure 'assets' before actually doing the generative work). E.g. a 3D fractal generator, a tree generator, …
Since asset engines are mere add-ons, nothing prevent them to add more panels where they need them to provides extra features (like external render engines do, e.g. a material-specialized asset engine could add direct access in material buttons, etc.).
Usage Design/Specifications
Here are some generic use-case scenarios demonstrating how current work is expected to behave.
See also #46059.
Using Assets
That is, browsing them, loading them, updating them… that is the part work has been focused on, so far.
Import
asset engine's pre-import callback is called with selected (entry/variant/revision) items. This callback is expected to return a list of paths to real data. import op actually imports those data (pretty much exactly the same way as current code, the only difference is that a reference to asset engine and asset uuid is stored within IDs).
** asset engines's post-import callback is called with imported IDs. This is for advanced processing, like e.g. applying scripts on those IDs (auto-place/resize objects, whatever).
File Save
When saving a .blend file, there is nothing special to do. Datablocks from asset engines are saved like any other appended/linked one.
File Load
When loading a saved file with some data from asset engine, load code itself is not changed. If the local files from asset engine are still available, asset datablocks will be loaded just like any appended/linked one, otherwise new place-holders system will be used, just as with 'regular' .blend libs (see missing-libs branch).
However, it is quite likely that some lib files will be missing, or a new version of some asset has become available, etc. To handle that, a second pass (after file itself is loaded) will be run, that will inquire relevant asset engine for datablocks that 'belong' to it, and try to reload them if needed (can also check for asset's revisions, to check the latest one, etc.).
Loaded Asset Management
That is, remove an asset from current file, or change its variant/revision. This should be handled by the Outliner (to be consistent with current behavior, outliner is for 'current' data, while filebrowser is to add new data).
There is nothing really specific here, aside one key point (which is also needed for the 'reload' behavior described above): for a given ID, we must be able to reload its data. This would also be more than handy even with current system, since it would allow to 'fix' missing libs easily (see id-remap branch).
Note that in addition to always using a manually specified variant/revision of an asset, there will also be an option to use 'default' variant, and 'latest' revision.
Defining Assets
That is, creating, editing, deleting assets from the proposed collection. This is the second step of the plan, goal is to first have a relatively 'feature complete' version of 'Using Assets' before tackling it. Also, this may need a new space - not totally convinced it would be wise to extend current filebrowser to support that - and yet it would probably share a lot of code with it.
Main task would be to control metadata of the assets (tags, variants, revisions).
There are no detailed plans for this part yet, general idea would be to have two views, one showing the 'asset engine' content (i.e. available assets), the other a 'real' file browser. One could then select datablocks from the 'file' part to define a new asset, or add to an existing one, etc.
Editing the content itself of the asset (its data) could be done e.g. by launching a new Blender instance to make the edits (using a 'forged' Blender file to contain all the asset data, and only the asset data?). Think this should be left to the asset engine though.
Current Status and Roadmap
Current work done (in addition to the full filebrowser rewrite already merged in Blender 2.76) is visible in asset-engine, missing-libs and id-remap branches. The first one contains work done on asset engine itself, the second one the 'place-holder IDs' used to not lose anymore a datablock from a .blend file when it cannot be found on load time, and the third one some (WIP) code to allow replacing a given datablock by another all over Blender.
Now in master, most efforts have been spent so far on enhancing the filebrowser (better previews, better behavior when listing datablocks, more filtering options, etc.), and making it ready for assets (reworking how files are listed…).
In asset-engine branch, a first version of needed API has been written, alongside with a (basically working) asset engine demo, codename Amber.
Roadmap
First goal currently is to finish work in id-remap (think missing-libs is pretty much master-ready), to allow to relocate libs and reload datablocks from them in real time, without having to save and re-open .blend file.
Next step is to finish basics of asset engine part I (that is, browsing/importing libs - already mostly done - and reloading from asset-engine on next opening of the .blend - mostly TODO still, depends on id-remap/missing-libs work too).
Once this is done, a quick & dirty 'asset editing' would be nice, to help testers to really play with Amber (since manual editing of JSon files is not that fun…).
Less urgent TODOs include:
Open Questions
Comments and suggestions are obviously most welcome on any part of above document, but here are some points that still require serious investigation, and some rather speculative possible extensions of asset concept (for when basics are up and running ;) ).
Links/References
There have already been some design proposals about assets in Blender, which helped defining/refining current one, found at least those two:
Code Design
This part is rather technical, it aims at describing how things (will) work code-wise.
File Browser
This part of the work has been mostly merged in master for blender 2.76. The core concepts of the changes are (listing only those directly related to asset engine project):
Thus, filebrowser is now ready to work with asset engines, at least on the basic level.
Appending/Linking and Lib Handling
Here are the points known so far that need to be fixed/improved/implemented in our library handling code (see also #45351):
Addressing Missing Linked Data
The missing-libs and id-remap branches aim at fixing those issues by:
From there it’s rather trivial to add options in Outliner (and/or maybe even any ID UI block) to replace a given ID by another.
The Sub-Datablocks Issue
Sub-datablocks or dependency datablocks (sub-IDs), that is, the ones indirectly linked because they are used by an asset (the materials, textures, etc. of an object e.g.).
Those create a problem when you want to update/reload an asset:
To address that issue, we need a way to know a posteriori which ID is used by which asset-ID (even indirectly). We could do that using some BKE's library_query stuff (though I'd expect some complications with the 'objects-made-direct-links' case), or we could cache it (e.g. in a linked list of ID pointers in each ID) during read/link time.
Solution is being worked on, here are current proposed points:
So asset engines (repository) should make real assets of any sub-IDs user could want to use independently (typical examples: armature object of rigged characters, materials, textures...). Non-asset sub-IDs should only be used by stuff very unlikely to be shared (e.g.: shape keys, probably anim data, etc.).
Non-ID assets
This is relatively restricted in current code: only affects datablocks that are thin wrappers around external files (image, font, text and sound). To implement this:
Call relevant datablock loader. Attach newly loaded ID to virtual library, add its uuid data, etc.
The most important change here is in write/readfile:
Asset Engine
Asset Engines will be mere python addons, communicating with Blender through a generic API, quite similar to how Render Engines (like Cycles) work. There isn’t much to say code-wise here, this is mostly boring RNA mapping code, and usual type/instance structs with helpers in dedicated BKE_asset area…
Data Changes
Two data structs will be modified for asset needs currently:
Changed status to: 'Open'
Added subscriber: @mont29
Added subscriber: @Blendify
Wow... cant wait to see what comes out of this
Added subscriber: @mano-wii
Added subscriber: @JulianEisel
Great @mont29, lots of interesting and valuable information!
Some general thoughts on this:
Added subscriber: @Januz
Added subscriber: @AditiaA.Pratama
Added subscriber: @lichtwerk
Added subscriber: @JonathanWilliamson
Some ideas:
Appended data: I agree that the file should be considered local, but I think a small reference from where it came from might be useful. Just a filepath string or something like that. So in the case someone else wants to re-do a mesh 6 months later, they know where the original came from.
Same would go for linked files made local (I guess they're technically "appended")
Simple storage types: +1! For instance, in a motion graphics workflow audio files and fonts are as much an asset as a mesh. Those filetypes also have metadata that asset engines could grab and use for search/filtering/etc.
Custom asset types: This could be really cool! It could use a general kind of ID like 'CUSTOM_PYTHON' (or something that makes sense). I think it'd be enough with a preview, a category, a description string and a py class. The class would run some code, set some properties and drawing code (for panels) like ops do. I think the more abstract, the better in this case.
Keep up the great work @mont29!
Added subscriber: @gandalf3
Added subscriber: @flav-3
Added subscriber: @sdilmob-3
@JulianEisel Actually, yes, Amber is intended to be shipped with official releases, as a simple local filesystem asset manager, aimed typically at independent artists. Would make a separate addon for BAM really, that would be more powerful but complex system (more aimed at studios), do not think it would be good idea to mix both really.
@Januz Actually, append simply links data and then calls 'make local' on them, indeed. We could e.g. add an option to makelocal to store lib references in localized ID's custom properties, e.g.
Added subscriber: @WeeKwongBong
Added subscriber: @Harvester
Added subscriber: @bliblubli
As we are heading to a revision system for assets, it would be nice to follow git spirit here:
It is essential to make all big changes now and have it flexible if we want to be able to use and build upon this new filebrowser for some years.
Have you thought about integrating USD From Pixar http://graphics.pixar.com/usd/ ?
Added subscriber: @Lapineige
Added subscriber: @JasonSchleifer
Great idea, considering it's going to be opensourced!
http://graphics.pixar.com/usd/docs/Open%2BSource%2BAnnouncement.html
Regarding USD: yes, this seems like a very interesting project indeed. But that would be handled through an asset engine, like everything else. ;)
USD also sounds like a possible fix for that broken joke of FBX… maybe… one day… etc…
Added subscriber: @karja
Added subscriber: @dr.sybren
One thing I miss in the current document is the support of asynchronous operations. it is important that Blender's UI doesn't lock up, for example when network communication is involved. We could leverage Python's asyncio support for this; for a demonstration see my Blender Cloud addon design document at https://github.com/armadillica/blender-cloud-addon#design
One aspect that is worth mentioning is the context object. With modal operators, this object is passed to the
modal(context, event)
function, and is destroyed/cleaned up after that function returns. As a result, the context cannot be passed to asynchronously running code, which will live for longer than themodal()
function call.Added subscriber: @chrisoffner3d
Removed subscriber: @chrisoffner3d
Added subscriber: @chrisoffner3d
Added subscriber: @Dsimovski
Added subscriber: @Brachi
Added subscriber: @ConradDueck
Added subscriber: @Ehab
Added subscriber: @MauricioMarinho
Added subscriber: @0o00o0oo
Added subscriber: @Josephbburg
It's been a couple years since the comments about USD. Now, it's open-source and widely adopted, and Sybren A. Stüvel has done excellent work on Blender I/O (which isn't finished yet, but it's already very impressive!). So I have a question: will it be possible to maintain links to USD's, so that when the USD is updated, the Blender file referencing it will be too?
I think it could work like this: Blender would store a path to the USD to do the linking. A "fake" .blend file would be created, importing the USD once the file with links to USD is opened. Then the links would point to the "fake" blend file with the imported USD. The USD would be like DNA, and the "fake" Blender file could be like a half-way between DNA and RNA--- The .blend file with links to USD would think it's linking to .blend file DNA, but that .blend file would just be a temporary import of the USD. Does this make sense? Of course, referencing USD's directly would also be awesome, and since this format is open-source, maybe it's possible. But I think that would require building the USD I/O into linking and appending.
This would make it really easy for Blender and other softwares to work together seamlessly. I imagine a similar workflow for .abc and .vdb could streamline the process further.
About Appended Data, I think keeping a reference to the asset around is a good idea, if for no other reason than to make it possible to over-write all of the data from that asset by re-appending it. Currently, appending data twice creates duplicated data. It would be nice to have an option to 'update' the appended data without keeping the older version around. Then again, maybe this is backward-thinking, considering Dynamic Overrides will probably solve this problem much more nicely.
Finally, I think it would be really useful to have screen that is a bird's-eye view of the project as a whole: it could be a node-graph showing all of the Blend files being linked/referenced and their relationships to each other.
Thanks.
That's already what we do with Alembic, so I don't see any reason why we wouldn't do this for USD.
Your other ideas are pretty much in line with what we have in mind already ;-)
Added subscriber: @MaciejMorgas
Added subscriber: @item412
Added subscriber: @AndyCuccaro
Added subscriber: @RosarioRosato
Added subscriber: @neosushi68
Added subscriber: @AndreaMonzini
Added subscriber: @frameshift
Added subscriber: @jfmatheu
Added subscriber: @Pipeliner
Added subscriber: @einsteinchen
Changed status from 'Confirmed' to: 'Archived'
Added subscriber: @Summer
Added subscriber: @robblau