Incorrect OSL type handling
Posted: Tue Jul 02, 2024 7:45 pm
As you can see from the attachment, in which I defined a vector, and the UI panel is vector, however the input pin is float.
Community Forums for OTOY Customers
https://render.otoy.com/forum/
Hi LewisO, as far as I know this is how it works in standalone - standalone also creates one pin which you can plug in a float input node which has XYZ.LewisO wrote:As you can see from the attachment, in which I defined a vector, and the UI panel is vector, however the input pin is float.
Code: Select all
shader Example
(
float R = 0.0,
float G = 0.0,
float B = 0.0,
output color result = color(0.0, 0.0, 0.0)
)
{
vector color_vector = vector(R, G, B);
result = color(color_vector);
}
Code: Select all
shader FloatsToColor
(
float R = 0 [[string label = "Red value", string help = "Value stored in the red channel of the output color."]],
float G = 0 [[string label = "Green value", string help = "Value stored in the green channel of the output color."]],
float B = 0 [[string label = "Blue value", string help = "Value stored in the blue channel of the output color."]],
output color out = 0)
{
out = color(R, G, B);
}
I noticed that and imh it's fundamentally wrongly designed since day 1 in standalone, or there should at least be some fix in the plugin ports (Houdini in this case). There are two "float" for pins, one is a single float input, and the 3 floats (theoretically a vector, or color without alpha, and they should be mutually compatible nonetheless, but unfortunately not the case in Octane) which is also named "float". How can a user know what the pin really expects? and there are no existing nodes to convert color back to vector/independent 3 elements, some essential nodes are missing afaikricky_otoy wrote:Hi LewisO, as far as I know this is how it works in standalone - standalone also creates one pin which you can plug in a float input node which has XYZ.LewisO wrote:As you can see from the attachment, in which I defined a vector, and the UI panel is vector, however the input pin is float.
If you want separate control pins I would suggest splitting into 3 float controls and combine as a vector afterwards.
Example:
orCode: Select all
shader Example ( float R = 0.0, float G = 0.0, float B = 0.0, output color result = color(0.0, 0.0, 0.0) ) { vector color_vector = vector(R, G, B); result = color(color_vector); }
But obviously adapt to what you need.Code: Select all
shader FloatsToColor ( float R = 0 [[string label = "Red value", string help = "Value stored in the red channel of the output color."]], float G = 0 [[string label = "Green value", string help = "Value stored in the green channel of the output color."]], float B = 0 [[string label = "Blue value", string help = "Value stored in the blue channel of the output color."]], output color out = 0) { out = color(R, G, B); }