[Cycles Standalone] How to bake AO/lighting?

Hello!

I’d like to use the standalone version of Cycles X for baking ambient occlusion as well as lighting (for lightmaps), but I haven’t found much information on how to do that.

I’ve set up everything for a normal scene render, which is working just fine. For baking, I also tell the bake manager which object it should use:
cclScene->bake_manager->set(cclScene,"name_of_bake_object");

That on its own just results in an image with a single color, so I’m assuming other steps are required. An earlier version of Cycles used to have a “bake” method in the bake manager, but that was removed in an update and I don’t know how you would set it up now.
I also don’t know how I would specify the lightmap UV data for the objects when I’m baking lighting.

Any advice? I just need some hints on what to look for, I haven’t found much in the source code.

Thanks.

Heya I’m trying to bake ao and lighting with cycles standalone - did you have any luck with this? I’ve been looking at this code:

And it looks like we way need to implement this function:

BlenderSession::do_write_update_render_tile(RenderTile &rtile,
                                                 bool do_update_only,
                                                 bool do_read_only,
                                                 bool highlight)

Half of the baking code is implemented in Blender, it provides image passes that specify for each pixel a triangle index and UV coordinate. The system is not really designed to be used outside of Blender, though it’s possible in principle.

Two passes are expected to be provided with the following data:

PASS_BAKE_PRIMITIVE
R: random seed integer for sampling (uint stored in float memory)
G: triangle index (uint stored in float memory)
B: barycentric u
A: barycentric v

PASS_BAKE_DIFFERENTIAL with differentials of barycentric uv
R: dudx
G: dudy
B: dvdx
A: dvdy

Thank you brecht that’s awesome. I’ll dig through the python code for the cycles integration and see if I can work out how to do this. That RGBA data is put into a float32 4 channel 2d texture for each pass yeah?