/* applies to render pipeline */
static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **UNUSED(out))
{
    TexCallData *cdata = (TexCallData *)data;
    TexResult *target = cdata->target;

    if (cdata->do_preview) {
        TexParams params;
        params_from_cdata(&params, cdata);

        if (in[1] && in[1]->hasinput && !in[0]->hasinput)
            tex_input_rgba(&target->tr, in[1], &params, cdata->thread);
        else
            tex_input_rgba(&target->tr, in[0], &params, cdata->thread);
        tex_do_preview(execdata->preview, params.co, &target->tr);
    }
    else {
        /* 0 means don't care, so just use first */
        if (cdata->which_output == node->custom1 || (cdata->which_output == 0 && node->custom1 == 1)) {
            TexParams params;
            params_from_cdata(&params, cdata);

            tex_input_rgba(&target->tr, in[0], &params, cdata->thread);

            target->tin = (target->tr + target->tg + target->tb) / 3.0f;
            target->talpha = TRUE;

            if (target->nor) {
                if (in[1] && in[1]->hasinput)
                    tex_input_vec(target->nor, in[1], &params, cdata->thread);
                else
                    target->nor = NULL;
            }
        }
    }
}
static void rgbtobw_valuefn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
	float cin[4];
	tex_input_rgba(cin, in[0], p, thread);
	
	*out = cin[0] * 0.35f + cin[1] * 0.45f + cin[2] * 0.2f;
}
static void rgbtobw_valuefn(
    float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
  float cin[4];
  tex_input_rgba(cin, in[0], p, thread);
  *out = IMB_colormanagement_get_luminance(cin);
}
static void rgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
	float cin[4];
	tex_input_rgba(cin, in[0], p, thread);
	
	curvemapping_evaluateRGBF(node->storage, out, cin);
	out[3] = cin[3];
}
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
	float fac  = tex_input_value(in[0], p, thread);
	float col1[4], col2[4];

	tex_input_rgba(col1, in[1], p, thread);
	tex_input_rgba(col2, in[2], p, thread);

	/* use alpha */
	if (node->custom2 & 1)
		fac *= col2[3];

	CLAMP(fac, 0.0f, 1.0f);

	copy_v4_v4(out, col1);
	ramp_blend(node->custom1, out, fac, col2);
}
Exemple #6
0
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
	TexParams np = *p;
	float new_co[3];
	np.co = new_co;
	
	tex_input_vec(new_co, in[1], p, thread);
	tex_input_rgba(out, in[0], &np, thread);
}
Exemple #7
0
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
	float x  = p->co[0];
	float y  = p->co[1];
	float z  = p->co[2];
	float sz = tex_input_value(in[2], p, thread);
	
	/* 0.00001  because of unit sized stuff */
	int xi = (int)fabs(floor(0.00001f + x / sz));
	int yi = (int)fabs(floor(0.00001f + y / sz));
	int zi = (int)fabs(floor(0.00001f + z / sz));
	
	if( (xi % 2 == yi % 2) == (zi % 2) ) {
		tex_input_rgba(out, in[0], p, thread);
	} else {
		tex_input_rgba(out, in[1], p, thread);
	} 
}
static void texfn(
	float *result, 
	TexParams *p,
	bNode *node, 
	bNodeStack **in,
	char is_normal, 
	MapFn map_inputs,
	short thread)
{
	Tex tex = *((Tex*)(node->storage));
	float col1[4], col2[4];
	tex_input_rgba(col1, in[0], p, thread);
	tex_input_rgba(col2, in[1], p, thread);
	
	map_inputs(&tex, in, p, thread);
	
	do_proc(result, p, col1, col2, is_normal, &tex, thread);
}
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(out))
{
	TexCallData *cdata = (TexCallData *)data;

	if (cdata->do_preview) {
		TexParams params;
		float col[4];
		params_from_cdata(&params, cdata);

		tex_input_rgba(col, in[0], &params, cdata->thread);
		tex_do_preview(node, params.previewco, col);
	}
}
Exemple #10
0
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
	float col[4];
	
	tex_input_rgba(col, in[0], p, thread);

	col[0] = 1.0f - col[0];
	col[1] = 1.0f - col[1];
	col[2] = 1.0f - col[2];
	
	VECCOPY(out, col);
	out[3] = col[3];
}
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
	float offset[3], new_co[3];
	TexParams np = *p;
	np.co = new_co;
	
	tex_input_vec(offset, in[1], p, thread);
	
	new_co[0] = p->co[0] + offset[0];
	new_co[1] = p->co[1] + offset[1];
	new_co[2] = p->co[2] + offset[2];
	
	tex_input_rgba(out, in[0], &np, thread);
}
Exemple #12
0
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
	Tex *nodetex = (Tex *)node->id;
	static float red[] = {1,0,0,1};
	static float white[] = {1,1,1,1};
	float co[3], dxt[3], dyt[3];
	
	copy_v3_v3(co, p->co);
	copy_v3_v3(dxt, p->dxt);
	copy_v3_v3(dyt, p->dyt);
	
	if(node->custom2 || node->need_exec==0) {
		/* this node refers to its own texture tree! */
		QUATCOPY(out, (fabs(co[0] - co[1]) < .01) ? white : red );
	}
	else if(nodetex) {
		TexResult texres;
		int textype;
		float nor[] = {0,0,0};
		float col1[4], col2[4];
		
		tex_input_rgba(col1, in[0], p, thread);
		tex_input_rgba(col2, in[1], p, thread);
		
		texres.nor = nor;
		textype = multitex_nodes(nodetex, co, dxt, dyt, p->osatex,
			&texres, thread, 0, p->shi, p->mtex);
		
		if(textype & TEX_RGB) {
			QUATCOPY(out, &texres.tr);
		}
		else {
			QUATCOPY(out, col1);
			ramp_blend(MA_RAMP_BLEND, out, out+1, out+2, texres.tin, col2);
		}
	}
}
Exemple #13
0
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{	
	float hue = tex_input_value(in[0], p, thread);
	float sat = tex_input_value(in[1], p, thread);
	float val = tex_input_value(in[2], p, thread);
	float fac = tex_input_value(in[3], p, thread);
	
	float col[4];
	tex_input_rgba(col, in[4], p, thread);
	
	hue += 0.5f; /* [-.5, .5] -> [0, 1] */
	
	do_hue_sat_fac(node, out, hue, sat, val, col, fac);
	
	out[3] = col[3];
}
Exemple #14
0
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
	float scale[3], new_co[3], new_dxt[3], new_dyt[3];
	TexParams np = *p;

	np.co = new_co;
	np.dxt = new_dxt;
	np.dyt = new_dyt;
	
	tex_input_vec(scale, in[1], p, thread);

	mul_v3_v3v3(new_co, p->co, scale);
	if (p->osatex) {
		mul_v3_v3v3(new_dxt, p->dxt, scale);
		mul_v3_v3v3(new_dyt, p->dyt, scale);
	}
	
	tex_input_rgba(out, in[0], &np, thread);
}
Exemple #15
0
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
	float new_co[3], new_dxt[3], new_dyt[3], a, ax[3];
	
	a= tex_input_value(in[1], p, thread);
	tex_input_vec(ax, in[2], p, thread);

	rotate(new_co, a, ax, p->co);
	if (p->osatex) {
		rotate(new_dxt, a, ax, p->dxt);
		rotate(new_dyt, a, ax, p->dyt);
	}
	
	{
		TexParams np = *p;
		np.co = new_co;
		np.dxt = new_dxt;
		np.dyt = new_dyt;
		tex_input_rgba(out, in[0], &np, thread);
	}
}
Exemple #16
0
static void valuefn_a(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
	tex_input_rgba(out, in[0], p, thread);
	*out = out[3];
}
Exemple #17
0
static void rgbtobw_valuefn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
	float cin[4];
	tex_input_rgba(cin, in[0], p, thread);
	*out = rgb_to_bw(cin);
}