Autobake Image Textures (Shader)
Make it possible to set up an autobaking material/shader. To accomplish this, add baking configuration to texture nodes, i.e. bake type, clear image, margin, influence options. Once a bake type apart from the default of none is selected, add the suitable inputs to the texture node, generally colour and alpha, to allow the user direct control of the texture data. For normal textures, for example, this input should be the same normal that should be feed to the normal input of the Principled BSDF node.
As for handling shading, in preview mode, treat the texture node as a simple transform/pass through node. For normal baking, map the normal to a suitable tangent space colour as per the bake options based on the assumption it's going to be feed into a normal map node. For other bake types, possibly clip the colour and alpha to the range and resolution of the colour space and image's bit depth. These as simple transformations, so should have an insignificance cost to the shader. As for render mode, this would trigger a hashed bake of the textures, i.e. generate a hash based on all variables inputting into the texture and the image settings. If this hash matches the current texture hash stored alongside the image in the blend file, then just use the stored image under the assumption it is correctly baked. Otherwise, rebake the texture based on the bake setting in the texture node prior to rendering.
Further considerations, add a bake button to the individual texture nodes and the material for manual forced baking, also add a no bake render option, that would cause the normal render to behave like the preview render.
0 Comments