Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_math.cc
| Show All 21 Lines | |||||
| */ | */ | ||||
| #include "node_shader_util.hh" | #include "node_shader_util.hh" | ||||
| #include "NOD_math_functions.hh" | #include "NOD_math_functions.hh" | ||||
| /* **************** SCALAR MATH ******************** */ | /* **************** SCALAR MATH ******************** */ | ||||
| namespace blender::nodes { | namespace blender::nodes::node_shader_math_cc { | ||||
| static void sh_node_math_declare(NodeDeclarationBuilder &b) | static void sh_node_math_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.is_function_node(); | b.is_function_node(); | ||||
| b.add_input<decl::Float>(N_("Value")).default_value(0.5f).min(-10000.0f).max(10000.0f); | b.add_input<decl::Float>(N_("Value")).default_value(0.5f).min(-10000.0f).max(10000.0f); | ||||
| b.add_input<decl::Float>(N_("Value"), "Value_001") | b.add_input<decl::Float>(N_("Value"), "Value_001") | ||||
| .default_value(0.5f) | .default_value(0.5f) | ||||
| .min(-10000.0f) | .min(-10000.0f) | ||||
| .max(10000.0f); | .max(10000.0f); | ||||
| b.add_input<decl::Float>(N_("Value"), "Value_002") | b.add_input<decl::Float>(N_("Value"), "Value_002") | ||||
| .default_value(0.5f) | .default_value(0.5f) | ||||
| .min(-10000.0f) | .min(-10000.0f) | ||||
| .max(10000.0f); | .max(10000.0f); | ||||
| b.add_output<decl::Float>(N_("Value")); | b.add_output<decl::Float>(N_("Value")); | ||||
| }; | }; | ||||
| } // namespace blender::nodes | |||||
| static const char *gpu_shader_get_name(int mode) | static const char *gpu_shader_get_name(int mode) | ||||
| { | { | ||||
| const blender::nodes::FloatMathOperationInfo *info = | const blender::nodes::FloatMathOperationInfo *info = | ||||
| blender::nodes::get_float_math_operation_info(mode); | blender::nodes::get_float_math_operation_info(mode); | ||||
| if (!info) { | if (!info) { | ||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| if (info->shader_name.is_empty()) { | if (info->shader_name.is_empty()) { | ||||
| ▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | static void sh_node_math_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder) | ||||
| if (clamp_output) { | if (clamp_output) { | ||||
| builder.construct_and_set_matching_fn<ClampWrapperFunction>(*base_function); | builder.construct_and_set_matching_fn<ClampWrapperFunction>(*base_function); | ||||
| } | } | ||||
| else { | else { | ||||
| builder.set_matching_fn(base_function); | builder.set_matching_fn(base_function); | ||||
| } | } | ||||
| } | } | ||||
| } // namespace blender::nodes::node_shader_math_cc | |||||
| void register_node_type_sh_math() | void register_node_type_sh_math() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_shader_math_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_fn_node_type_base(&ntype, SH_NODE_MATH, "Math", NODE_CLASS_CONVERTER, 0); | sh_fn_node_type_base(&ntype, SH_NODE_MATH, "Math", NODE_CLASS_CONVERTER, 0); | ||||
| ntype.declare = blender::nodes::sh_node_math_declare; | ntype.declare = file_ns::sh_node_math_declare; | ||||
| node_type_label(&ntype, node_math_label); | node_type_label(&ntype, node_math_label); | ||||
| node_type_gpu(&ntype, gpu_shader_math); | node_type_gpu(&ntype, file_ns::gpu_shader_math); | ||||
| node_type_update(&ntype, node_math_update); | node_type_update(&ntype, node_math_update); | ||||
| ntype.build_multi_function = sh_node_math_build_multi_function; | ntype.build_multi_function = file_ns::sh_node_math_build_multi_function; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||