-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathVEXpressions.txt
82 lines (69 loc) · 2.48 KB
/
VEXpressions.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Lines starting with # are comments and ignored
#
# Each entry starts with no indentation and gives the key used
# by the menu callback. By convention, this is nodename/parmname.
# Multiple keys can be given for the same entry.
#
# The next line gives the name of the expression. Its indentation
# level is then used for the remainder of the text. All the
# code until the next parameter are appended together to make
# the snippet. All preceeding indentation is removed.
# Note that tabs == 8 is assumed.
attribwrangle/snippet
EDU | Packed to origin
matrix trans = primintrinsic(0, "packedfulltransform", @ptnum);
trans = invert(trans);
matrix3 rot = (matrix3)trans;
v@P *= trans;
setprimintrinsic(0, "transform", @ptnum, rot, "mult");
attribwrangle/snippet
EDU | Packed origin to world
matrix trans = primintrinsic(3, "packedfulltransform", @ptnum);
matrix3 rot = (matrix3)trans;
v@P *= trans;
setprimintrinsic(0, "transform", @ptnum, rot, "mult");
attribwrangle/snippet
EDU | Create rotation matrix
// creates 3x3 identity matrix (X,Y,Z) rotation matrix
3@transform = ident();
// apply 'pscale' scale to our matrix
float pscale = 1;
scale(3@transform, pscale);
// apply 45 degrees rotation along the Y axis to our matrix
float angle_degrees = 45;
vector axis = normalize(set(0, 1, 0));
rotate(3@transform, radians(angle_degrees), axis);
//Apply rotation direction onto our points
//@P *= 3@transform
attribwrangle/snippet
EDU | Turbulence Alligator Noise
vector pos = v@P;
vector frequency = chv("Frequency");//(1,1,1)
vector offset = chv("Offset"); //(0,0,0)
int turbulence = chi("Turbulence"); //5
float rough = chf("Roughness");//0.5
float atten = chf("Attenuation");//1
float amplitude = chf("Amplitude");//1
vector mynoise = anoise((pos*frequency)-offset, turbulence, rough, attend);
mynoise *= amplitude;
v@P += mynoise;
attribwrangle/snippet
EDU | Pixel size pscale
// set pscale to a pixel size
string cam = chs("camera");
float focal = ch(cam+"/focal");
float aperture = ch(cam+"/aperture");
float resx = ch(cam+"/resx");
vector camP = ptransform(cam, v@P);
float z = abs(camP.z);
f@pscale = 0.5 * (aperture/focal) * (z/resx);
attribwrangle/snippet
EDU | Remove Point by Frustum
string cam = chs("cam");
vector ndcP = toNDC(cam, v@P);
float over = chf("overscan");
float far = -ch(cam+"/far");
float near = -ch(cam+"/near");
if( ndcP.x>1+over | ndcP.x<0-over |
ndcP.y>1+over | ndcP.y<0-over |
ndcP.z<far | ndcP.z>near) removepoint(0, @ptnum);