Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_curves.cc
| Show All 17 Lines | |||||
| */ | */ | ||||
| /** \file | /** \file | ||||
| * \ingroup shdnodes | * \ingroup shdnodes | ||||
| */ | */ | ||||
| #include "node_shader_util.hh" | #include "node_shader_util.hh" | ||||
| namespace blender::nodes { | namespace blender::nodes::node_shader_curve_vec_cc { | ||||
| static void sh_node_curve_vec_declare(NodeDeclarationBuilder &b) | static void sh_node_curve_vec_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.is_function_node(); | b.is_function_node(); | ||||
| b.add_input<decl::Float>(N_("Fac")).min(0.0f).max(1.0f).default_value(1.0f).subtype(PROP_FACTOR); | b.add_input<decl::Float>(N_("Fac")).min(0.0f).max(1.0f).default_value(1.0f).subtype(PROP_FACTOR); | ||||
| b.add_input<decl::Vector>(N_("Vector")).min(-1.0f).max(1.0f); | b.add_input<decl::Vector>(N_("Vector")).min(-1.0f).max(1.0f); | ||||
| b.add_output<decl::Vector>(N_("Vector")); | b.add_output<decl::Vector>(N_("Vector")); | ||||
| }; | }; | ||||
| } // namespace blender::nodes | |||||
| static void node_shader_exec_curve_vec(void *UNUSED(data), | static void node_shader_exec_curve_vec(void *UNUSED(data), | ||||
| int UNUSED(thread), | int UNUSED(thread), | ||||
| bNode *node, | bNode *node, | ||||
| bNodeExecData *UNUSED(execdata), | bNodeExecData *UNUSED(execdata), | ||||
| bNodeStack **in, | bNodeStack **in, | ||||
| bNodeStack **out) | bNodeStack **out) | ||||
| { | { | ||||
| float vec[3]; | float vec[3]; | ||||
| ▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | static void sh_node_curve_vec_build_multi_function( | ||||
| blender::nodes::NodeMultiFunctionBuilder &builder) | blender::nodes::NodeMultiFunctionBuilder &builder) | ||||
| { | { | ||||
| bNode &bnode = builder.node(); | bNode &bnode = builder.node(); | ||||
| CurveMapping *cumap = (CurveMapping *)bnode.storage; | CurveMapping *cumap = (CurveMapping *)bnode.storage; | ||||
| BKE_curvemapping_init(cumap); | BKE_curvemapping_init(cumap); | ||||
| builder.construct_and_set_matching_fn<CurveVecFunction>(*cumap); | builder.construct_and_set_matching_fn<CurveVecFunction>(*cumap); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_shader_curve_vec_cc | |||||
| void register_node_type_sh_curve_vec(void) | void register_node_type_sh_curve_vec(void) | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_shader_curve_vec_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_fn_node_type_base(&ntype, SH_NODE_CURVE_VEC, "Vector Curves", NODE_CLASS_OP_VECTOR, 0); | sh_fn_node_type_base(&ntype, SH_NODE_CURVE_VEC, "Vector Curves", NODE_CLASS_OP_VECTOR, 0); | ||||
| ntype.declare = blender::nodes::sh_node_curve_vec_declare; | ntype.declare = file_ns::sh_node_curve_vec_declare; | ||||
| node_type_init(&ntype, node_shader_init_curve_vec); | node_type_init(&ntype, file_ns::node_shader_init_curve_vec); | ||||
| node_type_size_preset(&ntype, NODE_SIZE_LARGE); | node_type_size_preset(&ntype, NODE_SIZE_LARGE); | ||||
| node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); | node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); | ||||
| node_type_exec(&ntype, node_initexec_curves, nullptr, node_shader_exec_curve_vec); | node_type_exec(&ntype, node_initexec_curves, nullptr, file_ns::node_shader_exec_curve_vec); | ||||
| node_type_gpu(&ntype, gpu_shader_curve_vec); | node_type_gpu(&ntype, file_ns::gpu_shader_curve_vec); | ||||
| ntype.build_multi_function = sh_node_curve_vec_build_multi_function; | ntype.build_multi_function = file_ns::sh_node_curve_vec_build_multi_function; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||
| /* **************** CURVE RGB ******************** */ | /* **************** CURVE RGB ******************** */ | ||||
| namespace blender::nodes { | namespace blender::nodes::node_shader_curve_rgb_cc { | ||||
| static void sh_node_curve_rgb_declare(NodeDeclarationBuilder &b) | static void sh_node_curve_rgb_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.is_function_node(); | b.is_function_node(); | ||||
| b.add_input<decl::Float>(N_("Fac")).min(0.0f).max(1.0f).default_value(1.0f).subtype(PROP_FACTOR); | b.add_input<decl::Float>(N_("Fac")).min(0.0f).max(1.0f).default_value(1.0f).subtype(PROP_FACTOR); | ||||
| b.add_input<decl::Color>(N_("Color")).default_value({1.0f, 1.0f, 1.0f, 1.0f}); | b.add_input<decl::Color>(N_("Color")).default_value({1.0f, 1.0f, 1.0f, 1.0f}); | ||||
| b.add_output<decl::Color>(N_("Color")); | b.add_output<decl::Color>(N_("Color")); | ||||
| }; | }; | ||||
| } // namespace blender::nodes | |||||
| static void node_shader_exec_curve_rgb(void *UNUSED(data), | static void node_shader_exec_curve_rgb(void *UNUSED(data), | ||||
| int UNUSED(thread), | int UNUSED(thread), | ||||
| bNode *node, | bNode *node, | ||||
| bNodeExecData *UNUSED(execdata), | bNodeExecData *UNUSED(execdata), | ||||
| bNodeStack **in, | bNodeStack **in, | ||||
| bNodeStack **out) | bNodeStack **out) | ||||
| { | { | ||||
| float vec[3]; | float vec[3]; | ||||
| ▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | static void sh_node_curve_rgb_build_multi_function( | ||||
| blender::nodes::NodeMultiFunctionBuilder &builder) | blender::nodes::NodeMultiFunctionBuilder &builder) | ||||
| { | { | ||||
| bNode &bnode = builder.node(); | bNode &bnode = builder.node(); | ||||
| CurveMapping *cumap = (CurveMapping *)bnode.storage; | CurveMapping *cumap = (CurveMapping *)bnode.storage; | ||||
| BKE_curvemapping_init(cumap); | BKE_curvemapping_init(cumap); | ||||
| builder.construct_and_set_matching_fn<CurveRGBFunction>(*cumap); | builder.construct_and_set_matching_fn<CurveRGBFunction>(*cumap); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_shader_curve_rgb_cc | |||||
| void register_node_type_sh_curve_rgb(void) | void register_node_type_sh_curve_rgb(void) | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_shader_curve_rgb_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_fn_node_type_base(&ntype, SH_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR, 0); | sh_fn_node_type_base(&ntype, SH_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR, 0); | ||||
| ntype.declare = blender::nodes::sh_node_curve_rgb_declare; | ntype.declare = file_ns::sh_node_curve_rgb_declare; | ||||
| node_type_init(&ntype, node_shader_init_curve_rgb); | node_type_init(&ntype, file_ns::node_shader_init_curve_rgb); | ||||
| node_type_size_preset(&ntype, NODE_SIZE_LARGE); | node_type_size_preset(&ntype, NODE_SIZE_LARGE); | ||||
| node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); | node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); | ||||
| node_type_exec(&ntype, node_initexec_curves, nullptr, node_shader_exec_curve_rgb); | node_type_exec(&ntype, node_initexec_curves, nullptr, file_ns::node_shader_exec_curve_rgb); | ||||
| node_type_gpu(&ntype, gpu_shader_curve_rgb); | node_type_gpu(&ntype, file_ns::gpu_shader_curve_rgb); | ||||
| ntype.build_multi_function = sh_node_curve_rgb_build_multi_function; | ntype.build_multi_function = file_ns::sh_node_curve_rgb_build_multi_function; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||
| /* **************** CURVE FLOAT ******************** */ | /* **************** CURVE FLOAT ******************** */ | ||||
| namespace blender::nodes { | namespace blender::nodes::node_shader_curve_float_cc { | ||||
| static void sh_node_curve_float_declare(NodeDeclarationBuilder &b) | static void sh_node_curve_float_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.is_function_node(); | b.is_function_node(); | ||||
| b.add_input<decl::Float>(N_("Factor")) | b.add_input<decl::Float>(N_("Factor")) | ||||
| .min(0.0f) | .min(0.0f) | ||||
| .max(1.0f) | .max(1.0f) | ||||
| .default_value(1.0f) | .default_value(1.0f) | ||||
| .subtype(PROP_FACTOR); | .subtype(PROP_FACTOR); | ||||
| b.add_input<decl::Float>(N_("Value")).default_value(1.0f).is_default_link_socket(); | b.add_input<decl::Float>(N_("Value")).default_value(1.0f).is_default_link_socket(); | ||||
| b.add_output<decl::Float>(N_("Value")); | b.add_output<decl::Float>(N_("Value")); | ||||
| }; | }; | ||||
| } // namespace blender::nodes | |||||
| static void node_shader_exec_curve_float(void *UNUSED(data), | static void node_shader_exec_curve_float(void *UNUSED(data), | ||||
| int UNUSED(thread), | int UNUSED(thread), | ||||
| bNode *node, | bNode *node, | ||||
| bNodeExecData *UNUSED(execdata), | bNodeExecData *UNUSED(execdata), | ||||
| bNodeStack **in, | bNodeStack **in, | ||||
| bNodeStack **out) | bNodeStack **out) | ||||
| { | { | ||||
| float value; | float value; | ||||
| ▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | static void sh_node_curve_float_build_multi_function( | ||||
| blender::nodes::NodeMultiFunctionBuilder &builder) | blender::nodes::NodeMultiFunctionBuilder &builder) | ||||
| { | { | ||||
| bNode &bnode = builder.node(); | bNode &bnode = builder.node(); | ||||
| CurveMapping *cumap = (CurveMapping *)bnode.storage; | CurveMapping *cumap = (CurveMapping *)bnode.storage; | ||||
| BKE_curvemapping_init(cumap); | BKE_curvemapping_init(cumap); | ||||
| builder.construct_and_set_matching_fn<CurveFloatFunction>(*cumap); | builder.construct_and_set_matching_fn<CurveFloatFunction>(*cumap); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_shader_curve_float_cc | |||||
| void register_node_type_sh_curve_float(void) | void register_node_type_sh_curve_float(void) | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_shader_curve_float_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_fn_node_type_base(&ntype, SH_NODE_CURVE_FLOAT, "Float Curve", NODE_CLASS_CONVERTER, 0); | sh_fn_node_type_base(&ntype, SH_NODE_CURVE_FLOAT, "Float Curve", NODE_CLASS_CONVERTER, 0); | ||||
| ntype.declare = blender::nodes::sh_node_curve_float_declare; | ntype.declare = file_ns::sh_node_curve_float_declare; | ||||
| node_type_init(&ntype, node_shader_init_curve_float); | node_type_init(&ntype, file_ns::node_shader_init_curve_float); | ||||
| node_type_size_preset(&ntype, NODE_SIZE_LARGE); | node_type_size_preset(&ntype, NODE_SIZE_LARGE); | ||||
| node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); | node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); | ||||
| node_type_exec(&ntype, node_initexec_curves, nullptr, node_shader_exec_curve_float); | node_type_exec(&ntype, node_initexec_curves, nullptr, file_ns::node_shader_exec_curve_float); | ||||
| node_type_gpu(&ntype, gpu_shader_curve_float); | node_type_gpu(&ntype, file_ns::gpu_shader_curve_float); | ||||
| ntype.build_multi_function = sh_node_curve_float_build_multi_function; | ntype.build_multi_function = file_ns::sh_node_curve_float_build_multi_function; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||