Fix: Forward compatibility issue in shader nodes
Raised in https://developer.blender.org/rBe5618725fd1e Reviewed By: brecht Differential Revision: https://developer.blender.org/D6102
This commit is contained in:
parent
e71963a37e
commit
3a65ea3b2d
|
@ -82,7 +82,10 @@ void *node_initexec_curves(bNodeExecContext *UNUSED(context),
|
|||
void node_blend_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen)
|
||||
{
|
||||
const char *name;
|
||||
RNA_enum_name(rna_enum_ramp_blend_items, node->custom1, &name);
|
||||
bool enum_label = RNA_enum_name(rna_enum_ramp_blend_items, node->custom1, &name);
|
||||
if (!enum_label) {
|
||||
name = "Unknown";
|
||||
}
|
||||
BLI_strncpy(label, IFACE_(name), maxlen);
|
||||
}
|
||||
|
||||
|
@ -96,21 +99,30 @@ void node_image_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int ma
|
|||
void node_math_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen)
|
||||
{
|
||||
const char *name;
|
||||
RNA_enum_name(rna_enum_node_math_items, node->custom1, &name);
|
||||
bool enum_label = RNA_enum_name(rna_enum_node_math_items, node->custom1, &name);
|
||||
if (!enum_label) {
|
||||
name = "Unknown";
|
||||
}
|
||||
BLI_strncpy(label, IFACE_(name), maxlen);
|
||||
}
|
||||
|
||||
void node_vector_math_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen)
|
||||
{
|
||||
const char *name;
|
||||
RNA_enum_name(rna_enum_node_vec_math_items, node->custom1, &name);
|
||||
bool enum_label = RNA_enum_name(rna_enum_node_vec_math_items, node->custom1, &name);
|
||||
if (!enum_label) {
|
||||
name = "Unknown";
|
||||
}
|
||||
BLI_strncpy(label, IFACE_(name), maxlen);
|
||||
}
|
||||
|
||||
void node_filter_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen)
|
||||
{
|
||||
const char *name;
|
||||
RNA_enum_name(rna_enum_node_filter_items, node->custom1, &name);
|
||||
bool enum_label = RNA_enum_name(rna_enum_node_filter_items, node->custom1, &name);
|
||||
if (!enum_label) {
|
||||
name = "Unknown";
|
||||
}
|
||||
BLI_strncpy(label, IFACE_(name), maxlen);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,12 @@ static int gpu_shader_mapping(GPUMaterial *mat,
|
|||
[NODE_MAPPING_TYPE_NORMAL] = "mapping_normal",
|
||||
};
|
||||
|
||||
return GPU_stack_link(mat, node, names[node->custom1], in, out);
|
||||
if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) {
|
||||
return GPU_stack_link(mat, node, names[node->custom1], in, out);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void node_shader_update_mapping(bNodeTree *UNUSED(ntree), bNode *node)
|
||||
|
|
|
@ -68,14 +68,19 @@ static int gpu_shader_math(GPUMaterial *mat,
|
|||
[NODE_MATH_ARCTAN2] = "math_arctan2",
|
||||
};
|
||||
|
||||
GPU_stack_link(mat, node, names[node->custom1], in, out);
|
||||
if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) {
|
||||
int ret = GPU_stack_link(mat, node, names[node->custom1], in, out);
|
||||
|
||||
if (node->custom2 & SHD_MATH_CLAMP) {
|
||||
float min[3] = {0.0f, 0.0f, 0.0f};
|
||||
float max[3] = {1.0f, 1.0f, 1.0f};
|
||||
GPU_link(mat, "clamp_value", out[0].link, GPU_constant(min), GPU_constant(max), &out[0].link);
|
||||
if (ret && node->custom2 & SHD_MATH_CLAMP) {
|
||||
float min[3] = {0.0f, 0.0f, 0.0f};
|
||||
float max[3] = {1.0f, 1.0f, 1.0f};
|
||||
GPU_link(mat, "clamp_value", out[0].link, GPU_constant(min), GPU_constant(max), &out[0].link);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void node_shader_update_math(bNodeTree *UNUSED(ntree), bNode *node)
|
||||
|
|
|
@ -88,13 +88,18 @@ static int gpu_shader_mix_rgb(GPUMaterial *mat,
|
|||
"mix_linear",
|
||||
};
|
||||
|
||||
int ret = GPU_stack_link(mat, node, names[node->custom1], in, out);
|
||||
if (ret && node->custom2 & SHD_MIXRGB_CLAMP) {
|
||||
float min[3] = {0.0f, 0.0f, 0.0f};
|
||||
float max[3] = {1.0f, 1.0f, 1.0f};
|
||||
GPU_link(mat, "clamp_color", out[0].link, GPU_constant(min), GPU_constant(max), &out[0].link);
|
||||
if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) {
|
||||
int ret = GPU_stack_link(mat, node, names[node->custom1], in, out);
|
||||
if (ret && node->custom2 & SHD_MIXRGB_CLAMP) {
|
||||
float min[3] = {0.0f, 0.0f, 0.0f};
|
||||
float max[3] = {1.0f, 1.0f, 1.0f};
|
||||
GPU_link(mat, "clamp_color", out[0].link, GPU_constant(min), GPU_constant(max), &out[0].link);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void register_node_type_sh_mix_rgb(void)
|
||||
|
|
|
@ -50,7 +50,12 @@ static int gpu_shader_tex_white_noise(GPUMaterial *mat,
|
|||
"node_white_noise_4d",
|
||||
};
|
||||
|
||||
return GPU_stack_link(mat, node, names[node->custom1], in, out);
|
||||
if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) {
|
||||
return GPU_stack_link(mat, node, names[node->custom1], in, out);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void node_shader_update_tex_white_noise(bNodeTree *UNUSED(ntree), bNode *node)
|
||||
|
|
|
@ -65,8 +65,12 @@ static int gpu_shader_vector_math(GPUMaterial *mat,
|
|||
[NODE_VECTOR_MATH_MAXIMUM] = "vector_math_maximum",
|
||||
};
|
||||
|
||||
GPU_stack_link(mat, node, names[node->custom1], in, out);
|
||||
return true;
|
||||
if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) {
|
||||
return GPU_stack_link(mat, node, names[node->custom1], in, out);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void node_shader_update_vector_math(bNodeTree *UNUSED(ntree), bNode *node)
|
||||
|
|
Loading…
Reference in New Issue