I want to pass arbitrary floating-point data from Animation Nodes into a shader.

I have found the Set Vertex Color node, but I have two problems with this method. The first is that the values are limited to the range [0.0, 1.0], and the second I think is due to color space transformations.

For example, the Red channel output is in the range 0.3 to 0.5:


But if I log the values in the shader using a (very slow) custom OSL script, I find that the incoming R values are different:


How can I send an unbounded floating point value to the shader without any value transformation side-effects?

Animation Nodes: Animation Nodes

Shader: Shader

shader shaderDebug(color input=0,output color debug=0)
  debug = input + 0.00001; // script is not a no-op; dont optimize away
  printf("debug: %f, %f, %f\n" , input[0], input[1], input[2] );

1 Answer 1


You can transfer any kind of data (float, integer, negative, greater than 1, etc.) from Animation Nodes to Shader (Material) with the help of UV Map Data Output node or Set Vertex Colors node but for this, you need Animation Nodes + Extra Nodes.

Method-1: First, we have to find the total number of vertices for individual polygons using the Mesh Object Input node and Separate Polygons node. Then, Create Float List (the list you want to pass to the shader), and now we have to make its length equal to the total number of vertices of polygons which we can achieve with Fill List node (length = total number of vertices of polygons). Now, connect this final list to the UV Map Data Output node (Note: Create Float List's length <= Total number of vertices), enter image description here

We have stored the data in UV coordinates which we can access in the material (I have added the color ramp node to show the difference between the values of the passed list), enter image description here

Blend File:

Method-2: This is also doable with Set Vertex Colors node in Blender2.81x but node-tree is more complex and slower. Here is the example, in which first I have mapped the Float List to 0-1 range then passes it as vertex colors. enter image description here

Then, in the material, I have re-mapped them to back their original values with the Map Range node, enter image description here

Blend File:

  • $\begingroup$ Method 1 requires using a fork which I view as a disadvantage, but I do think that UV data can go outside the [0, 1] range and would not be subject to color space transformation, so it should probably work. Method 2 doesn't require a fork but I think it still has range and color space problems. How does sending one float value as R, G, and B, and then in the shader reading the vertex Attribute's Fac affect the value? $\endgroup$ Nov 4, 2019 at 23:55
  • 1
    $\begingroup$ In method-2, first I have mapped the Float List to 0-1 range then transfer to the shader as vertex colors. Then, use the Map Range node to re-map them to their original values. Btw, what do you mean by fork? $\endgroup$
    – 3DSinghVFX
    Nov 5, 2019 at 6:21
  • $\begingroup$ Ah, I see -- I overlooked the Map Range node in Method 2, but I think this method still has problems with color space transformation. As for Method 1, what I meant by "fork" is "a fork of the Animation Nodes project" -- now I'm dependent on an additional developer and additional releases. However, I installed Animation Nodes + Extra Nodes and verified that Method 1 works and so far I don't think that it can be done with vanilla Animation Nodes. Thanks for your work there. Have you written any doc about the extra nodes? If so, where can I find it? $\endgroup$ Nov 5, 2019 at 10:12
  • 1
    $\begingroup$ The link from where you have downloaded the AnimationNodes + Extra Nodes is the daily build means you always get updated build. I have not written any Doc but I have been making many tutorials on YouTube channel 3D Singh VFX: youtube.com/3DSinghVFX $\endgroup$
    – 3DSinghVFX
    Nov 5, 2019 at 15:38

You must log in to answer this question.

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