0
$\begingroup$

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?

$\endgroup$
3
  • $\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
    Commented Dec 10, 2020 at 18:38
  • $\begingroup$ Hi, thank you. I've edited the post with the link. $\endgroup$ Commented Dec 11, 2020 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$ Commented Dec 13, 2020 at 9:29

1 Answer 1

0
$\begingroup$

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:
            try:
                emitStr.keyframe_delete( 'default_value', frame=pframe)
            except:
                None
        if SetKeyframes:
            emitStr.keyframe_insert( 'default_value', frame=pframe)
            
    else:
        print ('material '+MaterialName+' not found')
        return
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .