Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_color_ramp.cc
| Show All 31 Lines | |||||
| static void sh_node_valtorgb_declare(NodeDeclarationBuilder &b) | static void sh_node_valtorgb_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.is_function_node(); | b.is_function_node(); | ||||
| b.add_input<decl::Float>(N_("Fac")).default_value(0.5f).min(0.0f).max(1.0f).subtype(PROP_FACTOR); | b.add_input<decl::Float>(N_("Fac")).default_value(0.5f).min(0.0f).max(1.0f).subtype(PROP_FACTOR); | ||||
| b.add_output<decl::Color>(N_("Color")); | b.add_output<decl::Color>(N_("Color")); | ||||
| b.add_output<decl::Float>(N_("Alpha")); | b.add_output<decl::Float>(N_("Alpha")); | ||||
| }; | }; | ||||
| static void node_shader_exec_valtorgb(void *UNUSED(data), | |||||
| int UNUSED(thread), | |||||
| bNode *node, | |||||
| bNodeExecData *UNUSED(execdata), | |||||
| bNodeStack **in, | |||||
| bNodeStack **out) | |||||
| { | |||||
| /* stack order in: fac */ | |||||
| /* stack order out: col, alpha */ | |||||
| if (node->storage) { | |||||
| float fac; | |||||
| nodestack_get_vec(&fac, SOCK_FLOAT, in[0]); | |||||
| BKE_colorband_evaluate((ColorBand *)node->storage, fac, out[0]->vec); | |||||
| out[1]->vec[0] = out[0]->vec[3]; | |||||
| } | |||||
| } | |||||
| static void node_shader_init_valtorgb(bNodeTree *UNUSED(ntree), bNode *node) | static void node_shader_init_valtorgb(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| node->storage = BKE_colorband_add(true); | node->storage = BKE_colorband_add(true); | ||||
| } | } | ||||
| static int gpu_shader_valtorgb(GPUMaterial *mat, | static int gpu_shader_valtorgb(GPUMaterial *mat, | ||||
| bNode *node, | bNode *node, | ||||
| bNodeExecData *UNUSED(execdata), | bNodeExecData *UNUSED(execdata), | ||||
| ▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | void register_node_type_sh_valtorgb() | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_fn_node_type_base(&ntype, SH_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTER); | sh_fn_node_type_base(&ntype, SH_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTER); | ||||
| ntype.declare = file_ns::sh_node_valtorgb_declare; | ntype.declare = file_ns::sh_node_valtorgb_declare; | ||||
| node_type_init(&ntype, file_ns::node_shader_init_valtorgb); | node_type_init(&ntype, file_ns::node_shader_init_valtorgb); | ||||
| node_type_size_preset(&ntype, NODE_SIZE_LARGE); | node_type_size_preset(&ntype, NODE_SIZE_LARGE); | ||||
| node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage); | node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage); | ||||
| node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_valtorgb); | |||||
| node_type_gpu(&ntype, file_ns::gpu_shader_valtorgb); | node_type_gpu(&ntype, file_ns::gpu_shader_valtorgb); | ||||
| ntype.build_multi_function = file_ns::sh_node_valtorgb_build_multi_function; | ntype.build_multi_function = file_ns::sh_node_valtorgb_build_multi_function; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||