static void normalfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) { float new_co[3]; const float *co = p->co; float nabla = tex_input_value(in[1], p, thread); float val; float nor[3]; TexParams np = *p; np.co = new_co; val = tex_input_value(in[0], p, thread); new_co[0] = co[0] + nabla; new_co[1] = co[1]; new_co[2] = co[2]; nor[0] = tex_input_value(in[0], &np, thread); new_co[0] = co[0]; new_co[1] = co[1] + nabla; nor[1] = tex_input_value(in[0], &np, thread); new_co[1] = co[1]; new_co[2] = co[2] + nabla; nor[2] = tex_input_value(in[0], &np, thread); out[0] = val-nor[0]; out[1] = val-nor[1]; out[2] = val-nor[2]; }
static void musgrave_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { tex->mg_H = tex_input_value(in[I+0], p, thread); tex->mg_lacunarity = tex_input_value(in[I+1], p, thread); tex->mg_octaves = tex_input_value(in[I+2], p, thread); tex->ns_outscale = tex_input_value(in[I+3], p, thread); tex->noisesize = tex_input_value(in[I+4], p, thread); }
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]; }
static void valtorgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { if(node->storage) { float fac = tex_input_value(in[0], p, thread); do_colorband(node->storage, fac, out); } }
static void voronoi_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { tex->vn_w1 = tex_input_value(in[I+0], p, thread); tex->vn_w2 = tex_input_value(in[I+1], p, thread); tex->vn_w3 = tex_input_value(in[I+2], p, thread); tex->vn_w4 = tex_input_value(in[I+3], p, thread); tex->ns_outscale = tex_input_value(in[I+4], p, thread); tex->noisesize = tex_input_value(in[I+5], p, thread); }
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 *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 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); } }
static void stucci_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { tex->noisesize = tex_input_value(in[I+0], p, thread); tex->turbul = tex_input_value(in[I+1], p, thread); }
static void distnoise_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { tex->noisesize = tex_input_value(in[I+0], p, thread); tex->dist_amount = tex_input_value(in[I+1], p, thread); }
static void clouds_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { tex->noisesize = tex_input_value(in[I+0], p, thread); }
static void magic_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { tex->turbul = tex_input_value(in[I+0], p, thread); }
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) { int i; for (i = 0; i < 4; i++) out[i] = tex_input_value(in[i], p, thread); }
static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { float in0 = tex_input_value(in[0], p, thread); float in1 = tex_input_value(in[1], p, thread); switch (node->custom1) { case 0: /* Add */ *out = in0 + in1; break; case 1: /* Subtract */ *out = in0 - in1; break; case 2: /* Multiply */ *out = in0 * in1; break; case 3: /* Divide */ { if (in1 == 0) /* We don't want to divide by zero. */ *out = 0.0; else *out = in0 / in1; break; } case 4: /* Sine */ { *out = sin(in0); break; } case 5: /* Cosine */ { *out = cos(in0); break; } case 6: /* Tangent */ { *out = tan(in0); break; } case 7: /* Arc-Sine */ { /* Can't do the impossible... */ if (in0 <= 1 && in0 >= -1) *out = asin(in0); else *out = 0.0; break; } case 8: /* Arc-Cosine */ { /* Can't do the impossible... */ if (in0 <= 1 && in0 >= -1) *out = acos(in0); else *out = 0.0; break; } case 9: /* Arc-Tangent */ { *out = atan(in0); break; } case 10: /* Power */ { /* Only raise negative numbers by full integers */ if (in0 >= 0) { out[0] = pow(in0, in1); } else { float y_mod_1 = fmod(in1, 1); if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) { *out = pow(in0, floor(in1 + 0.5f)); } else { *out = 0.0; } } break; } case 11: /* Logarithm */ { /* Don't want any imaginary numbers... */ if (in0 > 0 && in1 > 0) *out = log(in0) / log(in1); else *out = 0.0; break; } case 12: /* Minimum */ { if (in0 < in1) *out = in0; else *out = in1; break; } case 13: /* Maximum */ { if (in0 > in1) *out = in0; else *out = in1; break; } case 14: /* Round */ { *out = (in0 < 0) ? (int)(in0 - 0.5f) : (int)(in0 + 0.5f); break; } case 15: /* Less Than */ { if (in0 < in1) *out = 1.0f; else *out = 0.0f; break; } case 16: /* Greater Than */ { if (in0 > in1) *out = 1.0f; else *out = 0.0f; break; } case 17: /* Modulo */ { if (in1 == 0.0f) *out = 0.0f; else *out = fmod(in0, in1); break; } default: { fprintf(stderr, "%s:%d: unhandeld value in switch statement: %d\n", __FILE__, __LINE__, node->custom1); } } }