Skip to content

Instantly share code, notes, and snippets.

View scale packed prim
float scale = chf('scale');
matrix3 trn = primintrinsic(0, "transform", @primnum);
matrix scalem = maketransform(0, 0, {0,0,0}, {0,0,0}, scale, @P);
trn *= matrix3(scalem);
setprimintrinsic(0, "transform", @primnum, trn);
View aim normals along surface in a direction
vector dir = chv('dir');
float angle = dot(@N, dir);
float fitangle = fit(angle, -1, 1, 0, 1);
float blend = chramp('blend', fitangle);
@Cd = blend;
vector tmp = cross(@N, dir);
vector cross = cross(@N, tmp);
View geo to uv space
@rest = v@P;
int vtx = pointvertex(0, @ptnum);
vector uv = vertex(0, 'uv', vtx);
v@P = lerp(@P, uv, chf('blend'));
View geo displacement by map
vector cd = point(1, 'Cd', @ptnum);
v@P += normalize(v@N) * fit01(cd.r, -0.5, 0.5) * chf('scale');
View pointveltovolume
int pt = nearpoint(1,@P);
v@vel = point(1,'v',pt);
View Pscale on Mesh
//define scales
float seed = ch('seed') + @primseed;
@Rand_Pscale = fit01(rand(i@ptnum+seed+225), -ch('Rand_Scale'), ch('Rand_Scale'));
@Uniform_Pscale = chf('Scale');
//apply pscale
@joshuazt
joshuazt / Attribute Driven Blendshape
Last active Feb 19, 2021
Attribute Driven Blendshape
View Attribute Driven Blendshape
v@P=lerp(v@P, point(1,'P',@ptnum), f@mask*ch('blend'));