Skip to content

Instantly share code, notes, and snippets.

//Get bounding box values
vector bbox = getbbox_size(0);
vector bbox_max = getbbox_max(0);
vector bbox_min = getbbox_min(0);
vector bbox_center = getbbox_center(0);
//Each of these functions return geometry bounding box values –
//it’s size, maximum and minimum values in each axis and the geometry center point.
//Result is always vector as it is a point in 3d space but you can isolate individual axis easily too:
float xsize = getbbox_size(0).x;
//string concatenation - reference an additional string inside a channel reference (eg: a switch index in a ch reference)
chs("../cam" + chs("../switcher1/camswitch") + "/focus")
@demoan666
demoan666 / Taper
Created January 29, 2021 18:51
Taper
//Taper
if(chi("axis")==0){
@P=set(@P.x,@P.y*chramp("profile",relbbox(@P).x)*ch("mult"),@P.z*chramp("profile",relbbox(@P).x)*ch("mult"));
}
else{
if(chi("axis")==1){
@P=set(@P.x*chramp("profile",relbbox(@P).y)*ch("mult"),@P.y,@P.z*chramp("profile",relbbox(@P).y)*ch("mult"));
}
else{
@P=set(@P.x*chramp("profile",relbbox(@P).z)*ch("mult"),@P.y*chramp("profile",relbbox(@P).z)*ch("mult"),@P.z);
@demoan666
demoan666 / Function convert spherical to cartesian cordinates
Created January 29, 2021 18:50
Function convert spherical to cartesian cordinates
//Function convert spherical to cartesian cordinates
vector sphereToCart(float lat, lon, rad){
float x = -cos(lat) * cos(lon);
float y = sin(lat);
float z = cos(lat)* sin(lon);
return rad * set(x, y, z);
}
v@P = sphereToCart(radians(@lat), radians(@lon), 1.0);
v@N = normalize(@P);
@demoan666
demoan666 / Melt
Created January 29, 2021 18:50
Melt
//Melt
float m= chf("melt");
float rx= chramp("effect",relbbox(@P).y);
float rz= chramp("effect",relbbox(@P).y);
float t= chf("thickness");
@P= set(@P.x*m*rx+@P.x,clamp(@P.y+t*@N.y-m,getbbox_min(0).y+t*@N.y,getbbox_max(0).y),@P.z*m*rz+@P.z);
@demoan666
demoan666 / Dashed Lines on resampled curves
Created January 29, 2021 18:48
Dashed Lines on resampled curves
//Dashed Lines on resampled curves
float u = vertexprimindex(0, @vtxnum) / float(primvertexcount(0, @primnum));
float u_length = u * primintrinsic(0, 'measuredperimeter', @primnum);
float u_anim = (u_length + @Time * chf('speed'));
int waves = sin(u_anim * M_PI * chf('frequency')) < chf('gaps');
v@Cd = hsvtorgb( set(u, 1.0, 1.0) ) * waves;
@width= chf('width');
//Initialize Glue Attributes on Constraints
s@constraint_name = "Glue";
s@constraint_type = "all";
i@propagate_iteration = chi("propagate_iteration");
//These attributes can be used to customize the properties of individual glue bonds.
//f@strength = -1;
//f@impulse_halflife = 0.1;
//f@propagate_rate = 1.0;
//Velocity Curl Noise With Offset
float amp = chf("amp");
float mult = chf("mult");
float speed = chf("speed");
v@N = v@N;
v@v += cross(v@N,(curlnoise(v@N*amp+@Time*speed)))*mult;
//PRIM_Set group based on word attribute on font SOP (Pre Requisite: create "word attribute")
if (@word == chi("select_word_index")){
@group_blue= 1;
}else{
@group_pink=1 ;
}
//DETAIL_Set word attribute on font SOP
//(Pre Requisite:enable "text attribute" on font sop > add a sort SOP based on "text index" attribute )
int id = 0;
int id_old = 0;
int wordcounter = 0;
for(int i=0; i<@numprim; i++)
{
id = prim(0,"textindex",i);