28
28
#include "../node_shader_util.h"
30
#include "IMB_colormanagement.h"
30
32
/* **************** OUTPUT ******************** */
32
static bNodeSocketTemplate sh_node_tex_image_in[]= {
33
{ SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
37
static bNodeSocketTemplate sh_node_tex_image_out[]= {
38
{ SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
39
{ SOCK_FLOAT, 0, "Alpha", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
43
static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
34
static bNodeSocketTemplate sh_node_tex_image_in[] = {
35
{ SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
39
static bNodeSocketTemplate sh_node_tex_image_out[] = {
40
{ SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
41
{ SOCK_FLOAT, 0, N_("Alpha"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
45
static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
45
47
NodeTexImage *tex = MEM_callocN(sizeof(NodeTexImage), "NodeTexImage");
46
48
default_tex_mapping(&tex->base.tex_mapping);
47
49
default_color_mapping(&tex->base.color_mapping);
48
50
tex->color_space = SHD_COLORSPACE_COLOR;
53
tex->iuser.fie_ima= 2;
50
56
node->storage = tex;
55
61
Image *ima= (Image*)node->id;
56
62
ImageUser *iuser= NULL;
63
NodeTexImage *tex = node->storage;
64
int isdata = tex->color_space == SHD_COLORSPACE_NONE;
59
float black[4] = {0.0f, 0.0f, 0.0f, 1.0f};
60
GPUNodeLink *vec = GPU_uniform(black);
61
return GPU_stack_link(mat, "set_rgba", out, out, vec);
68
return GPU_stack_link(mat, "node_tex_image_empty", in, out);
65
71
in[0].link = GPU_attribute(CD_MTFACE, "");
67
73
node_shader_gpu_tex_mapping(mat, node, in, out);
69
return GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser));
75
ret = GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser, isdata));
78
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
79
if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 &&
80
GPU_material_do_color_management(mat))
82
GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link);
84
BKE_image_release_ibuf(ima, ibuf, NULL);
72
90
/* node type definition */