static void do_mix_rgb(bNode *node, float *out, float *in1, float *in2, float *fac) { float col[3]; VECCOPY(col, in1); if(node->custom2) ramp_blend(node->custom1, col, col+1, col+2, in2[3]*fac[0], in2); else ramp_blend(node->custom1, col, col+1, col+2, fac[0], in2); VECCOPY(out, col); out[3]= in1[3]; }
/* Calls multitex and copies the result to the outputs. Called by xxx_exec, which handles inputs. */ static void do_proc(float *result, TexParams *p, const float col1[4], const float col2[4], char is_normal, Tex *tex, const short thread) { TexResult texres; int textype; if (is_normal) { texres.nor = result; } else texres.nor = NULL; textype = multitex_nodes(tex, p->co, p->dxt, p->dyt, p->osatex, &texres, thread, 0, p->shi, p->mtex); if (is_normal) return; if (textype & TEX_RGB) { copy_v4_v4(result, &texres.tr); } else { copy_v4_v4(result, col1); ramp_blend(MA_RAMP_BLEND, result, texres.tin, col2); } }
static PyObject *Freestyle_blendRamp(PyObject *self, PyObject *args) { PyObject *obj1, *obj2; char *s; int type; float a[3], fac, b[3]; if (!PyArg_ParseTuple(args, "sOfO", &s, &obj1, &fac, &obj2)) return NULL; type = ramp_blend_type(s); if (type < 0) { PyErr_SetString(PyExc_TypeError, "argument 1 is an unknown ramp blend type"); return NULL; } if (!float_array_from_PyObject(obj1, a, 3)) { PyErr_SetString(PyExc_TypeError, "argument 2 must be a 3D vector (either a tuple/list of 3 elements or Vector)"); return NULL; } if (!float_array_from_PyObject(obj2, b, 3)) { PyErr_SetString(PyExc_TypeError, "argument 4 must be a 3D vector (either a tuple/list of 3 elements or Vector)"); return NULL; } ramp_blend(type, a, fac, b); return Vector_CreatePyObject(a, 3, Py_NEW, NULL); }
/* shade sky according to sun lamps, all parameters are like shadeSkyView except sunsky*/ void shadeSunView(float col_r[3], const float view[3]) { GroupObject *go; LampRen *lar; float sview[3]; bool do_init = true; for (go=R.lights.first; go; go= go->next) { lar= go->lampren; if (lar->type==LA_SUN && lar->sunsky && (lar->sunsky->effect_type & LA_SUN_EFFECT_SKY)) { float sun_collector[3]; float colorxyz[3]; if (do_init) { normalize_v3_v3(sview, view); mul_m3_v3(R.imat, sview); if (sview[2] < 0.0f) sview[2] = 0.0f; normalize_v3(sview); do_init = false; } GetSkyXYZRadiancef(lar->sunsky, sview, colorxyz); xyz_to_rgb(colorxyz[0], colorxyz[1], colorxyz[2], &sun_collector[0], &sun_collector[1], &sun_collector[2], lar->sunsky->sky_colorspace); ramp_blend(lar->sunsky->skyblendtype, col_r, lar->sunsky->skyblendfac, sun_collector); } } }
static void node_shader_exec_mix_rgb(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { /* stack order in: fac, col1, col2 */ /* stack order out: col */ float col[3]; float fac; float vec[3]; nodestack_get_vec(&fac, SOCK_VALUE, in[0]); CLAMP(fac, 0.0f, 1.0f); nodestack_get_vec(col, SOCK_VECTOR, in[1]); nodestack_get_vec(vec, SOCK_VECTOR, in[2]); ramp_blend(node->custom1, col, col+1, col+2, fac, vec); VECCOPY(out[0]->vec, col); }
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); }
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); } } }