Solved Baking textures for PBR object

Is it possible to bake the values of the reflection channel into textures using "Bake object"?

Hi krftt thanks for reaching out us.

With regard to your question, if the intent is to bake the final appearance of a PBR material on a texture, I confirm that there are no means to achieve this considering that the baked data will also be camera-dependent.

If, on the contrary, your goal is to sample the shader used in any of the reflection layers used in a PBR material you can consider BaseShader::Sample() and, given a ChannelData, retrieve the color at a specific point - see this thread.

To browse through the different channel you can use something like:

    # check for an active material
    mat = doc.GetActiveMaterial()
    if mat is None:
    # retrieve the reflection layers count
    layersCount = mat.GetReflectionLayerCount()
    # loop through the layers
    for i in xrange(layersCount):
        # get the ReflectionLayer instance and the related data ID
        reflLayer = mat.GetReflectionLayerIndex(i)
        reflLayerData = reflLayer.GetDataID()
        # check for the instance to be the one currently active in the Attribute Manager
        if reflLayer.GetFlags() & (c4d.REFLECTION_FLAG_TAB):
            # retrieve the color
            color = mat[reflLayerData + c4d.REFLECTION_LAYER_COLOR_COLOR]   
            # try to retrieve the shader
            colorShader = mat[reflLayerData + c4d.REFLECTION_LAYER_COLOR_TEXTURE]

            # do something with the data retrieved
            if colorShader is None:
                print "Selected layer is ", reflLayer.GetName(), "and uses color: ", color
                print "Selected layer is ", reflLayer.GetName(), "and uses shader: ", colorShader.GetName()

Best, Riccardo