I’m right in the middle of migrating all my authoring scripts to use bakers. And I have quickly discovered some pain points that I wanted to bring up.
1) Control over which bakers and baking systems are allowed to bake
I’m aware there’s an assembly filter per project to help with this, but let’s be honest. Most people on the asset store are not going to be disciplined enough to split all their bakers into a bunch of different assemblies to allow for the selective customization people are going to need.
For example, I want to override baking for skinned meshes. Non-skinned meshes are fine, as well as everything else in Entities.Graphics. But skinned meshes require some special processing depending on the project. That’s not possible today.
But the most baffling part is that we have ICustomBootstrap, which does offer an opportunity to have extremely granular control over the systems added to a world. Though I have seen my fair share of issues with package samples included a custom bootstrap that conflicts with the project. So…
A) Can we have a custom baking bootstrap that lets us build the baking world and pass in a list of Baker types?
B) Can bootstraps work like Render Pipeline assets where we can drop in the bootstrap we want to use somewhere in the editor and change it on the fly (with a warning for baking bootstraps that all subscenes will need to be rebaked)?
2) There doesn’t seem to be an efficient way to build Blob Assets during baking
I had a conversation with @bogdancoder and @Aede-unity in a now locked thread about this issue. They suggested that I do not build blob assets in baking systems but rather build them inside of bakers directly due to data tracking concerns. Well, the only example we have today of generating blob assets via the baking workflow is Unity Physics. And guess what they do? Literally the exact opposite of what I was told to do. They bake their blob assets in Baking Systems using BlobAssetComputationContext and borrow the BlobAssetStore from the BakingSystem.
So I am really confused as to how to proceed. Here are some use cases I am trying to design for:
A) Someone paints 1000 instances of a prefab in a subscene, and it all gets baked. The same asset and inputs go into baking for all 1000 instances. While I don’t know if those assets and inputs are different from a previous bake, I do know that all 1000 instances will lead to the same blob asset. So I would like to only generate the blob asset once.
I think this can be solved with a little hackery where a Baker can see special baking systems that keep a cache of input-blob pairs and call methods on those systems to generate or retrieve existing blob assets. The baking systems would then clear the cache in their own OnUpdate().
B) Let’s say that someone decides to rerun full baking a subscene that needs 1000 different blob assets. This takes time, because Bakers run single-threaded. The blob generation algorithms don’t parallelize well for a single blob (can you even split a BlobBuilder to multiple threads?) so it is just one thread grinding through while the editor is locked up.
This seems like the problem the physics team ran into which is why they did what they did.
C) Now let’s suppose that I am an asset store developer, and I want to make an asset that can do cool things with a particular type of blob asset. But I don’t want to impose unnecessary limitations on where and how a user stores such an blob. They may want just a single blob in an ICD, or they may want multiple in a dynamic buffer, or they might want exactly three sitting side-by-side in an ICD struct along with some other metadata. How do I make an easy-to-use API to service this use case?
The simplest solution is to just provide a single static method that takes in inputs and spits back a blob asset. However, this runs into the issues that (A) and (B) have.
My old conversion-based solution solved (A), (B), and (C) all at once. But I need a new solution for baking.
3) There’s a dragon with strongly typed authoring references
Here’s the deal, let’s say I have AuthoringA which has a public reference member of type AuthoringB exposed in the inspector. It is super easy in a Baker to read data from AuthoringB without declaring a dependency. So then, how do you declare a dependency on a reference you already have? Well, with the Baker API right now, you re-fetch the reference using GetComponent. That’s a waste of performance, and unintuitive. And in extreme cases, GetComponent could even return the wrong reference if there is more than once instance of the ComponentB on whatever GameObject has the referred-to instance.
The answer for this one is simple. You just need to either add API or account for it in DependsOn (and make it obvious in the docs because reading the code it looked like this was overlooked).
Anyways, I’m really hoping for some quick feedback, thoughts, opinions, and insights as I am very quickly running up to a wall trying to update my projects. It would have been really nice if Entities Graphics still provided conversion so that I would have a checkpoint and could try out the new runtime features. But it is what it is.