4
$\begingroup$

everyone! I've run into an issue with controlling world shader with properties. Thus far I've been using a method where I check when I update a property and then overwrite the default value for a value node in the world node tree. This is because Attribute node with "Object" type doesn't work with world shaders. This, however, leads to several limitations. Firstly, it appears that my method has significant performance issues on larger node trees compared to how attribute node would work. This isn't the main problem and is not what I need solution for, just thought it's worth mentioning. The other big problem is handling animations, which is what I need a solution for here. The method that I'm currently using in the addon is quite hacky. I am using frame change handlers to check when frame changes and I need to update an animated property's value in the shader. This, however, comes with a few drawbacks.

  1. Animation performance is abysmally low. Since the node tree happens to be quite big, animating just a few values can sometimes drop the playback speed down to sub 10 FPS.
  2. This method is not very robust and can simply not work in some cases, namely when offloading the rendering task to a renderfarm. Since the animation requires addon to work (as otherwise there is no relation between the property values and the node tree), if the renderfarm does not have given addon present and enabled, the animated values will simply stay static on renderfarm side.

So what kind of solution I am looking for? Well, ideally I'd love to see Attribute node with "Object" type working in world shader nodes. However, since it's not a thing, I am wondering if it's somehow possible to copy all of the animation data from a property into a node's field through Python. This would mean that whenever you change a property's value or animate it, the nodes within the shader that contain the same value would get the same treatment. As such, I wouldn't need to use a frame change handler to update their value, significantly reducing performance issues and allowing the animations to work independently of the addon once they've been created.

$\endgroup$
5
  • $\begingroup$ you could write a feature request for Blender... $\endgroup$
    – Chris
    Commented Mar 14, 2022 at 9:58
  • 1
    $\begingroup$ can you pls make a small "real world" example what value should be written into what? Because it sounds like this could be solved with drivers. $\endgroup$
    – Chris
    Commented Mar 14, 2022 at 9:59
  • $\begingroup$ The real life example would be: A property input field, let's say, a float number, perhaps a distance or angle of sorts. You input value in it and press i. You change frame, input another value and press i again. Might do again. Then, perhaps, even adjust animation curves. What should happen is that exact same animation data should be copied into the node's input field. $\endgroup$ Commented Mar 14, 2022 at 10:19
  • $\begingroup$ and in which nodes input field? $\endgroup$
    – Chris
    Commented Mar 14, 2022 at 10:23
  • $\begingroup$ In this example it'd be the only present field in a "Value" node. $\endgroup$ Commented Mar 14, 2022 at 10:24

1 Answer 1

6
$\begingroup$

Hopefully i did understand you right...

create a custom property, keyframe value 1 at frame, keyframe 100 at frame 100.

enter image description here

right click while hovering over the field -> copy as new driver

insert an input field in shader edit, hover over the input -> right click -> paste as new driver

result:

enter image description here

$\endgroup$
6
  • 1
    $\begingroup$ I did not realize drivers could hold any type of animation data, I guess I am not as well versed in this part of Blender. Is there a way to achieve this entirely through Python? $\endgroup$ Commented Mar 14, 2022 at 10:45
  • 1
    $\begingroup$ everything you can do with drivers can be done with python. in fact...the scripted expression IS python ;) $\endgroup$
    – Chris
    Commented Mar 14, 2022 at 10:54
  • 1
    $\begingroup$ you are trying now to crack a nut with a sledgehammer - of course you can do this with python but it is much more easy with drivers. Maybe watch a beginner driver tutorial - they are great, fast, super useful and easy to use. $\endgroup$
    – Chris
    Commented Mar 14, 2022 at 10:56
  • $\begingroup$ No, essentially what I mean by doing it by Python - it is a part of an addon and as such needs to be automated. What I am wondering is what's the Python API for this "copy as new driver" and "paste driver" action. Doing it manually by hand would be quite tedious considering I have multiple tens of such properties. $\endgroup$ Commented Mar 14, 2022 at 11:04
  • 2
    $\begingroup$ Does this help? blender.stackexchange.com/a/39129/86891 $\endgroup$
    – Gorgious
    Commented Mar 14, 2022 at 13:19

You must log in to answer this question.

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