VEX —— Noise and Randomness

目录

Noise generators

noise

pnoise

onoise

snoise

anoise

xnoise

wnoise

vnoise

curlnoise

flownoise

Random number generators

random

nrandom

rand

hscript_rand


Noise generators

  • 噪波生成函数,noise、wnoise、vnoise、onoise、snoise、anoise;
  • 每一个函数表示生成噪波的不同算法;

每个噪波相对成本:

  • Perlin noise(noise),1;
  • Original perlin noise(onoise),1.1;
  • worley noise(wnoise),1.8;
  • Sparse Convolution noise(snoise),2.1;
  • Alligator noise(anoise),2.3;

noise

  • 有两种Perlin噪波,此为非周期噪波,周期噪波是pnoise;
  • 取值范围0~1,中位值为0.5;发布取决于维度,更高的维度接近高斯发布;

相当于:

  • VOP内 Turbulent Noise Perlin Noise
  • VOP内 Periodic Noise Perlin Noise
//基于1D位置
float noise(float pos)
vector noise(float pos)
//基于2D位置
float noise(float posx, float posy)
vector noise(float posx, float posy)
//基于3D位置
float noise(vector pos)
vector noise(vector pos)
//基于4D位置
float noise(vector4 pos)
vector noise(vector4 pos)

VEX —— Noise and Randomness_第1张图片

pnoise

  • 有两种Perlin噪波,此为周期噪波,非周期噪波是noise;
  • 发布取决于维度,更高的维度接近高斯发布;

相当于:

  • VOP内 Turbulent Noise Perlin Noise
  • VOP内 Periodic Noise Perlin Noise
float|vector pnoise(float x, int px)
float|vector pnoise(vector x, vector p)
float|vector pnoise(vector4 xyzt, vector4 p)
float|vector pnoise(float x, float y, int px, int py)
float|vector pnoise(vector xyz, int px, int py, int pz)
float|vector pnoise(vector4 xyzt, int px, int py, int pz, int pt)

VEX —— Noise and Randomness_第2张图片

onoise

  • 类似wnoise、vnoise(效率略低,特征不同);
  • 取值范围-1~1,仅支持3D noise;

相当于:VOP内 Turbulent Noise Original Perlin Noise

float  onoise(vector pos)
vector  onoise(vector pos)

float  onoise(vector pos, int turbulence, float rough, float atten)
vector  onoise(vector pos, int turbulence, float rough, float atten)

float  onoise(vector pos, int periodX, int periodY, int periodZ)
vector  onoise(vector pos, int periodX, int periodY, int periodZ)

float  onoise(vector pos, int periodX, int periodY, int periodZ, int turbulence, float rough, float atten)
vector  onoise(vector pos, int periodX, int periodY, int periodZ, int turbulence, float rough, float atten)

VEX —— Noise and Randomness_第3张图片

VEX —— Noise and Randomness_第4张图片

snoise

  • 类似于wnoise,基于所有最近点的权重;
  • 取值范围-1.7~1.7,仅支持3D noise;

相当于:VOP内 Turbulent Noise Sparse Convolution Noise

float snoise(vector pos)
vector snoise(vector pos)

float snoise(vector pos, int turbulence, float rough, float atten)
vector snoise(vector pos, int turbulence, float rough, float atten)

float snoise(vector pos, int periodX, int periodY, int periodZ)
vector snoise(vector pos, int periodX, int periodY, int periodZ)

float snoise(vector pos, int periodX, int periodY, int periodZ, int turbulence, float rough, float atten)
vector snoise(vector pos, int periodX, int periodY, int periodZ, int turbulence, float rough, float atten)

VEX —— Noise and Randomness_第5张图片

VEX —— Noise and Randomness_第6张图片

anoise

  • 生成“alligator” 噪波(cellular noise类型),类型wnoise;
  • 当前无法使用worley函数模拟“alligator” 噪波,但可获得类似外观;
  • 取值范围0~1,仅支持3D noise;

相当于:VOP内 Turbulent Noise Alligator Noise

float anoise(vector pos)
vector anoise(vector pos)

float anoise(vector pos, int turbulence, float rough, float atten)
vector anoise(vector pos, int turbulence, float rough, float atten)

float anoise(vector pos, int periodX, int periodY, int periodZ)
vector anoise(vector pos, int periodX, int periodY, int periodZ)

float anoise(vector pos, int periodX, int periodY, int periodZ, int turbulence, float rough, float atten)
vector anoise(vector pos, int periodX, int periodY, int periodZ, int turbulence, float rough, float atten)

VEX —— Noise and Randomness_第7张图片

VEX —— Noise and Randomness_第8张图片

xnoise

  • 非常接近Perlin noise;
  • 取值范围0~1,中位值为0.5;发布取决于维度,更高的维度接近高斯发布;

相当于:

  • VOP内 Turbulent Noise Simplex Noise
  • VOP内 Periodic Noise Simplex
float xnoise(float x)
vector xnoise(float x)

float xnoise(float x, float y)
vector xnoise(float x, float y)

float xnoise(vector xyz)
vector xnoise(vector xyz)

float xnoise(vector4 xyzt)
vector xnoise(vector4 xyzt)

VEX —— Noise and Randomness_第9张图片

wnoise

  • 生成Worley(蜂窝)噪波;

相当于:

  • VOP内 Worley Noise
//生成1D noise
void wnoise(float position, int &seed, float &f1, float &f2)
void wnoise(float position, int &seed, float &f1, float &f2, float &f3, float &f4)
//生成周期1D noise
void wnoise(float position, int &seed, float &f1, float &f2, int peiod)
void wnoise(float position, int &seed, float &f1, float &f2, float &f4, float &f4, int period)
//生成2D noise
void wnoise(float posx, float posy, int &seed, float &f1, float &f2)
void wnoise(float posx, float posy, int &seed, float &f1, float &f2, float &f3, float &f4)
//生成周期2D noise
void wnoise(float posx, float posy, int &seed, float &f1, float &f2, int periodx, int periody)
void wnoise(float posx, float posy, int &seed, float &f1, float &f2, float &f3, float &f4, int periodx, int periody)
//生成2D noise
void wnoise(vector2 position, int &seed, float &f1, float &f2)
void wnoise(vector2 position, int &seed, float &f1, float &f2, float &f3, float &f4)
//生成周期2D noise
void wnoise(vector2 position, int &seed, float &f1, float &f2, int periodx, int periody)
void wnoise(vector2 position, int &seed, float &f1, float &f2, float &f3, float &f4, int periodx, int periody)
//生成3D noise
void wnoise(vector position, int &seed, float &f1, float &f2)
void wnoise(vector position, int &seed, float &f1, float &f2, float &f3, float &f4)
//生成周期3D noise
void wnoise(vector position, int &seed, float &f1, float &f2, int periodx, int periody, int periodx)
void wnoise(vector position, int &seed, float &f1, float &f2, float &f3, float &f4, int periodx, int periody, int periodz)
//生成4D noise
void wnoise(vector4 position, int &seed, float &f1, float &f2)
void wnoise(vector4 position, int &seed, float &f1, float &f2, float &f3, float &f4)
//生成周期4D noise
void wnoise(vector4 position, int &seed, float &f1, float &f2, int periodx, int periody, int periodz, int periodw)
void wnoise(vector4 position, int &seed, float &f1, float &f2, float &f3, float &f4, int periodx, int periody, int periodz, int periodw)

VEX —— Noise and Randomness_第10张图片

vnoise

  • 生成Voronoi(蜂窝)噪波;
  • 此函数与wnoise结果相近,但比wnosie稍贵;由于返回真实的点位置,可克服wnoise的一些伪影;

相当于:

  • VOP内 Voronoi Noise
//生成1D noise
void vnoise(float position, float jitter, int &seed, float &f1, float &f2, float &pos1, float &pos2)
//生成周期1D noise
void vnoise(float position, float jitter, int &seed, float &f1, float &f2, float &pos1, float &pos2, int period)
//生成2D noise
void vnoise(float posx, float posy, float jittx, float jitty, int &seed, float &f1, float &f2, float &pos1x, float &pos1y, float &pos2x, float &pos2y)
//生成周期2D noise
void vnoise(float posx, float posy, float jittx, float jitty, int &seed, float &f1, float &f2, float &pos1x, float &pos1y, float &pos2x, float &pos2, int periodx, int periody)
//生成3D noise
void vnoise(vector position, vector jitter, int &seed, float &f1, float &f2, vector &pos1, vector &pos2)
//生成周期3D noise
void vnoise(vector position, vector jitter, int &seed, float &f1, float &f2, vector &pos1, vector &pos2, int periodx, int periody, int periodz)
void vnoise(vector position, vector jitter, int &seed, float &f1, float &f2, vector &pos1, vector &pos2, vector period)
//生成4D noise
void vnoise(vector4 position, vector4 jitter, int &seed, float &f1, float &f2, vector4 &pos1, vector4 &pos2)
//生成周期4D noise
void vnoise(vector4 position, vector4 jitter, int &seed, float &f1, float &f2, vector4 &pos1, vector4 &pos2, int periodx, int periody, int periodz, int periodw)
void vnoise(vector4 position, vector4 jitter, int &seed, float &f1, float &f2, vector4 &pos1, vector4 &pos2, vector4 period)

VEX —— Noise and Randomness_第11张图片

curlnoise

vector curlnoise(vector xyz)
vector curlnoise(vector4 xyzt)

flownoise

  • 取值范围0~1,中位值为0.5;发布取决于维度,更高的维度接近高斯发布;

相当于:

  • VOP内 Flow Noise
float flownoise(vector xyz, float flow)
vector flownoise(vector xyz, float flow)

float flownoise(vector4 xyzt, float flow)
vector flownoise(vector4 xyzt, float flow)

float flownoise(float x, float y, float flow)
vector flownoise(float x, float y, float flow)

Random number generators

random

  • random基于空间内的位置(1~4维度)生成一个随机数字;
  • random不像noise会平滑的插值;
  • random()是非常有效的方法,类似noise(floor(position))
//基于1D位置,生成对应噪波
float random(float|int position)
vector random(float|int position)
vector2 random(int position)
vector4 random(float|int position)
//基于2D位置,生成对应噪波
float random(float|int xpos, float|int ypos)
vector random(float|int xpos, float|int ypos)
vector4 random(float|int xpos, float|int ypos)
//基于3D位置,生成对应噪波
float random(vector position)
vector random(vector position)
vector4 random(vector position)
//基于4D位置,生成对应噪波
float random(vector4 position)
vector random(vector4 position)
vector4 random(vector4 position)

VEX —— Noise and Randomness_第12张图片

nrandom

  • nrandom是一个非确定的随机函数;生成的数值在0~1之间;
  • 如按相同顺序调用,将生成相同的随机数序列;
  • 由于没有种子,不可能重复多次生成相同的随机数或序列;
float  nrandom(...)
vector2  nrandom(...)
vector  nrandom(...)
vector4  nrandom(...)
//修改给定变量值,随机值0~1
void nrandom(float &x, float &y, ...)

VEX —— Noise and Randomness_第13张图片

rand

  • 根据seed,生成在 [0, 1) 的随机值;
float rand(float seed)
vector2 rand(float seed)
vector rand(float seed)
vector4 rand(float seed)

float rand(float seed, float seed2)
vector2 rand(float seed, float seed2)
vector rand(float seed, float seed2)
vector4 rand(float seed, float seed2)

float rand(vector2 seed)
vector2 rand(vector2 seed)
vector rand(vector2 seed)
vector4 rand(vector2 seed)

float rand(vector seed)
vector2 rand(vector seed)
vector rand(vector seed)
vector4 rand(vector seed)

float rand(vector4 seed)
vector2 rand(vector4 seed)
vector rand(vector4 seed)
vector4 rand(vector4 seed)

VEX —— Noise and Randomness_第14张图片

注,如需统一各个分量,可使用float()进行转化;

vector pos = 1;
float seed = 0;
pos *= float(rand(seed));

hscript_rand

  • hscript_rand生成与Hscript rand()相同的结果;对不同的浮点种子,此函数生成不同的随机值;这不同于random(将浮点参数转化为整数种子);
  • vex表达式hscript_rand与rand不同;
  • hscript_rand在不同硬件或操作系统上结果可能不同;
float|vector|vector4 hscript_rand(float seed)

VEX —— Noise and Randomness_第15张图片

你可能感兴趣的:(#,VEX,Houdini)