Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_curves.cc
| Show All 27 Lines | |||||
| 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")); | ||||
| }; | }; | ||||
| static void node_shader_exec_curve_vec(void *UNUSED(data), | |||||
| int UNUSED(thread), | |||||
| bNode *node, | |||||
| bNodeExecData *UNUSED(execdata), | |||||
| bNodeStack **in, | |||||
| bNodeStack **out) | |||||
| { | |||||
| float vec[3]; | |||||
| /* stack order input: vec */ | |||||
| /* stack order output: vec */ | |||||
| nodestack_get_vec(vec, SOCK_VECTOR, in[1]); | |||||
| BKE_curvemapping_evaluate3F((CurveMapping *)node->storage, out[0]->vec, vec); | |||||
| } | |||||
| static void node_shader_init_curve_vec(bNodeTree *UNUSED(ntree), bNode *node) | static void node_shader_init_curve_vec(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| node->storage = BKE_curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f); | node->storage = BKE_curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f); | ||||
| } | } | ||||
| static int gpu_shader_curve_vec(GPUMaterial *mat, | static int gpu_shader_curve_vec(GPUMaterial *mat, | ||||
| bNode *node, | bNode *node, | ||||
| bNodeExecData *UNUSED(execdata), | bNodeExecData *UNUSED(execdata), | ||||
| ▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | void register_node_type_sh_curve_vec() | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_fn_node_type_base(&ntype, SH_NODE_CURVE_VEC, "Vector Curves", NODE_CLASS_OP_VECTOR); | sh_fn_node_type_base(&ntype, SH_NODE_CURVE_VEC, "Vector Curves", NODE_CLASS_OP_VECTOR); | ||||
| ntype.declare = file_ns::sh_node_curve_vec_declare; | ntype.declare = file_ns::sh_node_curve_vec_declare; | ||||
| node_type_init(&ntype, file_ns::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, file_ns::node_shader_exec_curve_vec); | |||||
| node_type_gpu(&ntype, file_ns::gpu_shader_curve_vec); | node_type_gpu(&ntype, file_ns::gpu_shader_curve_vec); | ||||
| ntype.build_multi_function = file_ns::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::node_shader_curves_cc { | namespace blender::nodes::node_shader_curves_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")); | ||||
| }; | }; | ||||
| static void node_shader_exec_curve_rgb(void *UNUSED(data), | |||||
| int UNUSED(thread), | |||||
| bNode *node, | |||||
| bNodeExecData *UNUSED(execdata), | |||||
| bNodeStack **in, | |||||
| bNodeStack **out) | |||||
| { | |||||
| float vec[3]; | |||||
| float fac; | |||||
| /* stack order input: vec */ | |||||
| /* stack order output: vec */ | |||||
| nodestack_get_vec(&fac, SOCK_FLOAT, in[0]); | |||||
| nodestack_get_vec(vec, SOCK_VECTOR, in[1]); | |||||
| BKE_curvemapping_evaluateRGBF((CurveMapping *)node->storage, out[0]->vec, vec); | |||||
| if (fac != 1.0f) { | |||||
| interp_v3_v3v3(out[0]->vec, vec, out[0]->vec, fac); | |||||
| } | |||||
| } | |||||
| static void node_shader_init_curve_rgb(bNodeTree *UNUSED(ntree), bNode *node) | static void node_shader_init_curve_rgb(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| node->storage = BKE_curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); | node->storage = BKE_curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); | ||||
| } | } | ||||
| static int gpu_shader_curve_rgb(GPUMaterial *mat, | static int gpu_shader_curve_rgb(GPUMaterial *mat, | ||||
| bNode *node, | bNode *node, | ||||
| bNodeExecData *UNUSED(execdata), | bNodeExecData *UNUSED(execdata), | ||||
| ▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | void register_node_type_sh_curve_rgb() | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_fn_node_type_base(&ntype, SH_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR); | sh_fn_node_type_base(&ntype, SH_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR); | ||||
| ntype.declare = file_ns::sh_node_curve_rgb_declare; | ntype.declare = file_ns::sh_node_curve_rgb_declare; | ||||
| node_type_init(&ntype, file_ns::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, file_ns::node_shader_exec_curve_rgb); | |||||
| node_type_gpu(&ntype, file_ns::gpu_shader_curve_rgb); | node_type_gpu(&ntype, file_ns::gpu_shader_curve_rgb); | ||||
| ntype.build_multi_function = file_ns::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::node_shader_curves_cc { | namespace blender::nodes::node_shader_curves_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")); | ||||
| }; | }; | ||||
| static void node_shader_exec_curve_float(void *UNUSED(data), | |||||
| int UNUSED(thread), | |||||
| bNode *node, | |||||
| bNodeExecData *UNUSED(execdata), | |||||
| bNodeStack **in, | |||||
| bNodeStack **out) | |||||
| { | |||||
| float value; | |||||
| float fac; | |||||
| nodestack_get_vec(&fac, SOCK_FLOAT, in[0]); | |||||
| nodestack_get_vec(&value, SOCK_FLOAT, in[1]); | |||||
| out[0]->vec[0] = BKE_curvemapping_evaluateF((CurveMapping *)node->storage, 0, value); | |||||
| if (fac != 1.0f) { | |||||
| out[0]->vec[0] = (1.0f - fac) * value + fac * out[0]->vec[0]; | |||||
| } | |||||
| } | |||||
| static void node_shader_init_curve_float(bNodeTree *UNUSED(ntree), bNode *node) | static void node_shader_init_curve_float(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| node->storage = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); | node->storage = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); | ||||
| } | } | ||||
| static int gpu_shader_curve_float(GPUMaterial *mat, | static int gpu_shader_curve_float(GPUMaterial *mat, | ||||
| bNode *node, | bNode *node, | ||||
| bNodeExecData *UNUSED(execdata), | bNodeExecData *UNUSED(execdata), | ||||
| ▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | void register_node_type_sh_curve_float() | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_fn_node_type_base(&ntype, SH_NODE_CURVE_FLOAT, "Float Curve", NODE_CLASS_CONVERTER); | sh_fn_node_type_base(&ntype, SH_NODE_CURVE_FLOAT, "Float Curve", NODE_CLASS_CONVERTER); | ||||
| ntype.declare = file_ns::sh_node_curve_float_declare; | ntype.declare = file_ns::sh_node_curve_float_declare; | ||||
| node_type_init(&ntype, file_ns::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, file_ns::node_shader_exec_curve_float); | |||||
| node_type_gpu(&ntype, file_ns::gpu_shader_curve_float); | node_type_gpu(&ntype, file_ns::gpu_shader_curve_float); | ||||
| ntype.build_multi_function = file_ns::sh_node_curve_float_build_multi_function; | ntype.build_multi_function = file_ns::sh_node_curve_float_build_multi_function; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||