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

« back to all changes in this revision

Viewing changes to source/blender/nodes/composite/nodes/node_composite_curves.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:
36
36
/* **************** CURVE Time  ******************** */
37
37
 
38
38
/* custom1 = sfra, custom2 = efra */
39
 
static bNodeSocketTemplate cmp_node_time_out[]= {
40
 
        {       SOCK_FLOAT, 0, "Fac"},
 
39
static bNodeSocketTemplate cmp_node_time_out[] = {
 
40
        {       SOCK_FLOAT, 0, N_("Fac")},
41
41
        {       -1, 0, ""       }
42
42
};
43
43
 
44
 
static void node_composit_exec_curves_time(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out)
45
 
{
46
 
        RenderData *rd= data;
47
 
        /* stack order output: fac */
48
 
        float fac= 0.0f;
49
 
        
50
 
        if (node->custom1 < node->custom2)
51
 
                fac= (rd->cfra - node->custom1)/(float)(node->custom2-node->custom1);
52
 
        
53
 
        fac= curvemapping_evaluateF(node->storage, 0, fac);
54
 
        out[0]->vec[0]= CLAMPIS(fac, 0.0f, 1.0f);
55
 
}
56
 
 
57
 
 
58
 
static void node_composit_init_curves_time(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 
44
static void node_composit_init_curves_time(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
59
45
{
60
46
        node->custom1= 1;
61
47
        node->custom2= 250;
71
57
        node_type_size(&ntype, 140, 100, 320);
72
58
        node_type_init(&ntype, node_composit_init_curves_time);
73
59
        node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);
74
 
        node_type_exec(&ntype, node_composit_exec_curves_time);
75
60
 
76
61
        nodeRegisterType(ttype, &ntype);
77
62
}
79
64
 
80
65
 
81
66
/* **************** CURVE VEC  ******************** */
82
 
static bNodeSocketTemplate cmp_node_curve_vec_in[]= {
83
 
        {       SOCK_VECTOR, 1, "Vector",       0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE},
84
 
        {       -1, 0, ""       }
85
 
};
86
 
 
87
 
static bNodeSocketTemplate cmp_node_curve_vec_out[]= {
88
 
        {       SOCK_VECTOR, 0, "Vector"},
89
 
        {       -1, 0, ""       }
90
 
};
91
 
 
92
 
static void node_composit_exec_curve_vec(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
93
 
{
94
 
        /* stack order input:  vec */
95
 
        /* stack order output: vec */
96
 
        
97
 
        curvemapping_evaluate_premulRGBF(node->storage, out[0]->vec, in[0]->vec);
98
 
}
99
 
 
100
 
static void node_composit_init_curve_vec(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 
67
static bNodeSocketTemplate cmp_node_curve_vec_in[] = {
 
68
        {       SOCK_VECTOR, 1, N_("Vector"),   0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE},
 
69
        {       -1, 0, ""       }
 
70
};
 
71
 
 
72
static bNodeSocketTemplate cmp_node_curve_vec_out[] = {
 
73
        {       SOCK_VECTOR, 0, N_("Vector")},
 
74
        {       -1, 0, ""       }
 
75
};
 
76
 
 
77
static void node_composit_init_curve_vec(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
101
78
{
102
79
        node->storage= curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f);
103
80
}
111
88
        node_type_size(&ntype, 200, 140, 320);
112
89
        node_type_init(&ntype, node_composit_init_curve_vec);
113
90
        node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);
114
 
        node_type_exec(&ntype, node_composit_exec_curve_vec);
115
91
 
116
92
        nodeRegisterType(ttype, &ntype);
117
93
}
118
94
 
119
95
 
120
96
/* **************** CURVE RGB  ******************** */
121
 
static bNodeSocketTemplate cmp_node_curve_rgb_in[]= {
122
 
        {       SOCK_FLOAT, 1, "Fac",   1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_FACTOR},
123
 
        {       SOCK_RGBA, 1, "Image",  1.0f, 1.0f, 1.0f, 1.0f},
124
 
        {       SOCK_RGBA, 1, "Black Level",    0.0f, 0.0f, 0.0f, 1.0f},
125
 
        {       SOCK_RGBA, 1, "White Level",    1.0f, 1.0f, 1.0f, 1.0f},
126
 
        {       -1, 0, ""       }
127
 
};
128
 
 
129
 
static bNodeSocketTemplate cmp_node_curve_rgb_out[]= {
130
 
        {       SOCK_RGBA, 0, "Image"},
131
 
        {       -1, 0, ""       }
132
 
};
133
 
 
134
 
static void do_curves(bNode *node, float *out, float *in)
135
 
{
136
 
        curvemapping_evaluate_premulRGBF(node->storage, out, in);
137
 
        out[3]= in[3];
138
 
}
139
 
 
140
 
static void do_curves_fac(bNode *node, float *out, float *in, float *fac)
141
 
{
142
 
        
143
 
        if (*fac >= 1.0f)
144
 
                curvemapping_evaluate_premulRGBF(node->storage, out, in);
145
 
        else if (*fac <= 0.0f) {
146
 
                copy_v3_v3(out, in);
147
 
        }
148
 
        else {
149
 
                float col[4], mfac= 1.0f-*fac;
150
 
                curvemapping_evaluate_premulRGBF(node->storage, col, in);
151
 
                out[0]= mfac*in[0] + *fac*col[0];
152
 
                out[1]= mfac*in[1] + *fac*col[1];
153
 
                out[2]= mfac*in[2] + *fac*col[2];
154
 
        }
155
 
        out[3]= in[3];
156
 
}
157
 
 
158
 
static void node_composit_exec_curve_rgb(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
159
 
{
160
 
        /* stack order input:  fac, image, black level, white level */
161
 
        /* stack order output: image */
162
 
        
163
 
        if (out[0]->hasoutput==0)
164
 
                return;
165
 
 
166
 
        /* input no image? then only color operation */
167
 
        if (in[1]->data==NULL) {
168
 
                curvemapping_evaluateRGBF(node->storage, out[0]->vec, in[1]->vec);
169
 
        }
170
 
        else {
171
 
                /* make output size of input image */
172
 
                CompBuf *cbuf= in[1]->data;
173
 
                CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */
174
 
                
175
 
                curvemapping_set_black_white(node->storage, in[2]->vec, in[3]->vec);
176
 
                
177
 
                if (in[0]->data==NULL && in[0]->vec[0] == 1.0f)
178
 
                        composit1_pixel_processor(node, stackbuf, in[1]->data, in[1]->vec, do_curves, CB_RGBA);
179
 
                else
180
 
                        composit2_pixel_processor(node, stackbuf, in[1]->data, in[1]->vec, in[0]->data, in[0]->vec, do_curves_fac, CB_RGBA, CB_VAL);
181
 
                
182
 
                out[0]->data= stackbuf;
183
 
        }
184
 
        
185
 
}
186
 
 
187
 
static void node_composit_init_curve_rgb(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 
97
static bNodeSocketTemplate cmp_node_curve_rgb_in[] = {
 
98
        {       SOCK_FLOAT, 1, N_("Fac"),       1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_FACTOR},
 
99
        {       SOCK_RGBA, 1, N_("Image"),      1.0f, 1.0f, 1.0f, 1.0f},
 
100
        {       SOCK_RGBA, 1, N_("Black Level"),        0.0f, 0.0f, 0.0f, 1.0f},
 
101
        {       SOCK_RGBA, 1, N_("White Level"),        1.0f, 1.0f, 1.0f, 1.0f},
 
102
        {       -1, 0, ""       }
 
103
};
 
104
 
 
105
static bNodeSocketTemplate cmp_node_curve_rgb_out[] = {
 
106
        {       SOCK_RGBA, 0, N_("Image")},
 
107
        {       -1, 0, ""       }
 
108
};
 
109
 
 
110
static void node_composit_init_curve_rgb(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
188
111
{
189
112
        node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
190
113
}
198
121
        node_type_size(&ntype, 200, 140, 320);
199
122
        node_type_init(&ntype, node_composit_init_curve_rgb);
200
123
        node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);
201
 
        node_type_exec(&ntype, node_composit_exec_curve_rgb);
202
124
 
203
125
        nodeRegisterType(ttype, &ntype);
204
126
}