'Houdini/VEX functions'에 해당되는 글 3건

  1. 2013.01.18 VEX Functions Definition
  2. 2012.12.13 VEX shading functions
  3. 2012.11.18 VEX functions

함수의 정의를 보면 그 함수가 정확히 어떤 기능을 하는지 알 수 있다. 

그래서 지금부터 하나씩 하나씩 써 내려가야겠다.




Displace Along Normal





Color Mix





'Houdini > VEX functions' 카테고리의 다른 글

VEX shading functions  (0) 2012.12.13
VEX functions  (0) 2012.11.18
Posted by scii
:

Sign VEX node

이 함수는 vop과 shop... 그러니까 후디니 내에서만 존재한다.
vex에서는 없다. 

sign 함수 설명:

인자로 양수가 전달 될 경우, 1 을 반환한다.
인자로 음수가 전달 될 경우, -1 을 반환한다.
인자로 0 이 전달 될 경우, 0을 반환한다.

즉, 이렇게 되어있다는 뜻이다.

if(arg > 0)
return 1;

else if(arg < 0)
return -1;

else
return 0;

정리하면, sign 함수는 인자로 들어오는 값의 sign이 무엇인지만을 전달해주는 함수이다. 




smooth VEX function

float smooth(float value1, float value2, float amount)
float smooth(float value1, float value2, float amount, float rolloff)

smoothstep(min,max,x) : x가 [min, max] 사이의 값인 경우에 대해서 [0, 1] 사이에서 부드럽게 변하는 
    Hermite 보간법을 리턴한다. x가 min보다 작다면 0을 리턴하고, max보다 크다면 1을 리턴한다.

step(x,y) : x≤y 이면 1을 리턴하고, 그렇지 않으면 0을 리턴한다.



lerp VEX function

float lerp(float value1, float value2, float amount)
vector lerp(vector value1, vector value2, float amount)
vector4 lerp(vector4 value1, vector4 value2, float amont)

value1, value2 사이의 값을 interpolation 한다. 만약 amount가 0, 1의 범위를 벗어난 경우, 결과는 선형으로 나온다.

vopsop의 mix 노드랑 똑같음.

lerp(x,y,s) : 선형보간인 x + s(y - x) 를 리턴한다. x, y, s는 모두 동일한 타입으로 지정.



diffuse VEX function

Returns the diffuse (Lambertian) illumination given the normalized surface normal.

    1.     vector diffuse(vector nml)

    1.     vector diffuse(vector nml, vector V, float roughness)

    1.     bsdf diffuse()

    1.     bsdf diffuse(vector nml)

See writing a PBR shader for information on BSDFs.

Returns the diffuse (Lambertian) illumination given the normalized surface normal.

The diffuse(vector nml, V; float roughness, ...) form uses the Oren-Nayar lighting model to compute the diffuse illumination for the surface. The Oren-Nayar lighting model is a more sophisticated lighting model than Lambertian lighting. The V vector represents a vector from the surface to the eye (i.e. -normalize(I)). With a roughness of 0, the Oren-Nayar lighting model is equivalent to the Lambertian model. As roughness increases toward 1, the illumination changes to mimic rougher materials (like clay). The Oren-Nayar form of diffuse() is more expensive than Lambertian diffuse lighting. 




ambient VEX function

Returns the color of ambient light in the scene.

    1. vector ambient()

Returns the color of ambient light in the scene.

You can optionally specify a light mask




specular VEX function

phong, blinn, and specular return the illumination for specular highlights using different lighting models.

    1. vector specular(vector nml, vector V, float roughness)

    1. bsdf specular(vector dir)

See phong for information on the basic lighting models. See writing a PBR shader for information on BSDFs.

You can optionally specify a light mask



Returns the vector representing the reflection of the direction against the normal.

    1. vector reflect(vector direction, vector normal)

Returns the vector representing the reflection of the direction against the normal.



Returns the refraction ray given an incoming direction, the normalized normal and an index of refraction.

    1. vector refract(vector direction, vector normal, float index)

Returns the refraction ray given an incoming direction, the normalized normal and an index of refraction.

The index is a relative index of refraction, the ratio between the interior and exterior index of refraction, where the exterior is defined by the direction of the normals (normals point away from the interior).

In the case of total internal reflection, this function returns the reflection vector.

For example:

refract(normalize(I), normalize(N), outside_to_inside_ior)






frontface VEX function

If dot(I, Nref) is less than zero, N will be negated.

    1. vector frontface(vector N, vector I)

      This form (which doesn’t take a reference vector) is only available in the shading contexts, where the Ng variable is used.

    1. vector frontface(vector N, vector I, vector Nref)


'Houdini > VEX functions' 카테고리의 다른 글

VEX Functions Definition  (0) 2013.01.18
VEX functions  (0) 2012.11.18
Posted by scii
:

VEX functions

Houdini/VEX functions 2012. 11. 18. 17:20 |


set VEX function

vector set(float, float, float)

vector4 set(float, float, float, float)


set() 함수는 float 타입의 자료를 3개 받아 vector로 반환해주는 함수이다.

하나의 벡터 컴포넌트를 바꿔주고 그것을 vector로 반환

※ vop의 Set Vector Component 노드와 같다.




getbbox VEX function

void getbbox(vector min&, vector max&)


getbbox() 함수는 매개변수로 들어오는 2개의 vector 타입의 인자를 참조형으로 받아서 getbbox 안에서 해당 지오메트리의 min, max를 구해준다.

※ vop의 Bounding Box와 같다.




getneighbour VEX function




getneighbours VEX function

int[] getneighbours(int ptnum, input)

Returns an array of the point numbers of the neighbours of a point.





getneighbourcount VEX function




addattribute VEX function

1. void addattribute(string name, int value)

2. void addattribute(string name, float value)

3. void addattribute(string name, vector value)

4. void addattribute(string name, vector4 value)

5. void addattribute(string name, matrix value)

6. void addattribute(string name, matrix3 value)

7. void addattribute(string name, string value)

8. void addattribute(string name, float values[]; int capacity, ...)


-> 인수에 type을 정의할 수도 있다. 

vector(3 floats), normal(3 floats), point(3 floats), quaternion(4 floats), indexpair


float f[] = array(1,2,3,4,5,6,7,8);

addattribute("a1", arraylength(f));

=> 이렇게 하면, 포인트의 a1 속성에는 8이라는 배열길이가 들어간다.


/* addattribute는 각각의 포인트마다 값들이 들어간다. */

sop
create_attribs()
{
  float   f[] = array(1,2,3,4,5,6,7,8);

  // Add an attribute called "a1" with length 8
  addattribute("a1", f, arraylength(f));

=> 배열의 길이만큼 들어간다. 즉, 포인트마다 a1[0]~a1[7]이 생기고 1~8의 숫자가 들어간다. 0포인트에는 1, 1포인트에는 2, ... 이런식으로 들어간다.

// Force the attribute size to be 3 addattribute("a2", f, 3);

=> 배열의 3번째 요소까지만 포인트에 a2라는 속성이 생기며 들어간다. 1, 2, 3

// Set the "vector" qualifier so the attribute is transformed // differently. addattribute("a3", f, 3, "type", "vector");

=> "type", "vector"로 인하여 속성이 다르게 변한다. 즉, a3라는 속성이 생기는데 a3[x], a3[y], a3[z] 이렇게 생기고 배열의 첫번째부터 세번째까지의 값이 차례대로 들어간다. a3[x] = 1, a3[y] = 2, ...

주의할 점은, 길이가 꼭 3이어야만 한다는 점이다. 2나 4나 이런숫자가 들어가면 vector의 속성이 생기지 않는다.

// Set the "index-pair" qualifier (array length must be even) addattribute("a4", f, 8, "type", "indexpair");

=> a4 regn[0], a4 w[0.0], a4 regn[1], a4 w[1.0], ... 이런식으로 속성이 생기는데.. 이걸 어떨때 써야하는지 감이 잘 안온다.

"type", "indexpair" 는 배열의 길이는 되어야 한다고 써있는데.. 그 이유는 잘..

// Add some random values in a 2-tuple f = array( float(nrandom()), float(random(ptnum)) ); addattribute("rnd", f, arraylength(f));

=> f는 길이가 2인 배열로 바뀌면서 rnd[0]에는 nrandom()으로 생성된 랜덤값이, rnd[1]에는 random(ptnum)으로 생성된 랜덤값이 들어간다.

}


Adds a new point attribute (or Writes to an existing attribute)

파티클이나 포인트에 VEX를 이용해서 새로운 attribute를 부여하고자 할 경우나 Output에 없는 attribute의 경우에 이 노드를 이용해서 Output 시킬 수 있다.

addattribute 함수나 vop 노드는 따로 output variables에 연결되지 않고 자체적으로 끝마친다. 왜냐면, 그 애트리뷰트에 넣어주는 것이므로.

※ vop의 Add Attribute와 같다. 또한 sop의 Create Attribute와 비슷하다.




import VEX function

int import(string attrib_name, type result&; int input)
int import(string attrib_name, type result&; int input; int pt_num)
int import(string attrib_name, float values[] &; int input; int pt_num)


This from lets you import attributes containing arbitrary length arrays of floats, such as capture data.

Import attribute data from the SOP or POP connected to the specified input. Returns 1 and puts the data in result on success, or returns 0 on failure.


Possible reasons for failure are:

  • No input is connected to the specified index.

  • The attribute doesn’t exist on the input geometry.

  • The attribute size/type doesn’t match the VEX type.

  • The input geometry has fewer points than the VEX SOPs geometry.

  • The point number given is larger than the number of points in the input.

There are two forms of the import() function. The first form will import the attribute data from the current point that the VEX function is working on. The second form allows you to specify an arbitrary point number of the input. Point numbers are indexed from 0. 


sop에서 UV Texture node를 이용하여 만든 UV값을 vop에서 불러오고자 할 때, Global Variables에 없는 Attribute를 불러올 때 유용하게 사용이 가능하다.

OP Input Index를 이용하면 vop의 다른 Input에 연결된 node의 Attribute도 불러올 수 있다.

그리고, 첫번째 output인 Integer 값은, 잘 갖고오면(성공하면) 1을 반환하고 그렇지 않으면 0을 반환하기 때문에 그것을 이용하여 'Two Way Switch node' 와 같이 사용할 수 있다.




resize VEX function

void resize(arraytype &array; int size)

If you enlarge the array, intermediate values may be uninitialized (return 0 or "").




array VEX function

arraytype array(...)


효율적으로 배열의 인수를 만든다.

만약, vector v1[] = array(1, 2, {1,2,3}, 4, 5, 6, 7, 8); 이런식으로 문장이 구성되면, 아래의 그림과 같이 v1배열이 구성된다.

저 수식에서 array를 빼면 2번째 인덱스에 들어가는 {1,2,3} 때문에 에러가 난다. 즉, 이런식으로 효율적으로 배열의 요소들을 구성하려면 array()함수를 써야만 한다.


그리고, 

vector v[] = vector(array( 1, {1,2,3}, 3, s, t, Cl, P, N)); float f[] = float(array(1, 2, s, t, length(P-L), length(N)));

올바른 배열의 구성을 가지려면 함수스타일형 변환을 하라고하는데... 이렇게하면 에러가 난다. 왜 그러지..




nrandom VEX function

1. float nrandom()
2. vector nrandom()
3. vector4 nrandom()
4. float nrandom(float)

이 함수는 랜덤을 발생시키는 함수인데.. 랜덤을 발생하고 그 다음 랜덤을 또 발생시키면 7번 포인트가 가졌던 랜덤 값을 6번포인트가 갖고 6번 포인트가 갖고 있던 랜덤 값을 5번 포인트가 갖도로 해준다. 즉, 랜덤 값이 모든 포인트마다 새롭게 생기는 것이 아니라 하나씩 번갈아가며 랜덤 값을 갖는다.



rotate VEX function

1. void rotate(matrix &, float amount(radians), vector axis)
2. void rotate(matrix3 &, float amount(radians), vector axis)

이 함수는 주어진 매트릭스에 회전을 적용한다. 
그리고 각도는 radians로 해주어야 하며, 축은 정규화를 해주어야 한다.

그리고 첫번째 인수로 matrix 자료형을 받는데, 참조형으로 받아서 반환형이 void이다. 내부에서 matrix 값을 변환하는가보다.




Set Vector Component VEX node


Assigns a value to one of the vector's components.
This operator assigns a value to one of the vector's components.

vector의 한가지 요소를 할당한다. 
그리고 vex에서 어떻게 쓰이는지 예제가 없는것은 vex에서 기본적으로 되어있다는 뜻이다. 
즉, 이 vex node 같은 경우에는 vex에서 P.x = v.x로 할당할 수 있다.



dihedral VEX function

matrix3 dihedral(vector a, vector b)


computes the rotation matrix which rotates the vector 'a' onto the vector 'b'

vop sop의 노드로는 Align 노드가 있다.



qconvert VEX function

matrix3 qconvert(vector4 quaternion)

Converts a quaternion represented by a vector4 to a matrix3 representation.

쿼터니언을 matrix3로 변환해서 반환해준다.
vop의 노드로는 Quaternion To Matrix3 노드가 있다.



Make Transformer VEX node


Builds a general 4×4 transform matrix given an order of transformations (trs), an o...

This operator builds a general 4×4 transform matrix given an order of transformations (trs), an order for rotations (xyz), vectors representing the translation (t), rotation (r) and scale (s) amounts, and optionally a pivot. 


Transform Matrix VEX node


Transforms an input position, normal, or vector by a matrix specified by the translate, rotate, and scale parameters. 


Make Transformer 노드와 Transform Matrix 노드는 비슷하다. 단지, output이 매트릭스냐 벡터냐의 차이 뿐!




'Houdini > VEX functions' 카테고리의 다른 글

VEX Functions Definition  (0) 2013.01.18
VEX shading functions  (0) 2012.12.13
Posted by scii
: