int plugin_tex_doit(int stype, Cast *cast, float *texvec, float *dxt, float *dyt, float *result) { float xwave, ywave; if(stype==1) { texvec[0]+= hnoise(cast->noise, texvec[0], texvec[1], texvec[2]); texvec[1]+= hnoise(cast->noise, texvec[1], texvec[2], texvec[0]); } if(dxt && dyt) { xwave= sample_wave(cast->size, texvec[0], fabs(dxt[0]) + fabs(dyt[0]) ); ywave= sample_wave(cast->size, texvec[1], fabs(dxt[1]) + fabs(dyt[1]) ); if(xwave > ywave) result[0]= xwave-ywave; else result[0]= ywave-xwave; } else { xwave= sample_wave(cast->size, texvec[0], 0.0 ); ywave= sample_wave(cast->size, texvec[1], 0.0 ); if(xwave > ywave) result[0]= xwave-ywave; else result[0]= ywave-xwave; } return TEX_INT; }
int plugin_tex_doit(int stype, Cast *cast, float *texvec, float *dxt, float *dyt, float *result) { float val = 0.0; float a = 1.0; float p[3]; float tv[3]; int i; int res = TEX_INT; tv[0]=(texvec[0]+1.0)/2.0; tv[1]=(texvec[1]+1.0)/2.0; tv[2]=(texvec[2]+1.0)/2.0; p[0] = cast->txtscale * tv[0]; p[1] = cast->txtscale * tv[1]; p[2] = cast->txtscale * tv[2]; for (i=0; i<cast->depth; i++) { val += a * hnoise(1.0, p[0], p[1], p[2]); p[0] *= 2.0; p[1] *= 2.0; p[2] *= 2.0; a *= 0.5; } /* always return this value */ result[0] = CLAMP (val+cast->offset, 0.0, 1.0) * pow (fabs(sqrt(tv[0]*tv[0]+tv[1]*tv[1]+tv[2]*tv[2])), cast->falloff); if(stype==1) { /* * this is r, g, b, a: */ result[1]= 0.5*result[0]; result[2]= 1.0-val; result[3]= fsqrt(fabs(result[0])); result[4]= 1.0; res |= TEX_RGB; } if(stype==2) { /* * This value is the displacement of the actual normal in * the Material calculation. */ result[5]+= val; result[6]+= 1.0-val; result[7]= 0.0; res |= TEX_NOR; } return res; }