3
$\begingroup$

I have this system of pipes I would like to fade into the scene, but since every pipe has its own material I would need to create keyframes for every single material in there, and there's around 50 of them so it take a considerable amount of time to animate each one separately.

Is there a way to animate them (fade in with alpha going from 0 > 100) all together? Or at least copy and paste the keyframes from one material to the other?

The pipe system These pipes should fade in

Frame One of the animated material, can I do this to multiple materials at once or copy these keyframes?

Last frame of the same material

enter image description here

enter image description here

enter image description here

enter image description here

$\endgroup$
6
  • $\begingroup$ I don't know if there is way but you could try to give all pipes same material, animate that one material and then duplicate material for each pipe(duplicate will keep keyframes and you can just tweak each material one by one) $\endgroup$
    – MikoCG
    Commented Aug 18, 2021 at 7:07
  • $\begingroup$ @MikoCG That's one way to do it but I feel like it would be even more work than animating them one by one. $\endgroup$
    – Luka
    Commented Aug 18, 2021 at 7:22
  • $\begingroup$ I don't think because you won't have to set all keyframes again only to change their positions $\endgroup$
    – MikoCG
    Commented Aug 18, 2021 at 7:23
  • $\begingroup$ Yeah but I will have to apply each material to each pipe, which was a nightmare to do in the first place. I wish blender had an option to join or connect multiple materials into one material or at least a collection of some sorts, so you can apply changes to all at once. $\endgroup$
    – Luka
    Commented Aug 18, 2021 at 7:30
  • $\begingroup$ are the materials all equal? can you show us your materials please? if the materials are "plain" or just simple node setup, this should be an easy task for a small python script. $\endgroup$
    – Chris
    Commented Aug 18, 2021 at 8:05

2 Answers 2

1
$\begingroup$

ok, here is a basic python script, which does what you want.

PREQUISITE:

  1. You have a collection named "Automatic" where all objects are in for which you want that behaviour.

  2. Each of your materials have a Principled BSDF and it is named that way (not renamed)

works for Cycles and Eevee.

    import bpy

    index = bpy.data.collections.find('Automatic')
    coll = bpy.data.collections[index]
    scene = bpy.context.scene

    for eachObject in coll.objects:
    
        for eachMat in eachObject.data.materials:
        
            nodes = eachMat.node_tree.nodes
        
            pb = nodes.get('Principled BSDF')
            eachMat.blend_method = 'HASHED'

            if pb:            
                pb.inputs[19].default_value = 0
            
         pb.inputs[19].keyframe_insert(data_path="default_value", frame=0) # do inset this to the line above
                pb.inputs[19].default_value = 1
            
          
         pb.inputs[19].keyframe_insert(data_path="default_value", frame=100) # do inset this to the line above
            
                print ("set for ", eachMat)
        
  
$\endgroup$
3
  • 1
    $\begingroup$ First off, I am really thankful you're taking time out of your day to help me. Would this work with Cycles also? If not, it is of not much use to me becouse the animation must be rendered in Cycles. Again, I hope I am not wasting your time, I just do not have much experience with these things. $\endgroup$
    – Luka
    Commented Aug 18, 2021 at 9:59
  • $\begingroup$ i just tried it out, it works for Cycles too. I just wasn't sure because of this statement: eachMat.blend_method = 'HASHED' ...because there is no blend_method in cycles, but it worked. Please be aware that you have to indent the two lines i marked in the code yourself, else it won't work $\endgroup$
    – Chris
    Commented Aug 18, 2021 at 10:54
  • $\begingroup$ Thank you for all the help again, I will give it a try. $\endgroup$
    – Luka
    Commented Aug 18, 2021 at 11:35
0
$\begingroup$

There are several ways to do this. One technique that is often overlooked is to use a Value node contained in a node group. This works because if you change a value inside a node group, it changes in every material that uses that node group. It's a bit of work in your case, because you have to add the node group to every material, but here's an example.

  1. Initial setup

    • Add a Value node to any one of your materials.
    • Deselect all of the other nodes in that material and select the value node.
    • Type CtrlG to create a node group.

At this point, your node editor will look something like this:

Node group created

* Enter <kbd>Tab</kbd> to close the node group:

Newly created closed node group

Now when you have the group selected, typing Tab will toggle whether it is open or closed.

  • Open the sidebar in the node editor and open the Properties panel. In it, you'll see an entry for the Node group's name. Change it to something meaningful. I picked "Animation" for the example.

  • Connect the Value output of the NodeGroup to the Alpha input of your BSDF node.

  • Now you can add the Nodegroup to every material that you want animated by typing A and selecting your name from the Group submenu:

Add menu showing 'animation' selected from Group submenu

  1. Animation
  • Pick any material, select the node group and open it.
  • Move to frame 1 on the time line, set the value to 0, and keyframe it. (You can keyframe the value of an input just like any other field. Set it to 0, hover over it, right click and pick Insert Keyframe.
  • Move to the frame where you want the fade to start and keyframe the value
  • Move to the frame where you want full visibility. Set the value to 1. Keyframe it.
$\endgroup$

You must log in to answer this question.

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