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

« back to all changes in this revision

Viewing changes to source/blender/nodes/texture/nodes/node_texture_bricks.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:
35
35
 
36
36
#include <math.h>
37
37
 
38
 
static bNodeSocketTemplate inputs[]= {
39
 
        { SOCK_RGBA,  1, "Bricks 1",    0.596f, 0.282f, 0.0f,  1.0f },
40
 
        { SOCK_RGBA,  1, "Bricks 2",    0.632f, 0.504f, 0.05f, 1.0f },
41
 
        { SOCK_RGBA,  1, "Mortar",      0.0f,   0.0f,   0.0f,  1.0f },
42
 
        { SOCK_FLOAT, 1, "Thickness",   0.02f,  0.0f,   0.0f,  0.0f,  0.0f,    1.0f, PROP_UNSIGNED },
43
 
        { SOCK_FLOAT, 1, "Bias",        0.0f,   0.0f,   0.0f,  0.0f, -1.0f,    1.0f, PROP_NONE },
44
 
        { SOCK_FLOAT, 1, "Brick Width", 0.5f,   0.0f,   0.0f,  0.0f,  0.001f, 99.0f, PROP_UNSIGNED },
45
 
        { SOCK_FLOAT, 1, "Row Height",  0.25f,  0.0f,   0.0f,  0.0f,  0.001f, 99.0f, PROP_UNSIGNED },
 
38
static bNodeSocketTemplate inputs[] = {
 
39
        { SOCK_RGBA,  1, N_("Bricks 1"),    0.596f, 0.282f, 0.0f,  1.0f },
 
40
        { SOCK_RGBA,  1, N_("Bricks 2"),    0.632f, 0.504f, 0.05f, 1.0f },
 
41
        { SOCK_RGBA,  1, N_("Mortar"),      0.0f,   0.0f,   0.0f,  1.0f },
 
42
        { SOCK_FLOAT, 1, N_("Thickness"),   0.02f,  0.0f,   0.0f,  0.0f,  0.0f,    1.0f, PROP_UNSIGNED },
 
43
        { SOCK_FLOAT, 1, N_("Bias"),        0.0f,   0.0f,   0.0f,  0.0f, -1.0f,    1.0f, PROP_NONE },
 
44
        { SOCK_FLOAT, 1, N_("Brick Width"), 0.5f,   0.0f,   0.0f,  0.0f,  0.001f, 99.0f, PROP_UNSIGNED },
 
45
        { SOCK_FLOAT, 1, N_("Row Height"),  0.25f,  0.0f,   0.0f,  0.0f,  0.001f, 99.0f, PROP_UNSIGNED },
46
46
        { -1, 0, "" }
47
47
};
48
 
static bNodeSocketTemplate outputs[]= {
49
 
        { SOCK_RGBA, 0, "Color"},
 
48
static bNodeSocketTemplate outputs[] = {
 
49
        { SOCK_RGBA, 0, N_("Color")},
50
50
        { -1, 0, ""     }
51
51
};
52
52
 
53
 
static void init(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 
53
static void init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
54
54
{
55
55
        node->custom3 = 0.5; /* offset */
56
56
        node->custom4 = 1.0; /* squash */
66
66
 
67
67
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
68
68
{
69
 
        float *co = p->co;
 
69
        const float *co = p->co;
70
70
        
71
71
        float x = co[0];
72
72
        float y = co[1];
102
102
        ins_y = y - row_height*rownum;
103
103
        
104
104
        tint = noise((rownum << 16) + (bricknum & 0xFFFF)) + bias;
105
 
        CLAMP(tint,0.0f,1.0f);
 
105
        CLAMP(tint, 0.0f, 1.0f);
106
106
        
107
 
        if ( ins_x < mortar_thickness || ins_y < mortar_thickness ||
108
 
                ins_x > (brick_width - mortar_thickness) ||
109
 
                ins_y > (row_height - mortar_thickness) ) {
110
 
                copy_v4_v4( out, mortar );
 
107
        if (ins_x < mortar_thickness || ins_y < mortar_thickness ||
 
108
            ins_x > (brick_width - mortar_thickness) ||
 
109
            ins_y > (row_height - mortar_thickness))
 
110
        {
 
111
                copy_v4_v4(out, mortar);
111
112
        }
112
113
        else {
113
 
                copy_v4_v4( out, bricks1 );
114
 
                ramp_blend( MA_RAMP_BLEND, out, tint, bricks2 );
 
114
                copy_v4_v4(out, bricks1);
 
115
                ramp_blend(MA_RAMP_BLEND, out, tint, bricks2);
115
116
        }
116
117
}
117
118