6
$\begingroup$

I want to do an animation of a Blender object that changes color over time using a script. I already found out how to change the colors and set the keyframes from a script, but what I would need in addition is a possibility to "translate" the values of the external data (which are temperature values) to corresponding colors with a colormap (like e. g. the Jet colormap in Matlab).

I suppose that there is a simpler solutions than calculating these values "by hand", since I already saw how this can be applied for smoke, but the solution there seems not to be applicable for objects different from smoke.

Thank you again really much for your answers, you are a great help for me!

Edit: the question on the complete task I want to achieve (which has as suggested been split up into several smaller questions) can be found here, where also the application is shown.

$\endgroup$
0

2 Answers 2

10
$\begingroup$

In this case you have a predefined range 10 ... 90 degrees, it's simple to remap those to a 0....1.

Using a Cycles material

You could give each object a Value Node and key-frame its values within a range 0 ... 1, then convert them via a ColorRamp node to your Jet colormap (here quickly defined by hand).

enter image description here

Octave Gradients (add-on)


I wrote a little add-on that can recreate Octave/Matlab default gradients: Get it here. Installation can be done using the zip on github and Blender's Install from File feature in User Preferences. {category: 'Node', name: 'octave gradients'}

This adds a panel called Octave Gradient Demo to the Cycles node view. From here you can choose the gradient by name, it will display the colors in the same panel.

enter image description here

The set gradient button will write the gradient to a ColorRamp if it finds one in the current material, else it adds a ColorRamp and then fills it with the gradient info.

The location of the newly added ColorRamp is a contentious issue, how would I decide where to add it? for now i've set it to add the node to (0,0).

Notice i've defaulted it to Linear, but gradient might be smoother.

enter image description here

Choices:

enter image description here

Usage


  1. enable addon
  2. make sure renderer is set to cycles
  3. click an object, and create a new node based material
  4. get a view open to see the nodes for the material
  5. in the right side panel (use N to show the shelf) you'll see the Octave Gradient Demo panel.
  6. initially this will show all black ramp slots until you change the palette from the dropdown.
  7. If you haven't already added a ColorRamp node to the current Material, that's OK the set gradient button adds a ramp for you (but it might not be visible, zoom out if not)
$\endgroup$
5
  • $\begingroup$ Thank you again really much for your help, the solutions you are creating are just amazing! I will now try to get all of the things you suggested working. It might will take some time since there's also vacation time now, but I will definitely try and tell you once I succeeded! I only tell you this so you do not think I've lost interest in my project. $\endgroup$
    – mindm49907
    Commented Aug 19, 2015 at 11:13
  • $\begingroup$ Hello again! Sorry for my late reply, but I finally found the time to work on my implementation. I cloned the Gist you supported me, and ran it within Blender. But I get two errors: One in line 102 saying name 'false' is not defined which I think is simply a spelling mistake, so I changed false to False. The other error appears on line 85 and says AttributeError: 'NoneType' object has no attribute 'nodes'. I tried to look deeper into it using pdb, but could no really understand whats going on. Maybe we are using different Blender version? Mine is 2.75. Thank you again for your help! $\endgroup$
    – mindm49907
    Commented Oct 12, 2015 at 10:35
  • $\begingroup$ Wow, thank you! You're really fast! I'll try, and let you know how it went! $\endgroup$
    – mindm49907
    Commented Oct 12, 2015 at 13:10
  • $\begingroup$ please check the revised instructions. $\endgroup$
    – zeffii
    Commented Oct 12, 2015 at 13:42
  • $\begingroup$ @zeffii is it possible to use this approach to color an entire surface at once? i.e. say I have a surface and also an array of values for each node that I want to color by. I could normalize the values to be 0..1, but without downloading the addon and trying it appears as if this would work by setting one value at a time, i.e. for one node at a time. Is it possible to pass in an entire array of values instead? Similar to how you would use a seperate xyz node to extract the z values to color by? $\endgroup$
    – Derek Eden
    Commented Apr 17, 2020 at 16:41
1
$\begingroup$

In theory, you could use OpenColorIO for such a transformation. OpenColorIO can be used to transform data to meet colour critical precision, transform into greyscale, create linearized or nonlinear transforms, etc.

Without knowing much more about your context, it is difficult to provide a more robust answer.

$\endgroup$
1
  • $\begingroup$ Thank your for your reply! See this post for an impression on what I want to achieve. Could you give me another hint on how OpenColorIO could be used in this context? That would be really great! $\endgroup$
    – mindm49907
    Commented Aug 17, 2015 at 8:03

You must log in to answer this question.

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