Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc
| Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | public: | ||||
| { | { | ||||
| static blender::fn::MFSignature signature = create_signature(); | static blender::fn::MFSignature signature = create_signature(); | ||||
| this->set_signature(&signature); | this->set_signature(&signature); | ||||
| } | } | ||||
| static blender::fn::MFSignature create_signature() | static blender::fn::MFSignature create_signature() | ||||
| { | { | ||||
| blender::fn::MFSignatureBuilder signature{"Separate RGB"}; | blender::fn::MFSignatureBuilder signature{"Separate RGB"}; | ||||
| signature.single_input<blender::Color4f>("Color"); | signature.single_input<blender::ColorGeometry4f>("Color"); | ||||
EAW: By dropping the `4f` it isn’t as clear in areas of the code like this one that `ColorGeometry`… | |||||
Done Inline Actions@Jacques Lucke (JacquesLucke) What do you think? jbakker: @JacquesLucke What do you think? | |||||
Done Inline ActionsIn this design ColorGeometry always has exactly four floats, right? JacquesLucke: In this design `ColorGeometry` always has exactly four floats, right?
I think having the `4f`… | |||||
| signature.single_output<float>("R"); | signature.single_output<float>("R"); | ||||
| signature.single_output<float>("G"); | signature.single_output<float>("G"); | ||||
| signature.single_output<float>("B"); | signature.single_output<float>("B"); | ||||
| return signature.build(); | return signature.build(); | ||||
| } | } | ||||
| void call(blender::IndexMask mask, | void call(blender::IndexMask mask, | ||||
| blender::fn::MFParams params, | blender::fn::MFParams params, | ||||
| blender::fn::MFContext UNUSED(context)) const override | blender::fn::MFContext UNUSED(context)) const override | ||||
| { | { | ||||
| const blender::VArray<blender::Color4f> &colors = | const blender::VArray<blender::ColorGeometry4f> &colors = | ||||
| params.readonly_single_input<blender::Color4f>(0, "Color"); | params.readonly_single_input<blender::ColorGeometry4f>(0, "Color"); | ||||
| blender::MutableSpan<float> rs = params.uninitialized_single_output<float>(1, "R"); | blender::MutableSpan<float> rs = params.uninitialized_single_output<float>(1, "R"); | ||||
| blender::MutableSpan<float> gs = params.uninitialized_single_output<float>(2, "G"); | blender::MutableSpan<float> gs = params.uninitialized_single_output<float>(2, "G"); | ||||
| blender::MutableSpan<float> bs = params.uninitialized_single_output<float>(3, "B"); | blender::MutableSpan<float> bs = params.uninitialized_single_output<float>(3, "B"); | ||||
| for (int64_t i : mask) { | for (int64_t i : mask) { | ||||
| blender::Color4f color = colors[i]; | blender::ColorGeometry4f color = colors[i]; | ||||
| rs[i] = color.r; | rs[i] = color.r; | ||||
| gs[i] = color.g; | gs[i] = color.g; | ||||
| bs[i] = color.b; | bs[i] = color.b; | ||||
| } | } | ||||
| } | } | ||||
| }; | }; | ||||
| static void sh_node_seprgb_expand_in_mf_network(blender::nodes::NodeMFNetworkBuilder &builder) | static void sh_node_seprgb_expand_in_mf_network(blender::nodes::NodeMFNetworkBuilder &builder) | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | static int gpu_shader_combrgb(GPUMaterial *mat, | ||||
| GPUNodeStack *in, | GPUNodeStack *in, | ||||
| GPUNodeStack *out) | GPUNodeStack *out) | ||||
| { | { | ||||
| return GPU_stack_link(mat, node, "combine_rgb", in, out); | return GPU_stack_link(mat, node, "combine_rgb", in, out); | ||||
| } | } | ||||
| static void sh_node_combrgb_expand_in_mf_network(blender::nodes::NodeMFNetworkBuilder &builder) | static void sh_node_combrgb_expand_in_mf_network(blender::nodes::NodeMFNetworkBuilder &builder) | ||||
| { | { | ||||
| static blender::fn::CustomMF_SI_SI_SI_SO<float, float, float, blender::Color4f> fn{ | static blender::fn::CustomMF_SI_SI_SI_SO<float, float, float, blender::ColorGeometry4f> fn{ | ||||
| "Combine RGB", [](float r, float g, float b) { return blender::Color4f(r, g, b, 1.0f); }}; | "Combine RGB", | ||||
| [](float r, float g, float b) { return blender::ColorGeometry4f(r, g, b, 1.0f); }}; | |||||
| builder.set_matching_fn(fn); | builder.set_matching_fn(fn); | ||||
| } | } | ||||
| void register_node_type_sh_combrgb(void) | void register_node_type_sh_combrgb(void) | ||||
| { | { | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_fn_node_type_base(&ntype, SH_NODE_COMBRGB, "Combine RGB", NODE_CLASS_CONVERTOR, 0); | sh_fn_node_type_base(&ntype, SH_NODE_COMBRGB, "Combine RGB", NODE_CLASS_CONVERTOR, 0); | ||||
| node_type_socket_templates(&ntype, sh_node_combrgb_in, sh_node_combrgb_out); | node_type_socket_templates(&ntype, sh_node_combrgb_in, sh_node_combrgb_out); | ||||
| node_type_exec(&ntype, nullptr, nullptr, node_shader_exec_combrgb); | node_type_exec(&ntype, nullptr, nullptr, node_shader_exec_combrgb); | ||||
| node_type_gpu(&ntype, gpu_shader_combrgb); | node_type_gpu(&ntype, gpu_shader_combrgb); | ||||
| ntype.expand_in_mf_network = sh_node_combrgb_expand_in_mf_network; | ntype.expand_in_mf_network = sh_node_combrgb_expand_in_mf_network; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||
By dropping the 4f it isn’t as clear in areas of the code like this one that ColorGeometry is 4 floats and not 3. Perhaps ColorGeometry4f would be clearer.