OSL implementation of RGB ramp node.
The sampled color ramp data is passed to OSL as a color array. This has to be done as actual float[3] array though, since the Cycles float3 type actually contains 4 floats, leading to shifting color components in the array. Additional parameter set functions for arrays have been added to the Cycles OSL interface for this purpose.
This commit is contained in:
@@ -2768,6 +2768,19 @@ void RGBRampNode::compile(SVMCompiler& compiler)
|
||||
|
||||
void RGBRampNode::compile(OSLCompiler& compiler)
|
||||
{
|
||||
/* OSL shader only takes separate RGB and A array, split the RGBA base array */
|
||||
/* NB: cycles float3 type is actually 4 floats! need to use an explicit array */
|
||||
float ramp_color[RAMP_TABLE_SIZE][3];
|
||||
float ramp_alpha[RAMP_TABLE_SIZE];
|
||||
for (int i = 0; i < RAMP_TABLE_SIZE; ++i) {
|
||||
ramp_color[i][0] = ramp[i].x;
|
||||
ramp_color[i][1] = ramp[i].y;
|
||||
ramp_color[i][2] = ramp[i].z;
|
||||
ramp_alpha[i] = ramp[i].w;
|
||||
}
|
||||
compiler.parameter_color_array("ramp_color", ramp_color, RAMP_TABLE_SIZE);
|
||||
compiler.parameter_array("ramp_alpha", ramp_alpha, RAMP_TABLE_SIZE);
|
||||
|
||||
compiler.add(this, "node_rgb_ramp");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user