VEX

// C:\Users\ (UserName) \Documents\houdini19.0\houdini.env
EDITOR = "C:\Users\(UserName)\AppData\Local\Programs\Microsoft VS Code\Code.exe"
  • 절대로 point() 또는 prim() 표현식을 사용하지 마십시오(expressions). VEX 대응만 사용하십시오.

  • https://www.tokeru.com/cgwiki/?title=HoudiniVex

  • https://www.sidefx.com/learn/vex/

  • Attribute VOP

    • Vex 시각화 그래프
  • Attribute Wrangle

    • Vex 코딩
    • Wrangle
      • This is a very powerful, low-level node that lets experts who are familiar with VEX tweak attributes using code.
      • https://english.stackexchange.com/questions/263712/what-does-come-on-lets-wrangle-up-the-cattle-mean
      • 소나 말들 관리

@P                     => points
@N                     => normals
@Cd                    => primvars:displayColor
@id                    => ids
@width,@widths,@pscale => widths
@v                     => velocities
@w                     => angularVelocities
@accel                 => accelerations
@uv                    => primvars:st
@Alpha                 => primvars:displayOpacity


v@N; // the normal. If this hasn't been set, vex will calculate it for you just by calling it without initialised values
v@up; // a vector to control the spin around the normal when using instancing/copytopoints/etc
p@orient; // vector4 used as explicit rotation for instances
3@transform; // matrix3 used to control rotation and scale for instances
4@localtransform; // matrix (4x4) used for kinefx joints
f@pscale; // uniform scale for instances
v@scale; // XYZ scale control for instances

v@P; // current elements position. can be set for points, can be read for vertices and prims. Prims will guess the midpoint, not always reliable!
v@Cd; // diffuse colour

type@attribute

  • geometry sheet에서 확인 가능
i@myint         = 5;                                        // i | int

f@myfloat       = 12.234;                                   // f | float
u@myvector2     = {0.6, 0.5};                               // u | float2
v@myvector      = {1,2,3};                                  // v | float3
p@myquat        = {0,0,0,1};                                // p | float4

2@mymatrix2     = {1,2,3,4};                                // 2 | float2x2
3@mymatrix3     = {1,2,3,4,5,6,7,8,9};                      // 3 | float3x3
4@mymatrix4     = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; // 4 | float4x4

s@mystring      = 'a string';                               // s | string

d@mydict        = {};                                       // d | dict
d@mydict['key'] = 'value';

i[]@connected_pts = neighbours(0, @ptnum);                  // i[] | int[] array

// 정의 후 @attribute 형태로 쓸 수 있다.
// { ... } 과 set( ... ) 는 동일.

https://sites.google.com/site/fujitarium/Houdini/sop/copy-sop

// https://www.sidefx.com/docs/houdini/vex/snippets.html
vector x0 = point(0, "P", @ptnum);
vector x1 = point(1, "P", @ptnum);


float dist = distance(x0, x1);
vector dir = normalize(x1 - x0);
vector next = x0 + dir * (dist / 2.0f);

@P = next;

@

@elemnum현재 element@id
@vtxnum현재 vertex (linear)흔히 말하는 버텍스
@ptnum현재 point포인트(중복된 포지션이 없다)
@primnum현재 primitive단일 엔티티(면 or 구 ...)
@numelem총 element 갯수
@numvtx총 vertex 갯수
@numpt총 point 갯수
@numprim총 primitive 갯수
@TimeFloat time ($T)
@FrameFloat frame ($FF) // $F는 int frame
@SimTimeFloat simulation time ($ST), only present in DOP contexts.
@SimFrameFloat simulation frame ($SF), only present in DOP contexts.
@TimeIncFloat time step (1/$FPS)
$VTXvertexprimindex(0, @vtxnum);

geometry attribute

@
GeometryidintA unique element ID
namestring이름
Pvector포지션
Nvector노말
vvector속도 Velocity
pieceint조각
pscalefloatUniform scaling factor
scalevectorWhereas pscale is a single uniform scaling factor in all axes
RenderinguvvectorUV
ShaderCdvectordiffuse 색깔
Csvectorspecular 색깔
Crvectorreflect 색깔
Cevectoremission 색깔
Ctvectortransmit 색깔
AlphafloatAlpha transparency override. The viewport uses this to set the alpha of OpenGL geometry.
roughfloatRoughness override.
fresnelfloatFresnel coefficient override.
shadowfloatShadow intensity override.
sbiasfloatShadow bias override.
Particleorientvector4Quaternion orientation of a particle
upvectorRepresents the up vector of a particle’s local space
rotvector4An additional offset-quaternion applied after all other attributes

https://www.sidefx.com/docs/houdini/copy/instanceattrs.html

ch

파라미터 삭제시: More > Delete Spare Parameter

chf
chi
chv
chramp(channel,ramppos, time)조절 가능한 2차원 그래프 채널이 생긴다

Function

clamp(value, min, max)
fit(value, fromMin, fromMax, toMin, toMax)
point(geometry, attribute_name, pointnumber)geometry는 입력 순서(0부터)
포지션 - minpos(geometry, point)point에서 geometry에 레이를 쐈을시 가장 먼저 닿는 부분의 포지션
포인트 - nearpoint(geometry, pt)geometry에 있는 모든 point 중에서 pt와 가장 가까운 point의 번호
Vector getbbox_size(geometry)Computes the size of the bounding box for the geometry.

getbbox_max

vector currP = @P;

// 현재 위치에서 1번 지오메트리와 맨 처음으로 마주치게될 포지션.
vector hittedP = minpos(1, currP);

// 현재 위치에서 1번 지오메트리에 있는 모든 포인트 중 가장 가까운 포인트번호.
int nearPointNumber = nearpoint(1, currP);

// 1번 지오메트리의 nearpointNumber의 _id값.
int id = point(1, "_id", nearPointNumber);

quaternion

vector4 orient = quaternion(maketransform(@N, @up));
vector euler  = quaterniontoeuler(orient,XFORM_XYZ);
v@rot = degrees(euler);
// maketransform: https://www.sidefx.com/docs/houdini/vex/functions/maketransform.html

vector4  quaternion(matrix3 rotations)
vector4  quaternion(float angle, vector axis)
vector4  quaternion(vector angleaxis)

vector  qrotate(vector4 quaternion, vector v)
vector  degrees(vector nums_in_rads)
vector  quaterniontoeuler(vector4 orient, int order)

vector4  slerp(vector4 q1, vector4 q2, float bias)

vector4  qmultiply(vector4 q1, vector4 q2)
Constant nameRotation Order
XFORM_XYZRotate order X, Y, Z
XFORM_XZYRotate order X, Z, Y
XFORM_YXZRotate order Y, X, Z
XFORM_YZXRotate order Y, Z, X
XFORM_ZXYRotate order Z, X, Y
XFORM_ZYXRotate order Z, Y, X

Etc

point("../OUT_P", 0, "P", 1)  // OUT_P  노드의 0번째의 point P의 Y좌표(xyz / 012)
prim("../OUT_Cd", 2, "Cd", 0) // OUT_Cd 노드의 2번째의 primitive Cd의 Red채널값(rgb / 012)
opdigits(".")                 // 현재 노드(".")의 이름의 숫자만 가져옴
rand(x)                       // 랜덤. 분포가 일정하게 되는데 그럴때 사칙연산을 내부적으로 넣어주기도 함

chramp("radious_ramp", @curveu)    // 기어버튼으로 추가된 radious_ramp curveu의 위치 값을 가져온다
detail("../META/", "iteration", 0) // META에 있는 iteration의 0번째 값



npoints(0) => 0번입력의 포인트 갯수
nprims


addpoint // removepoint
addprim  // removeprim

setpointattrib
setprimattrib

fit
lerp

distance

cross
dot
normalize

getpointbbox_center(input)

float xyzdist(geometry, originVector)

`opinputpath(".", 0)

@opinput‹n›_‹name› @opinput1_P // 입력 1의 P.

v@P = lerp(v@P, @opinput1_P, chf('blend'));

i@id = @ptnum // 현재 point v@P = lerp(v@P, point(1, 'P', findattribval(1, 'point', 'id', i@id)), chf('blend')); v@P = lerp(v@P, point(1, 'P', idtopoint(1, i@id)), chf('blend'));

v@pos = uvsample(0, 'P', 'uv', chv('uv'));

setdetailattrib(0, 'foo', @ptnum, 'set');

normalize cross abs dot length degree min / max sin/cos/acos

relpointbbox(2, pos); addpoint(geoself(), pos);

pointprims => point to prim

primpoints => prim to point primvertices

neighbours

pcfind 범위(radius)에서 포인트를 찾음 nearpoints // pcfind를 편히 쓸 수 있는 버전

// array insert / append removeindex removevalue push / pop resize len argsort reverse reorder find

addprim(int_geohandle, string_type) removeprim addvertex

setpointgroup setprimgroup

sprintf

nearpoint는 포인트만. point cloud에서는 원하는 정보만 가져올 수 있다. https://www.sidefx.com/docs/houdini/vex/functions/pcopen.html pcopen int pcopen(int opinput, string Pchannel, vector P, float radius, int maxpoints)

int pc_handle = pcopen(0, "P", @P, 1, 10);

if (pcnumfound(pc_handle) < 3) { removepoint(0, @ptnum); }

pcclose(pc_handle);

int pts[] = nearpoints(0, @P, 1, 10);

if (len(pts) < 3) { removepoint(0, @ptnum); }

pcimportbyidxf pcfilter pciterate

foreach ([element_type] value; array) {

}

foreach (index, value; array) statement;
foreach (int index; element_type value; array) statement;

int test(int a; int b; string c) { return 1; }

struct SHello { int a = 1; int b;

int Func()
{
  return a;
}

}

SHello x = SHello(1, 2);

// string startswith endswith find match concat join split lstrip / rstrip splitpath isdigit opdigits // Returns the integer value of the last sequence of digits of a string https://www.sidefx.com/docs/houdini/vex/functions/opdigits.html atoi / atof itoa

// regex string regex = r''; i@match = re_match(regex, teststring); re_match re_find re_findall re_replace re_split

https://regex101.com

Random

https://www.sidefx.com/docs/houdini/vex/random.html

NoiseRelative cost
Perlin noise (noise)1.0
Original perlin noise (onoise)1.1
Worley noise (wnoise)1.8
Sparse Convolution noise (snoise)2.1
Alligator noise (anoise)2.3

curlnoise flownoise