PDA

View Full Version : Slim template error


Asgar
08-08-2005, 01:02 PM
Hi!I'm new in renderman world!!!
I wrote a simple shader but i have some problem with the slim template!!

here's the code!!
Thanks for help!!!
Debug write:
ERROR: Primary Compiler:
ERROR: "MBlend_0.sl", line 93: ERROR: argument mismatch for function "mxslMBlend"
ERROR: Possible choices were:
ERROR: <unknown type> mxslMBlend(color; color; float; float; color)
ERROR: Your call was:
ERROR: float mxslMBlend(uniform float; uniform color; uniform color; uniform float; varying color)
ERROR:
ERROR: MBlend_0: ERRORS -- NOT COMPILED.
ERROR: Shader not compiled





slim 1 extensions Asgarmx {
extensions Asgar mxsl {
template color MBlend {
description "Combines or blend two color functions."
parameter float Mode {
label "Mode"
subtype selector
range {
"Sum" 0
"Subtract" 1
"Multiply" 2
"Union" 3
"Difference" 4
"Blend" 5
}
default 5
}
parameter color color_A {
detail varying
default {0 1 0}
}
parameter color color_B {
detail varying
default {1 0 1}
}
parameter float Blender {
default .5
value 1.00
range {0 1}
provider constant
subtype slider
detail varying {}
}
parameter color result {
access output
display hidden
}



RSLFunction {
void mxslMBlend(
color color_A;
color color_B;
float Blender;
float Mode;
output color result;
)
{

/* Sum */
if (Mode == 0)
result = color_A + color_B;

/* Subtract */
else if (Mode == 1)
result = color_A - color_B;

/* Multiply */
else if (Mode == 2)
result = color_A * color_B;

/* Union */
else if (Mode == 3)
result = color_A + color_B - color_A * color_B;

/* Difference */
else if (Mode == 4)
result = color_A - color_A * color_B;

/* Blend */
else if (Mode == 5)
result = mix(color_A,color_B,Blender);
}
}
}
}
}

playmesumch00ns
08-09-2005, 09:09 AM
It tells you exactly what you've done wrong in the error message.

The key is these lines:

ERROR: "MBlend_0.sl", line 93: ERROR: argument mismatch for function "mxslMBlend"
ERROR: Possible choices were:
ERROR: <unknown type> mxslMBlend(color; color; float; float; color)
ERROR: Your call was:
ERROR: float mxslMBlend(uniform float; uniform color; uniform color; uniform float; varying color)

When you write a slim template using RSLFunction you have to define a function inside the RSLFunction block, then define a matching parameter interface in the slim code above it. If you look at the parameters you've declared, you've got

color,color,float,float,output color

whereas in your function declaration below you've got

float,color,color,float,output color

The order of the parameters in the slim part must match the order of the parameters in the RSL part. Simply put your "Mode" parameter first in the function delcaration and it should work.

For this reason I much prefer using the DynamicFunction-style slim templates. Slim handles building the function declaration for you, so you can change the parameters as much as you like, and you also get access to more functionality.

CGTalk Moderation
08-09-2005, 09:09 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.