I’m adding a shader graph system to my renderer. I would like parameters on shading nodes to either have a constant value, or a connection to another node to evaluate to get the value. For instance:
rtDeclareVariable(float3, color_value, , );
rtDeclareVariable(rtCallableProgramId<float3()>, eval_color, , );
rtDeclareVariable(bool, color_is_bound, , );
RT_CALLABLE_PROGRAM float3 shader_node() {
float3 result = color_value;
if (color_is_bound) result = eval_color();
return result;
}
Is there a way of checking if the program is bound without having a manually set flag in there as well? Another alternative would be to bind a different program instead that just supplies the constant value, but this seems like it might be less efficient (or is it)?
What’s the recommended way of doing this?