I have used Object Info,random output and colorRamp to randomly asign colours to a few hundred different object instances (for example roof tiles, wooden elements, rocks and grass), which works great for renderings. I want to upload my model to sketchfab which doesn't support this type of material. My solution right now is to make the object instances unique and select all the objects with the same colour and apply a simple material with the same colour, but this is tedious work. Is it possible to "bake" or apply the random colours to the objects? Some objects have multiple materials applied this way. Thanks for any help!
1 Answer
Assuming you have made UVs for all your objects and they all fit in the UV space at the same time:
Add a new texture node, plugged to nothing. Click the New button to create a new texture, name it like color.png
and set a nice resolution.
If your objects use multiple materials, make sure to copy paste this node everywhere.
While this texture node is selected, go to the properties editor, rendering tab, make sure the render engine is set to Cycles.
In the Baking panel, set Bake type to Diffuse, check only Color in the Influense subpanel. Pay attention the margin setting in the Output subpannel, this determines how many pixels are calculated out of each UV island to prevent bleeding, too much of it will make the baking bleed onto other islands. This depends on the texture resolution and how you did your UVs so there is no perfect answer, you have to test. I like to start from 8px and see how it goes from there.
Then you can bake, and you will obtain a texture that you can use anywhere. Don't forget to save it by pressing ⎇ AltS from the Image Editor. Or menu Image → Save As....
-
$\begingroup$ Thank you for not only a great solution but also excellent instructions with a useful screenshot and coresponding steps marked. The only thing is it's baking every object one at a time, so I have to uncheck clear image in the settings, otherwise the previous bake gets overwritten. I will play with the settings some more, maybe I'll find a solution to that. In any case, a great answer. $\endgroup$ Commented Nov 30, 2021 at 23:16
-
1$\begingroup$ That's why you should have all the objects' UVs withing the same space (see my baked image, you can see each cube is a different patch). So that you have all the objects baked in one go. That's the coolest part of it. $\endgroup$– Lauloque ♦Commented Nov 30, 2021 at 23:51