What does the UV Bake Type do?
The UV bake type is used to bake the UV coordinates of your geometry. As stated by the documentation, the red channel represents the U value and the green represents the V value, the blue channel will be a constant 1.
This bake type would allow you to bake the UV pass in the View Layer passes (this link is for the 2.7 doc but passes work the same in 2.8 and I couldn't find the corresponding doc for 2.8+).
With the defauld cube, if you go to Properties>View Layer>Passes>Data and check UV (you have to be in Cycles, of course, otherwise you wouldn't see those), and render the scene, you will have an UV pass :
It's like you render the object but each point of its surface is colored according to where that point is mapped on the UV coordinates. The picture below illustrates what I mean by that :
If the square in the middle is the UV grid, then your faces will be colored depending on where their UV islands are on this UV grid and those colors are the ones who would get baked on the image if you chose UV as bake type.
How to have a decent UV Bake Type result?
Now, why do you always get a black image when you try to bake with UV bake type?
The reason is quite simple, Blender bakes whatever you have in your shaders (unless, of course, if you are baking from Selected to Active
).
If you bake the normals for example, Blender will search for whatever you plugged on the normal inputs of the shaders and if nothing is found, you will have a "blank" image, or if you try to bake the diffuse but all you have in your nodes is an emission shader, you will have a "blank" image.
Long story short, you need to somewhat have the UV map "present" in your node tree and having its output contribute to the Material Output (sorry for the bad explanation, I don't know any other way to say this).
You can try with the default cube and its default material. Click on the principled BSDF node and press CTRLT and replace the Texture Coordinate node with a UVMap node (SHIFTA>Input>UVMap) and select the UV Map you want to bake :
You can leave the image texture with no image on it, it doesn't matter since all we need is the UVMap node connected to the material output. You can even plug it directly to the output like so :
The bake result will be the same (as long as there is a link from the UVMap node to the Material output, if you disconnect them, you'll have a black image).
Now you can bake (make sure to have the correct image texture node as active for the bake target to avoid Circular Reference) and you will have your UV baked :
This is how UV bake type works. May be there is a simpler way to make it work but this is how I could make it work.
What's the deal with Color Attributes?
And for your question about the Color Attributes, this represents the bake target.
When baking Blender allows you to select a bake target. You have two options : Images Textures
and Color Attributes
. Those two options are available for all bake type as far as I know (not only UV bake type).
Baking to an Image texture will store the bake result to an image while the Color Attributes option will store the bake result on the object itself as a Color Attribute (as a Vertex Color or Face Corner color), you will need to have an active Color Attribute before doing this :
There is no Color Attribute by default, you can add one with the + button on the right. You can use a Color attribute in the shader node editor with a Color Attribute node :
There is on important thing to note : just as the quality of the bake results depends on the image resolution if you bake to an image, the quality of your bake also depends on the resolution of your mesh if you bake to a color attribute. The Color Attribute is an attribute relative to each vertex (or each face corner if you chose the face corner type) so the more vertices you have, the more detailed your bake is going to be.
Now, if you want to bake to a color attribute, you can select it as a bake target in the bake section and click Bake. If you have multiple Color Attributes Blender will bake on the one that is active i.e. the one highlighted in the Color Attributes section of the Object Data properties :
When the bake is finished, you can use the color attribute as you please :
There are still a lot of things that need to be said about Bake Types and Bake Targets but this answer is already very long, anyway I hope I helped you in some way.
And no, Baking is not the worst part of Blender. It is actually one of the coolest things about it when you understand it properly ;).