ImageEngine/gaffer — pull request #411 by johnhaddon (2013-07-10 12:30:36+00:00)
Title: RenderManShader spline parameter support

This pull request implements support for colour spline parameters in RenderManShaders. A sample shader might look like this :

```
surface splineParameter(

color colorSplineValues[] = {};
float colorSplinePositions[] = {};

)
{

float tt = spline( "solve-catrom", t, colorSplinePositions);
Ci = spline( "catrom", tt, colorSplineValues );
Oi = 1;

}
```

The array parameters are matched based on name and mapped to a single Gaffer SplinefColor3fPlug. This is displayed in the node editor, and an editor is launched by clicking on it. It should be fairly self-explanatory how to use it, but there's a tooltip with some help if not.

There are a couple of open questions :

#### Interpolation type.

I've hardcoded catmull-rom interpolation for now, but others are possible. The good thing about catmull-rom is that it guarantees to visit every colour in the ramp exactly, and interpolates nice and smoothly as long as the handles aren't too close. The bad thing is that if the handles get a little close, the transitions get very abrupt. Some alternatives would be b-spline or linear. B-splines are lovely and smooth no matter the distance between handles, but don't actually visit the colours you specify exactly. Linear visits exactly but they look kindof linear. If anyone wants to experiment with interpolation, they can do so with a tiny bit of scripting in the script editor :

```python
plug = the spline plug i just dragged to the script editor
spline = plug.getValue()
spline.basis = IECore.CubicBasisf.bSpline() # or linear()
plug.setValue( spline )
```

#### Default values

As far as I can tell you can't give a variable length array parameter a default value in RSL - it's the zero-lengthness of the default that marks it as variable length. I discovered/remembered this late in the development so haven't really addressed it satisfactorily. Currently you can define the parameters with a zero length default, and they'll get a default black-to-white ramp when converted to Gaffer. Or you can define them with values, and they'll be converted to Gaffer properly, but if you add/remove points in Gaffer then 3delight will complain at render time. Do you know any more about this Daniel? Can a variable length array have a non-zero length default somehow? If not how would you like to address it? I could parse a default value out of a shader annotation, but other than that I don't have any bright ideas...