Bake textures to file
The texture-baking nodes in Bifrost let you sample data from a surface in 3D and write it to 2D image files, effectively caching the results of a graph evaluation in the form of texture files. For example, you can create wet maps to track where a liquid has touched a surface. The files can be used like any other image, for example, as weights in another graph or with materials in Maya. UDIM and other texture tile formats are supported.
Make sure that the Bifrost mesh you want to sample has a valid
face_vertex_uv
property.Add a
create_texture_samples
node to the graph, and connect the mesh into itsgeometry
port.Set the desired pixel resolution and sampling density on the
create_texture_samples
node.Add a
bake_texture_samples
node, and connect thecreate_texture_samples
node'ssample_points
output into itssample_points
input.Connect the data that you want to bake into the
sampled_data
input. Use 3D data for RGB and 4D data for RGBA values. 1D data gets promoted to 3D data with constant members. You can connect any of several different data types:- A field gets sampled at the sample points' 3D positions.
- A string gets interpreted as the name of a geo property on the mesh, which is sampled at the sample points' locations.
- A Bifrost object gets interpreted as a texture and sampled at the sample points' UV positions.
- A single vector gets interpreted as a constant value for all pixels.
- An array of vectors gets resized to the correct number of pixels and used as the explicit pixel values.
If desired, you can use the auxiliary outputs (
sample_uvs
,sample_positions
, andsample_locations
) of thecreate_texture_samples
node to create your own complex data look-ups, for example, using geometry queries (see Query data on geometric objects). Thesample_is_valid
output lets you know if the location corresponding to the UV coordinates exists on the geometry, and take whatever action you prefer if it doesn't.You can also use an
accumulate_color_texture_samples
node to add or blend color values over time, as for wet maps and other effects.Connect the output of the
bake_texture_samples
node to awrite_texture
node, and set its parameters.Connect the
out_texture
output of thewrite_texture
node to theoutput
node of the graph to run it.Disconnect it if you don't want to rewrite the images every time the graph runs, or use an
if
node to control when the files are written.