~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/nodes/shader/nodes/node_shader_tex_image.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
#include "../node_shader_util.h"
29
29
 
 
30
#include "IMB_colormanagement.h"
 
31
 
30
32
/* **************** OUTPUT ******************** */
31
33
 
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},
34
 
        {       -1, 0, ""       }
35
 
};
36
 
 
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},
40
 
        {       -1, 0, ""       }
41
 
};
42
 
 
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},
 
36
        {       -1, 0, ""       }
 
37
};
 
38
 
 
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},
 
42
        {       -1, 0, ""       }
 
43
};
 
44
 
 
45
static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
44
46
{
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;
 
51
        tex->iuser.frames= 1;
 
52
        tex->iuser.sfra= 1;
 
53
        tex->iuser.fie_ima= 2;
 
54
        tex->iuser.ok= 1;
49
55
 
50
56
        node->storage = tex;
51
57
}
54
60
{
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;
 
65
        int ret;
57
66
 
58
 
        if (!ima) {
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);
62
 
        }
 
67
        if (!ima)
 
68
                return GPU_stack_link(mat, "node_tex_image_empty", in, out);
63
69
        
64
70
        if (!in[0].link)
65
71
                in[0].link = GPU_attribute(CD_MTFACE, "");
66
72
 
67
73
        node_shader_gpu_tex_mapping(mat, node, in, out);
68
74
 
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));
 
76
 
 
77
        if (ret) {
 
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))
 
81
                {
 
82
                        GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link);
 
83
                }
 
84
                BKE_image_release_ibuf(ima, ibuf, NULL);
 
85
        }
 
86
 
 
87
        return ret;
70
88
}
71
89
 
72
90
/* node type definition */