View Categories

Ek prosedürel gürültüler

10 dakika okuma

vray_osl_alligator_noise_10.png

Fraktal timsah gürültüsü

vray_osl_simplex_noise_10.png

Fraktal simpleks gürültüsü

vray_osl_perlin_flow_noise_10.png

Fraktal Perlin akış gürültüsü

vray_osl_simplex_flow_noise_10.png

Fraktal Simpleks akış gürültüsü

Genel Bakış #


Bu, burada açıklanan Houdini’nin timsah gürültüsü efektinin bir uygulamasıdır .

Bu yöntem, yüzeyin doku koordinatlarını değil, gölgelendirme noktasının nesne uzayındaki konumunu kullanır.

Bu gölgelendiriciyi, ” doku koordinatlarını sar ” seçeneği kapalı olan bir VRayOSLTex örneğiyle birlikte kullanın.

Shader koduna şu adresten ulaşabilirsiniz:

timsahgürültüsü.zip

.

Parametreler #


Başlangıç ​​frekansı – Genel ayrıntı düzeyini etkileyen ilk örnekleme pozisyonu çarpanı.

Başlangıç ​​ofseti – İlk örnekleme konumunu ofsetleyerek deseni belirtilen yönde kaydırır.

Lakünarite – Yineleme başına konum (frekans) çarpanı.

kazanç – Her yinelemedeki genlik çarpanı.

oktavlar – Fraktal yineleme sayısı.

Zayıflama – Sonuca uygulanan azalma gücü.

Gölgelendirici kodu  #


İşte shader kodu:

timsahgürültüsü.osl #
</p>
<div>/*</div>
<div> * Copyright (c) 2016</div>
<div> * Side Effects Software Inc.  All rights reserved.</div>
<div> *</div>
<div> * Redistribution and use of Houdini Development Kit samples in source and</div>
<div> * binary forms, with or without modification, are permitted provided that the</div>
<div> * following conditions are met:</div>
<div> * 1. Redistributions of source code must retain the above copyright notice,</div>
<div> *    this list of conditions and the following disclaimer.</div>
<div> * 2. The name of Side Effects Software may not be used to endorse or</div>
<div> *    promote products derived from this software without specific prior</div>
<div> *    written permission.</div>
<div> *</div>
<div> * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS</div>
<div> * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</div>
<div> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN</div>
<div> * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,</div>
<div> * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</div>
<div> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,</div>
<div> * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF</div>
<div> * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING</div>
<div> * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,</div>
<div> * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</div>
<div> *</div>
<div> *----------------------------------------------------------------------------</div>
<div> */</div>
<div></div>
<div>/// Alligator Noise is provided by Side Effects Software Inc. and is licensed</div>
<div>/// under a Creative Commons Attribution-ShareAlike 4.0 International License.</div>
<div>///</div>
<div>/// Author:  "Side Effects Software Inc"</div>
<div>/// Source:  "http://www.sidefx.com/docs/hdk15.0/alligator_2alligator_8_c-example.html"</div>
<div>/// License: "http://creativecommons.org/licenses/by-sa/4.0/"</div>
<div>///</div>
<div>/// Translated and modified by Ivan Mavrov, Chaos Group Ltd. 2016</div>
<div>/// Contact: ivan.mavrov@chaosgroup.com</div>
<div></div>
<div>/// 3D Alligator noise implementation.</div>
<div>/// Returned values are in the [0, 1] range.</div>
<div>float alligatorNoise3D(point position) {</div>
<div>vector cellOffsets[27] = {</div>
<div>vector( 0,  0,  0),</div>
<div>vector( 1,  0,  0),</div>
<div>vector( 1,  1,  0),</div>
<div>vector( 0,  1,  0),</div>
<div>vector(-1,  1,  0),</div>
<div>vector(-1,  0,  0),</div>
<div>vector(-1, -1,  0),</div>
<div>vector( 0, -1,  0),</div>
<div>vector( 1, -1,  0),</div>
<div></div>
<div>vector( 0,  0, -1),</div>
<div>vector( 1,  0, -1),</div>
<div>vector( 1,  1, -1),</div>
<div>vector( 0,  1, -1),</div>
<div>vector(-1,  1, -1),</div>
<div>vector(-1,  0, -1),</div>
<div>vector(-1, -1, -1),</div>
<div>vector( 0, -1, -1),</div>
<div>vector( 1, -1, -1),</div>
<div></div>
<div>vector( 0,  0,  1),</div>
<div>vector( 1,  0,  1),</div>
<div>vector( 1,  1,  1),</div>
<div>vector( 0,  1,  1),</div>
<div>vector(-1,  1,  1),</div>
<div>vector(-1,  0,  1),</div>
<div>vector(-1, -1,  1),</div>
<div>vector( 0, -1,  1),</div>
<div>vector( 1, -1,  1)</div>
<div>};</div>
<div></div>
<div>point iPosition = floor(position);</div>
<div></div>
<div>float firstReverseSmoothPointDistance = 0.0;</div>
<div>float secondReverseSmoothPointDistance = 0.0;</div>
<div></div>
<div>for (int cellIndex = 0; cellIndex &lt; 27; ++cellIndex) {</div>
<div>point cellOrigin = iPosition + cellOffsets[cellIndex];</div>
<div>vector cellPointOffset = cellnoise(cellOrigin, 0.0);</div>
<div>point cellPointPosition = cellOrigin + cellPointOffset;</div>
<div></div>
<div>float cellPointDistance = distance(position, cellPointPosition);</div>
<div></div>
<div>if (cellPointDistance &lt; 1.0) {</div>
<div>float reverseSmoothDistance = smoothstep(0.0, 1.0, 1.0 - cellPointDistance);</div>
<div></div>
<div>float distanceMultiplier = float(cellnoise(cellOrigin, 1.0));</div>
<div>reverseSmoothDistance *= distanceMultiplier;</div>
<div></div>
<div>if (firstReverseSmoothPointDistance &lt; reverseSmoothDistance) {</div>
<div>secondReverseSmoothPointDistance = firstReverseSmoothPointDistance;</div>
<div>firstReverseSmoothPointDistance = reverseSmoothDistance;</div>
<div>} else {</div>
<div>if (secondReverseSmoothPointDistance &lt; reverseSmoothDistance) {</div>
<div>secondReverseSmoothPointDistance = reverseSmoothDistance;</div>
<div>}</div>
<div>}</div>
<div>}</div>
<div>}</div>
<div></div>
<div>return firstReverseSmoothPointDistance - secondReverseSmoothPointDistance;</div>
<div>}</div>
<div></div>
<div>/// 3D Fractal Alligator noise implementation.</div>
<div>/// Returned values are in the [-1, 1] range.</div>
<div>float fractalAlligatorNoise3D(</div>
<div>point position,</div>
<div>float lacunarity, // Houdini 2.0</div>
<div>float gain,       // Houdini rough</div>
<div>int octaveCount   // Houdini turbulence - 1</div>
<div>) {</div>
<div>float noiseValue = 0.0;</div>
<div></div>
<div>float amplitude = 1.0;</div>
<div></div>
<div>    for (int octave = 0; octave &lt; octaveCount; ++octave) {</div>
<div>noiseValue += amplitude * (alligatorNoise3D(position) - 0.5);</div>
<div>position *= lacunarity;</div>
<div>amplitude *= gain;</div>
<div>}</div>
<div></div>
<div>return noiseValue;</div>
<div>}</div>
<div></div>
<div>shader FractalAlligatorNoise</div>
<div>[[ string description = "Fractal Alligator noise" ]]</div>
<div>(</div>
<div>float start_frequency = 1.0</div>
<div>[[ string description = "Initial sampling position multiplier that affects the overall granularity." ]],</div>
<div>vector start_offset = vector(0.0)</div>
<div>[[ string description = "Offsets the initial sampling position effectively shifting the pattern in the specified direction." ]],</div>
<div></div>
<div>float lacunarity = 2.0</div>
<div>[[ string description = "Position (frequency) multiplier per iteration." ]],</div>
<div>float gain = 0.5</div>
<div>[[ string description = "Amplitude multiplier per iteration." ]],</div>
<div>int octaves = 8</div>
<div>[[ string description = "Number of fractal iterations." ]],</div>
<div></div>
<div>float attenuation = 1.0</div>
<div>[[ string description = "The power of the falloff applied to the final result." ]],</div>
<div></div>
<div>output color result = 0.0</div>
<div>) {</div>
<div>point objectPosition = transform("object", P);</div>
<div>point startPosition = start_frequency * objectPosition - start_offset;</div>
<div></div>
<div>float noiseValue = fractalAlligatorNoise3D(startPosition, lacunarity, gain, octaves);</div>
<div></div>
<div>noiseValue = 0.5 * noiseValue + 0.5;</div>
<div>noiseValue = pow(noiseValue, attenuation);</div>
<div></div>
<div>result = color(noiseValue);</div>
<div>}</div>
<p>

Simpleks gürültüsü #

 Genel Bakış #


Simpleks gürültüsü,  Perlin gürültüsünün yakın bir akrabasıdır ancak daha az yönsel bozulmaya ve özellikle yüksek boyutlarda genellikle daha düşük hesaplama yüküne sahiptir.

Mevcut 3D uygulama, yüzeyin doku koordinatları yerine gölgelendirme noktasının nesne uzayındaki konumunu kullanır.

Bu gölgelendiriciyi, ” doku koordinatlarını sar ” seçeneği kapalı olan bir VRayOSLTex örneğiyle birlikte kullanın.

Shader koduna şu adresten ulaşabilirsiniz:

simplexnoise.zip

.

Parametreler #


Başlangıç ​​frekansı – Genel ayrıntı düzeyini etkileyen ilk örnekleme pozisyonu çarpanı.

Başlangıç ​​ofseti – İlk örnekleme konumunu ofsetleyerek deseni belirtilen yönde kaydırır.

Lakünarite – Yineleme başına konum (frekans) çarpanı.

kazanç – Her yinelemedeki genlik çarpanı.

oktavlar – Fraktal yineleme sayısı.

Zayıflama – Sonuca uygulanan azalma gücü.

Gölgelendirici kodu #


İşte shader kodu:

simplexnoise.osl #
/// 3D Simplex noise implementation.
} else {
// Y X Z order
skewedOffset1 = vector(0, 1, 0);
skewedOffset2 = vector(1, 1, 0);
}
}
// A step of (1, 0, 0) in skewed space means a step of (1 – G3, -G3, -G3) in regular space.
// A step of (0, 1, 0) in skewed space means a step of (-G3, 1 – G3, -G3) in regular space.
// A step of (0, 0, 1) in skewed space means a step of (-G3, -G3, 1 – G3) in regular space.
// The offset from point 1 in regular space.
vector offset1 = offset0 – skewedOffset1 + G3;
// The offset from point 2 in regular space.
vector offset2 = offset0 – skewedOffset2 + G3a;
// The offset from point 3 in regular space.
vector offset3 = offset0 + G3b;
// Wrap the integer indices at 256, to avoid indexing perm[] out of bounds.
int i = int(skewedCellOrigin[0]) & 255;
int j = int(skewedCellOrigin[1]) & 255;
int k = int(skewedCellOrigin[2]) & 255;
// Accumulate the contributions from the four points.
float noiseValue = 0.0;
noiseValue += evaluatePointContribution(i, j, k, offset0);
noiseValue += evaluatePointContribution(i + int(skewedOffset1[0]), j + int(skewedOffset1[1]), k + int(skewedOffset1[2]), offset1);
noiseValue += evaluatePointContribution(i + int(skewedOffset2[0]), j + int(skewedOffset2[1]), k + int(skewedOffset2[2]), offset2);
noiseValue += evaluatePointContribution(i + 1, j + 1, k + 1, offset3);
// Scale to the [-1,1] range.
noiseValue *= 32.0;
// Scale to the [0, 1] range.
return 0.5 * noiseValue + 0.5;
}
/// 3D Fractal Simplex noise implementation.
/// Returned values are in the [-1, 1] range.
float fractalSimplexNoise3D(
point position,
float lacunarity,
float gain,
int octaveCount
) {
float noiseValue = 0.0;
float amplitude = 1.0;
for (int octave = 0; octave < octaveCount; ++octave) {
noiseValue += amplitude * (simplexNoise3D(position) – 0.5);
position *= lacunarity;
amplitude *= gain;
}
return noiseValue;
}
shader FractalSimplexNoise
[[ string description = “Fractal Simplex noise” ]]
(
float start_frequency = 1.0
[[ string description = “Initial sampling position multiplier that affects the overall granularity.” ]],
vector start_offset = vector(0.0)
[[ string description = “Offsets the initial sampling position effectively shifting the pattern in the specified direction.” ]],
float lacunarity = 2.0
[[ string description = “Position (frequency) multiplier per iteration.” ]],
float gain = 0.5
[[ string description = “Amplitude multiplier per iteration.” ]],
int octaves = 8
[[ string description = “Number of fractal iterations.” ]],
float attenuation = 1.0
[[ string description = “The power of the falloff applied to the final result.” ]],
output color result = 0.0
) {
point objectPosition = transform(“object”, P);
point startPosition = start_frequency * objectPosition – start_offset;
float noiseValue = fractalSimplexNoise3D(startPosition, lacunarity, gain, octaves);
noiseValue = 0.5 * noiseValue + 0.5;
noiseValue = pow(noiseValue, attenuation);
result = color(noiseValue);
}

Perlin akış gürültüsü #

Genel Bakış  #


Bu , gürültüyü değerlendirmek için kullanılan gradyan vektörlerini döndüren ek bir akış parametresi içeren bir Perlin gürültüsüdür .

Bu, gürültüyü gürültü uzayında kaydırmak yerine dönüştüren, periyodu 1.0 olan 4. boyutlu bir parametre oluşturur.

Bu uygulama, Stefan Gustavson’ın gradyan döndürme düzlemleri kavramını kullanmaktadır. Daha fazla bilgiyi burada bulabilirsiniz .

Bu, yüzeyin doku koordinatlarını değil, gölgelendirme noktasının nesne uzayındaki konumunu kullanan 3 boyutlu bir gürültüdür.

Bu gölgelendiriciyi, ” doku koordinatlarını sar ” seçeneği kapalı olan bir VRayOSLTex örneğiyle birlikte kullanın.

Shader koduna şu adresten ulaşabilirsiniz:

perlinflownoise.zip

.

Parametreler #


Başlangıç ​​frekansı – Genel ayrıntı düzeyini etkileyen ilk örnekleme pozisyonu çarpanı.

Başlangıç ​​ofseti – İlk örnekleme konumunu ofsetleyerek deseni belirtilen yönde kaydırır.

Akış – Gürültü uzayında 3 boyutlu bir dilimi kaydırmak yerine, gürültüyü canlandırmak için doğal olarak evrimleştiren, periyodu 1 olan özel bir gürültü boyutunun koordinatı.

Lakünarite – Yineleme başına konum (frekans) çarpanı.

Akış hızı – Her yinelemede akış koordinatı çarpanı.

kazanç – Her yinelemedeki genlik çarpanı.

advect – Hem başlangıçtaki adveksiyon miktarı hem de yineleme başına adveksiyon çarpanı.

oktavlar – Fraktal yineleme sayısı.

Zayıflama – Sonuca uygulanan azalma gücü.

Gölgelendirici kodu  #


İşte shader kodu:

perlinflownoise.osl #
int fastFloor(float x) {
/// 3D Fractal Perlin flow noise implementation.
/// Returned values are in the [-1, 1] range.
float fractalPerlinFlowNoise3D(
point position,
float flow,
float lacunarity,
float flowRate,
float gain,
float advect,
int octaveCount
) {
float noiseValue = 0.0;
float flowValue = flow;
float amplitude = 1.0;
float advectionAmount = advect;
for (int octave = 0; octave < octaveCount; ++octave) {
float noiseOctave = amplitude * (perlinFlowNoise3D(position, flowValue) – 0.5);
noiseValue += noiseOctave;
if (advectionAmount != 0.0) {
position -= advectionAmount * noiseOctave * perlinFlowNoise3DGradient(position, flow, 0.01);
}
position *= lacunarity;
flowValue *= flowRate;
amplitude *= gain;
advectionAmount *= advect;
}
return noiseValue;
}
shader FractalPerlinFlowNoise
[[ string description = “Fractal Perlin flow noise” ]]
(
float start_frequency = 1.0
[[ string description = “Initial sampling position multiplier that affects the overall granularity.” ]],
vector start_offset = vector(0.0)
[[ string description = “Offsets the initial sampling position effectively shifting the pattern in the specified direction.” ]],
float flow = 1.0
[[ string description = “The coordinate of a special noise dimension with a period of 1 that naturally evolves the noise to animate it instead of sliding a 3D slice throught the noise space.” ]],
float lacunarity = 2.0
[[ string description = “Position (frequency) multiplier per iteration.” ]],
float flow_rate = 1.0
[[ string description = “Flow coordinate multiplier per iteration.” ]],
float gain = 0.5
[[ string description = “Amplitude multiplier per iteration.” ]],
float advect = 0.5
[[ string description = “Both initial advection amount and advection multiplier per iteration.” ]],
int octaves = 8
[[ string description = “Number of fractal iterations.” ]],
float attenuation = 1.0
[[ string description = “The power of the falloff applied to the final result.” ]],
output color result = 0.0
) {
point objectPosition = transform(“object”, P);
point startPosition = start_frequency * objectPosition – start_offset;
float noiseValue = fractalPerlinFlowNoise3D(startPosition, flow, lacunarity, flow_rate, gain, advect, octaves);
noiseValue = 0.5 * noiseValue + 0.5;
noiseValue = pow(noiseValue, attenuation);
result = color(noiseValue);
}

Simpleks akış gürültüsü #

Genel Bakış  #


Bu , Stefan Gustavson’ın Simplex akış gürültüsü uygulamasının fraktal gürültü uzantısıyla birlikte OSL’ye (Over-Steam) çevirisidir .

Simplex akış gürültüsü, Perlin akış gürültüsüne kıyasla önemli bir performans avantajı sağlayan gerçek analitik türevleri kullanır.

Bu, yüzeyin doku koordinatlarını değil, gölgelendirme noktasının nesne uzayındaki konumunu kullanan 3 boyutlu bir gürültüdür.

Bu gölgelendiriciyi, ” doku koordinatlarını sar ” seçeneği kapalı olan bir VRayOSLTex örneğiyle birlikte kullanın.

Shader koduna şu adresten ulaşabilirsiniz:

simplexflownoise.zip

.

Parametreler #


Başlangıç ​​frekansı – Genel ayrıntı düzeyini etkileyen ilk örnekleme pozisyonu çarpanı.

Başlangıç ​​ofseti – İlk örnekleme konumunu ofsetleyerek deseni belirtilen yönde kaydırır.

Akış – Gürültü uzayında 3 boyutlu bir dilimi kaydırmak yerine, gürültüyü canlandırmak için doğal olarak evrimleştiren, periyodu 1 olan özel bir gürültü boyutunun koordinatı.

Lakünarite – Yineleme başına konum (frekans) çarpanı.

Akış hızı – Her yinelemede akış koordinatı çarpanı.

kazanç – Her yinelemedeki genlik çarpanı.

advect – Hem başlangıçtaki adveksiyon miktarı hem de yineleme başına adveksiyon çarpanı.

oktavlar – Fraktal yineleme sayısı.

Zayıflama – Sonuca uygulanan azalma gücü.

Gölgelendirici kodu #


İşte shader kodu:

simplexflownoise.osl #
/// Oiginal notice:
float lacunarity,
float flowRate,
float gain,
float advect,
int octaveCount
) {
float noiseValue = 0.0;
float flowValue = flow;
float amplitude = 1.0;
float advectionAmount = advect;
for (int octave = 0; octave < octaveCount; ++octave) {
vector flownoise3DGradient = vector(0.0);
float noiseOctave = amplitude * (simplexFlowNoise3D(position, flowValue, flownoise3DGradient) – 0.5);
noiseValue += noiseOctave;
position -= advectionAmount * noiseOctave * flownoise3DGradient;
position *= lacunarity;
flowValue *= flowRate;
amplitude *= gain;
advectionAmount *= advect;
}
return noiseValue;
}
shader FractalSimplexFlowNoise
[[ string description = “Fractal Simplex flow noise” ]]
(
float start_frequency = 1.0
[[ string description = “Initial sampling position multiplier that affects the overall granularity.” ]],
vector start_offset = vector(0.0)
[[ string description = “Offsets the initial sampling position effectively shifting the pattern in the specified direction.” ]],
float flow = 1.0
[[ string description = “The coordinate of a special noise dimension with a period of 1 that naturally evolves the noise to animate it instead of sliding a 3D slice throught the noise space.” ]],
float lacunarity = 2.0
[[ string description = “Position (frequency) multiplier per iteration.” ]],
float flow_rate = 1.0
[[ string description = “Flow coordinate multiplier per iteration.” ]],
float gain = 0.5
[[ string description = “Amplitude multiplier per iteration.” ]],
float advect = 0.5
[[ string description = “Both initial advection amount and advection multiplier per iteration.” ]],
int octaves = 8
[[ string description = “Number of fractal iterations.” ]],
float attenuation = 1.0
[[ string description = “The power of the falloff applied to the final result.” ]],
output color result = 0.0
) {
point objectPosition = transform(“object”, P);
point startPosition = start_frequency * objectPosition – start_offset;
float noiseValue = fractalSimplexFlowNoise3D(startPosition, flow, lacunarity, flow_rate, gain, advect, octaves);
noiseValue = 0.5 * noiseValue + 0.5;
noiseValue = pow(noiseValue, attenuation);
result = color(noiseValue);
}

Tarafından desteklenmektedir BetterDocs

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir