噪波表达式示例

除了在此处提供的表达式示例,您还可以加载在“XGen 表达式编辑器”(XGen Expressions Editor)中预定义的噪波表达式。单击“示例”(Samples)选项卡,然后浏览至“全局”>“颜色”>“程序”>“噪波”(Global > Color > Procedural > Noise)

在噪波表达式中使用两个 Ptex 贴图

在此示例中,会合并两个 Ptex 贴图的输出值,然后在噪波表达式中进行修改。

#Two Ptex maps to be combined.
$a=map('${DESC}/paintmaps/color');#3dpaint,5.0
$b=map('${DESC}/paintmaps/color1');#3dpaint,5.0

#Declare local variables to control noise functions.
$freq_fine =0.653; #0.00,1.00
$freq_coarse =22.000; # 0,100
$X = 1.000; #0.00,10.00
$Y = 1; #0.00,10.00
$Z = 1; #0.00,10.00


$frequency = ($freq_fine+$freq_coarse) * [$X,$Y,$Z];

$Strength=1.000;
$Contrast =0.793;
$Color =1.000; #0,1
 
$Cnew = ($Color ? noise($P*$frequency) : noise($P*$frequency))-> contrast($Contrast);
mix($Cs,$Cnew,$Strength)*($a/$b)

创建噪波的多个层:简单

此噪波表达式可使用柏林噪波函数和三个数学函数生成噪波的多个层。

#Declare local variables to control noise and math functions.
$hi =1; #0.00,1.00 #slider created, range is 0 to 1.
$lo =0; #-1.00,0.00 #slider created, range is -1.0 to 0.
$contrast =0.59155;
$freq =10.4176; #0.1,30 #slider created, range is 0.1 to 30.0.

#Noise calculation: smoothstep() uses inputs and creates a noise field. This result is modified by the contrast setting.
smoothstep(noise($Pref*$freq), $lo, $hi) -> contrast($contrast)

创建噪波的多个层:复杂

此复杂噪波表达式可使用柏林噪波函数和多个数学函数生成噪波的多个层。

#Decalare local variables for input values to noise functions.
$Offset =0.1750;  
$liquidScale =7.3150;#0,100.0
$zitsLo =0.2600; 
$zitsHi =1.0000; 
$allLo =0.1450; 
$allHi =0.8850; 

#Declare local variables to control noise functions.
$noiseScaleFine =3.1350;#0,300.0 #slider created, range is 0 to 300.
$noiseScaleLarge =4.5300;#0,100.0 #slider is created, range is 0 to 100.

#Using Pref and Offset, noise and scale in a variable to move the noise.
$PP = ($Pref + $Offset) + noise($Pref*$liquidScale);

#Nosie being modified with the $nBuf local variable. Fbm() is a type of noise function.
$nBuf = (fbm($PP * $noiseScaleFine)+ fbm($PP * $noiseScaleLarge)) / 2; 

#Declare local variable for taking and applying a smoothstep to the Lo, Hi and Noise values.
$zitsBuf = smoothstep($nBuf, $zitsLo, $zitsHi);

#Declare local variable for taking and applying a smoothstep to create another layer of noise.
$liquidSkin =(smoothstep($zitsBuf + $nBuf,$allLo,$allHi));

#Invert multiplies the computed value by -1. -1 x -1 =1, 1 x -1=-1. You can also use ~ rather than $invert
$Invert=1;# 0,1

#$C is a local variable, $Cs is the evaluated color at the primitives location on the surface. The color is being modified by the local variable $Cnew.
#$E is a math function for Euler’s Number (an irrational constant). 

$C=($Cs*$Cnew)+(1-$Cs);
$E=(((1-$Cs)*$Cnew)+($Cs))

#Conditional statement. If $Invert is less than 0.5 then use $C else use $E.
($Invert < .5) ? $C : $E