In an older Question I found an answer, what is possible to bake with AN. One in the list was: Cycles Matrial Output (2 Years ago)

Link: Animation nodes bake to keyframes not working with polygon decomposed offsets

I’ve a Plane with Emission-Node as Material, which changes Color and Strength randomly over time.

enter image description here

When I try to Set Keyframes, there is a problem (I believe):

In Set Keyframes-Node you need an object for reference to the data-path (custom-channel), but the material-datapath is not linked to a specific object (bpy.data.materials["feuerlicht"].node_tree.nodes["Emission"].inputs[1].default_value).

Set Keyframes node tells me

Could not set keyframe

And when I look to python code, it seems, that I need an object for keyframe-setting:

obj.keyframe_insert('location', frame=1)

Or, as I found:

material.node_tree.keyframe_insert(datapath, frame=1)

But the material is not a separate object I can choose in then set keyframe-node, or?

I changed from Area-light to this plane-emission-thing to get it baked, I thought.

Is it possible to get Cycles-Material-changes baked to keyframes in AN?

  • $\begingroup$ Hi and welcome! Please add the link to the post you've found to your question. Also I recommend take the tour to learn about how this site works: blender.stackexchange.com/tour $\endgroup$ – brockmann Dec 10 '20 at 18:38
  • $\begingroup$ Hi, thank you. I've edited the post with the link. $\endgroup$ – Grisalho S.K. Dec 11 '20 at 12:15
  • $\begingroup$ so, I think there does not exist a node for this. I made a quick and dirty script for this: $\endgroup$ – Grisalho S.K. Dec 13 '20 at 9:29

After further search I think there is no node for this. Now I did it with a quick an dirty script-node:

    # inputs:
# Enable = boolean
# SetKeyframes = boolean
# RemoveUnwanted = boolean
# MaterialName = text
# pframe = integer

import bpy

mat = None

if Enable:
    for tmat in bpy.data.materials:
        if tmat.name == MaterialName:
            mat = tmat
    if mat != None:
        print ('material found')
        emitStr = mat.node_tree.nodes['Emission'].inputs[1]
        if RemoveUnwanted:
                emitStr.keyframe_delete( 'default_value', frame=pframe)
        if SetKeyframes:
            emitStr.keyframe_insert( 'default_value', frame=pframe)
        print ('material '+MaterialName+' not found')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.