Firstly, I am delighted to see material baking in the engine finally. I hadn’t heard a peep about it until it showed up in the 4.19 preview. Being that it’s an unannounced feature that’s still in development I figure Epic has plans for it, but I have some early feedback that may or may not overlap with what you already plan to do.
I figure that the use case of material baking so far is to convert complicated, slow material shaders into quick texture-based lookup materials. This will lighten the overhead of, say, using Substances everywhere. I also found I could bake materials per-world-object which is excellent. This is going to be amazing on mobile.
That brings us to the feedback:
- The immediate, obvious use case here is baking normals from the base LOD to a lower LOD’s material.
Currently this won’t work because you transform the face into tangent space and render the normals that way rather than capturing face normal detail in world space.
You need to add an additional normal pass that bakes the world normals to a texture that is then used by your template material. If your UV generation for lower LODs is good this will complete the missing piece of the new LOD tools in UE and bake vertex normals from higher detail surfaces to lower detail surfaces.
- Pretty much everything is unwrapped to sit flat on the z axis at 0,0,0 before being baked.
This is no good either. People using world-position based noise or other effects will find their noise textures coming out all black or all white.
The face has to be baked in position, at least using its local offset inside the mesh. When the user has clicked on an in-world object to bake it, the face’s position in world space should be used.
- There’s no way to indicate inside a material that only a part of it should be baked.
To me this is the most important thing missing. Being able to include a material function and mark it for baking would be fantastic.
A good use case would be a noise function used in parallax offset to simulate metal being eaten away. The noise aspect of this material should definitely be baked, but the parallax doesn’t suit baking at all. Adding a flag to a material to mark it as “not bakeable” and then having “bakeable” areas inside it would be excellent. This feature should also be able to be set so that materials are generated per-object-instance or in single material instance mode.
I stumbled across all this while looking into material layers. Without making the whole workflow too complicated I could suggest using layers as a way of marking bakeable sections of a material, whereby a whole section of shader language can be replaced by an inline texture sampler as needed.
Keep up the good work!