← All ideas
  • Published 4 Sep 2018

Create and Use Variables for Anything

Blender is value-heavy, whether it is the position of a vertex, or the number of hair fibers in a particle system. Ideally, it should be possible to use the value of anything for the value of anything else through variables. For you programmers out there, this would be 'pass by reference' (i.e, pointer).

For example, the rotation of an object could be bound to the height of another object, or the position of a vertex could be based on the color of a material, etc. While these examples can be accomplished through other means, this feature would be robust enough to handle almost any scenario.

<h1>UX</h1> <ul><li><b>Creating a variable</b> — Just like keyframing, you would hover on the value and press 'v' (for variable). A pop-up would appear for you to specify a name for the variable. A default name could be generated based on information about the source field. For example, if it was the object's z-rotation field, the default name would be <i>"[objectname]_rotation_z"</i>.</li> <li><b>Using a variable</b> — In the target numerical field, clear it, then press space to get a list of variables. Type for the variable's name, then click one or press enter to use the first match.</li> </ul>

<h1>Variable Panel</h1> There would need to be a panel to manage these variables. It would handle the usual stuff, plus a couple neat things: <ul> <li><b>Management</b> — Standard management stuff like replacing all instances of a variable with another variable, creating independent variables, renaming, deleting, forking, etc.</li><li><b>Mapping</b> — See where a variable is being used. Drag a target from one variable's list to a different variable to re-map it to the new one.</li> <li><b>Math</b> — Variables are even better if you can do math with them. You could redefine the value of the variable using typical programming math syntax, and include other variables in the math.</li> <li><b>Object Access</b> — Through dictionary and 'self' notation, you would be able to use any of an object's values in the variable definition once you establish the link. This is to avoid having to create a variable for every property you want to use that has the same source. For example, if you want to create a variable that is "x + z", you could create 1 variable with the definition "self.dimensions.x + self.dimensions.z", rather than creating 3 variables (x, z, sum).</li> <li><b>Options</b> — Specify if the value is absolute, or can be affected by other things, such as modifiers, scaling, etc. Conceptually, you are controlling if the variable is the starting, intermediate, or final value.</li> </ul>

<h1>Other Notes:</h1> <ul> <li><b>Works at the Vertex Level</b> — This use-case was the inspiration for this feature; I wanted a way to have a vertex's location always be directly between two other vertices, plus an offset. Currently, it is awkward to accomplish. I wanted this mainly for rigging purposes.</li> <li><b>makeRelative()</b> — Related to the above, this function would allow you to quickly define a property for the selection based on a value or logic. For example, you could select random vertices, then lock their relative locations to each other. This kind of functionality requires this variable infrastructure.</li> <li><b>Living Variable Names</b> — If the variable name was auto-generated, it is 'living', so if you change the object's name, the variable's name updates.</li> <li><b>Animatible</b> — Variables should be animatible. This means you can set specific definitions of the value like keyframes, then specify the interpolation method/function. Alternatively, you could just include a time-affected value in your calculation.</li> </ul>

<h1>Why</h1> <ul> <li><b>Rigging</b> — I found that certain rigging scenarios are simplified with variables (plus math). You could have a bone's location or properties depend on other things, beyond what the current bone-constraints let you accomplish.</li> <li><b>Dynamism</b> — Rigs and objects can be more dynamic when their mesh or features are controlled via variables. You could configure a part of a mesh with a single variable instead of constraints or other tricks.</li> <li><b>Mesh Control</b> — Something as simple as making sure every cross-piece in a loop stays the same length no matter what is currently hard to achieve, and similar corner-cases.</li> <li><b>Fake Physics</b> — Like the above example, you can fake certain physics effects with variables, such as locking the length of certain edges, but allowing others to deform (looks like stretching).</li> </ul>

I have not included a mock-up as the UX component is straight-forward. I encourage you to think of scenarios where defining or linking values would help you; I find myself constantly wanting it.

92.3%

Development Status: Open

Upvote 12 Downvote 1
Karric
4 Sep 2018

6 Comments

paulhart

This is needed, coming from software programming, where Variables are common. I just went in and had to adjust a whole cluster of Light Intensity. A single variable would affect a whole group of items, simple example

1
dddjef

I think this is a workflow issue. I agree creating a driver is still tedious, a copy paste approch will be better. But, the driver functionnality could be use, copy paste a RNA should just create a driver. And the math should accepted too.

1
yesno

I'd love to see something like this and it would be incredibly useful. For example let's say I have 50 objects for a game export and I need to set some modifier parameters that are the same for each of the 50 objects. Let's say that could be an object target, numerical value or checkbox. Now if I want to make a change it is super tedious to make that change for all 50 objects.

Now, if blender had global variables then I could just create an object variable and set that variable to point to an Empty.003 for example. I'd name that variable as my_target. Then everywhere I want to use that Empty.003 I can just type there "my_target" instead. If I want to change that my_target to point to another object I need to just change the variable once and not the object for every 50 objects.

Same works for numerical value. Let's say I want to use a value of 0.52 for displace modifier that is used in 50 objects. Instead I could create a variable "called my_displace_y" or just "y" if _I want to have short variable names. Then I just type y when I want to use that value. If I want to change the 0.52 to 0.337 in every 50 objects I can just change the variable value once from 0.52 to 0.337. Similarly I could create a boolean for checkboxes that would allow me to turn on or off "In front" in those 50 objects with single click.

This would speed up certain operations a lot. You could then animate those parameters. You could use them in nodes and in precise operations to save having to type same long values all the time. You could use them as multipliers so a value in a cube x scale could be 2*variable_x for example.

Then you'd have a single variables menu inside blender where you can see all variables and then click to follow where they are used. Variables could be named like normal text and highlighted in some way to distinguish them from normal text. I think underlining or italics could work.

dpdpforlife

This isn't the same as current drivers workflow and he basically states this in the Works at the Vertex Level section when he says "Currently, it is awkward to accomplish." You will also see that it is also much more powerful. Except that drivers have custom curves, which could also be rolled into the approach proposed here.

This is similar to my proposal (here) from a few months ago. I even made a quick prototype. I accomplished it by using the existing CTRL+Alt+Shift+C functionality to copy the absolute address of the element under the cursor which could then be pasted into another field. These addresses are very long, so I like the idea of using the V key to make a new variable, I may have mentioned something about it in my proposal.

Right now, yes you can do some of this that you propose with drivers, but your proposal is a much more powerful and streamlined approach.

ammusionist

@dpdpforlife: Excellent point. There is much beyond Drivers.

I wonder if the "Evevything Nodes" project might cover this. It wouldn't surprise me if you can already handle most variables in the Animation Nodes plugin!

1