ここで紹介するエクスプレッションの例に加えて、XGen エクスプレッション エディタ(XGen Expression Editor)で、定義済みのノイズ エクスプレッションをロードすることができます。サンプル(Samples)タブをクリックし、グローバル >カラー > プロシージャ > ノイズ(Global > Color > Procedural > Noise)を参照します。
この例では、2 つの 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)
このノイズ エクスプレッションは、Perlin ノイズ関数と 3 つの数学関数を使用して、ノイズの複数レイヤを生成します。
#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)
この複雑なノイズ エクスプレッションは、Perlin ノイズ関数と複数の数学関数を使用して、ノイズの複数レイヤを生成します。
#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