Skip to content

Instantly share code, notes, and snippets.

@yone80
Last active October 15, 2015 10:32
Show Gist options
  • Save yone80/4abafbf380f31b63e574 to your computer and use it in GitHub Desktop.
Save yone80/4abafbf380f31b63e574 to your computer and use it in GitHub Desktop.
VEXpression
/* Input1 is 'Geometry to Transfer Attribute to' */
/* Input2 is 'Geometry to Transfer Attribute from' */
string attrib_name = 'attrib_name';
float search_lim = 0.5;
float accum = point(0, attrib_name, @ptnum);
for(int i=0; i<nprimitives(1); i++)
{
vector bbxmin, bbxmax;
getbbox(1, itoa(i), bbxmin, bbxmax);
bbxmin = bbxmin - search_lim*1.5;
bbxmax = bbxmax + search_lim*1.5;
int inbounds = (bbxmin.x<@P.x) && (bbxmin.y<@P.y) && (bbxmin.z<@P.z)
&& (bbxmax.x>@P.x) && (bbxmax.y>@P.y) && (bbxmax.z>@P.z);
if(inbounds)
{
int temp_prim;
vector temp_uv;
float f = xyzdist(@OpInput2, itoa(i), @P, temp_prim, temp_uv, search_lim);
f = fit(f, 0.0, search_lim, 1.0, 0.0);
float v = primuv(@OpInput2, attrib_name, temp_prim, temp_uv);
v *= smooth(0.0, 1.0, f);
accum = max(accum, v);
}
}
setpointattrib(0, attrib_name, @ptnum, accum);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment