cancel
Showing results for 
Search instead for 
Did you mean: 

SDK Discussions

shauser67
Journeyman III

Operation RPR_MATERIAL_NODE_OP_COMBINE of shader RPR_MATERIAL_NODE_ARITHMETIC

Hello,

I am trying to use RPR_MATERIAL_NODE_ARITHMETIC for some advanced mathematical operations inside a node graph. My understanding after reading the documentation is that I can split a color in its components with RPR_MATERIAL_NODE_OP_SELECT_X (_Y, _Z) and combine these components back to a color with RPR_MATERIAL_NODE_OP_COMBINE. However, the latter operation doesn't work as expected:

rpr_material_node material_node = nullptr;

rprMaterialSystemCreateNode (material_system,
                                 RPR_MATERIAL_NODE_ARITHMETIC,
                                 &material_node));


rprMaterialNodeSetInputUByKey (material_node,
                                   RPR_MATERIAL_INPUT_OP,
                                   RPR_MATERIAL_NODE_OP_COMBINE));


rprMaterialNodeSetInputFByKey (material_node, RPR_MATERIAL_INPUT_COLOR0, 1.0f, 1.0f, 1.0f, 1.0f));
rprMaterialNodeSetInputFByKey (material_node, RPR_MATERIAL_INPUT_COLOR1,  0.8f, 0.8f, 0.8f, 1.0f));
rprMaterialNodeSetInputFByKey (material_node, RPR_MATERIAL_INPUT_COLOR2,  0.0f, 0.0f, 0.0f, 1.0f));

This should create a bright yellow color (1.0, 0.8, 0.0) = (COLOR0.r, COLOR1.g, COLOR2.b), but I am getting white with a purple tint.

I am using the latest release rpr 1.35.1.

Thanks for any help in advance.

0 Likes
1 Solution
bsavery
Staff

That OP looks a bit strange from the code.  One way you could do this would be to do (in pseudo code)

COLOR0 * (1.0, 0.0, 0.0, 0.0) + COLOR1 * (0.0, 1.0, 0.0, 0.0) + COLOR2 * (0.0, 0.0, 1.0, 0.0) + (0.0, 0.0, 0.0, 1.0)

View solution in original post

0 Likes
2 Replies
bsavery
Staff

That OP looks a bit strange from the code.  One way you could do this would be to do (in pseudo code)

COLOR0 * (1.0, 0.0, 0.0, 0.0) + COLOR1 * (0.0, 1.0, 0.0, 0.0) + COLOR2 * (0.0, 0.0, 1.0, 0.0) + (0.0, 0.0, 0.0, 1.0)

0 Likes
shauser67
Journeyman III

Thanks, this has solved the problem!

0 Likes