# Is there a way of keyframing RGB curves?

In the node editor the RGB Curves node only lets me keyframe the factor. The control points have boxes for x and y coordinates, but it doesn't allow me to keyframe these boxes. Is there a way around this?

All of the node data is available through python so a workaround could be to use a python script to adjust the curve at the right time.

To view the curve data you can use a script like -

import bpy

theCurveNode = bpy.data.materials['Material'].node_tree.nodes['RGB Curves']

print("R Curve points are:")
for point in theCurveNode.mapping.curves[0].points:
print(point.location)

print("G Curve points are:")
for point in theCurveNode.mapping.curves[1].points:
print(point.location)

print("B Curve points are:")
for point in theCurveNode.mapping.curves[2].points:
print(point.location)

print("C Curve points are:")
for point in theCurveNode.mapping.curves[3].points:
print(point.location)


So curves[] will always be 0-3 for RGBC and each curve can have any number of points. It would be tedious but you could use the script to generate a list of values that you then use as data for the script that imitates keyframes. Possibly calculating them or interpolating smoothly between frames.

theCurveNode.mapping.curves[1].points[2].location.x = myCurvePointLocX(1,2)
theCurveNode.mapping.curves[1].points[2].location.y = myCurvePointLocY(1,2)
theCurveNode.mapping.update()


Be sure to run mapping.update() after altering any curve points.

You could then setup a script that appends a function for bpy.app.handlers.frame_change_pre that alters the curves based on frame_current.

I can't say this is a recommended method but in theory it could work.

It's apparently not possible; as a workaround, you could use a different node that you can keyframe, or use two or more rgb curve nodes and animate a mix node between them:

add two or more rgb curve nodes using the same input and configure them as you like(for example each node reprents a key frame - start rgb values,intermediate rgb values, and end rgb values; mix their outputs in proper order using color mix nodes, and then animate the mix nodes factor. hope that's clear, sorry for the colossal delay, I've been signed in on a different account :)

• Could you explain how to do this? – cybrbeast May 6 '14 at 6:05

Good idea to use a RGB mix node as a workaround to keyframing RGB curve values. I wanted to make a sky get darker by keyframing the RGB curves, but ended up duplicating the sky (one light, one dark), and then transitioned from light to dark by keyframing the mix node. Worked great.