Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_map_range.c
| Show All 31 Lines | static bNodeSocketTemplate sh_node_map_range_in[] = { | ||||
| {SOCK_FLOAT, 1, N_("To Max"), 1.0f, 1.0f, 1.0f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, | {SOCK_FLOAT, 1, N_("To Max"), 1.0f, 1.0f, 1.0f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, | ||||
| {-1, 0, ""}, | {-1, 0, ""}, | ||||
| }; | }; | ||||
| static bNodeSocketTemplate sh_node_map_range_out[] = { | static bNodeSocketTemplate sh_node_map_range_out[] = { | ||||
| {SOCK_FLOAT, 0, N_("Result")}, | {SOCK_FLOAT, 0, N_("Result")}, | ||||
| {-1, 0, ""}, | {-1, 0, ""}, | ||||
| }; | }; | ||||
| static void node_shader_init_map_range(bNodeTree *UNUSED(ntree), bNode *node) | |||||
| { | |||||
| node->custom1 = true; | |||||
| } | |||||
| static int gpu_shader_map_range(GPUMaterial *mat, | static int gpu_shader_map_range(GPUMaterial *mat, | ||||
| bNode *node, | bNode *node, | ||||
| bNodeExecData *UNUSED(execdata), | bNodeExecData *UNUSED(execdata), | ||||
| GPUNodeStack *in, | GPUNodeStack *in, | ||||
| GPUNodeStack *out) | GPUNodeStack *out) | ||||
| { | { | ||||
| return GPU_stack_link(mat, node, "map_range", in, out); | GPU_stack_link(mat, node, "map_range", in, out); | ||||
| if (node->custom1) { | |||||
| GPU_link(mat, "clamp_value", out[0].link, in[3].link, in[4].link, &out[0].link); | |||||
| } | |||||
| return 1; | |||||
| } | } | ||||
| void register_node_type_sh_map_range(void) | void register_node_type_sh_map_range(void) | ||||
| { | { | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_node_type_base(&ntype, SH_NODE_MAP_RANGE, "Map Range", NODE_CLASS_CONVERTOR, 0); | sh_node_type_base(&ntype, SH_NODE_MAP_RANGE, "Map Range", NODE_CLASS_CONVERTOR, 0); | ||||
| node_type_socket_templates(&ntype, sh_node_map_range_in, sh_node_map_range_out); | node_type_socket_templates(&ntype, sh_node_map_range_in, sh_node_map_range_out); | ||||
| node_type_init(&ntype, node_shader_init_map_range); | |||||
| node_type_gpu(&ntype, gpu_shader_map_range); | node_type_gpu(&ntype, gpu_shader_map_range); | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||