When writing a glsl material, are there any controls for the built-in noise function TDSimplexNoise like we have in a glsl top or chop? (period, harmonics, exponent, etc.)
I should probably rather use a 2D sampler and reference a top…
When writing a glsl material, are there any controls for the built-in noise function TDSimplexNoise like we have in a glsl top or chop? (period, harmonics, exponent, etc.)
I should probably rather use a 2D sampler and reference a top…
Not to derail your actual question, but a pixel sample is generally faster than the complex math for a good noise function (on the GPU)
Like bwheaton says it’s definitely faster to ‘prebake’ the noise, but might not always be easy when prototyping. The noise you see in a noiseTOP is a ‘fbm’ (fractional brownian motion) version, which mean there are more iterations of noise with different frequencies and amplitudes. You can do a similar approach by creating your noise in a for loop.
Something like this:
out vec4 fragColor;
void main()
{
vec2 uv = vUV.st*2.-1.;
float period = 1;
int harmonics = 3;
float spread = 2.;
float gain = 0.7;
float exponent = 1.;
float frequency = 1./period;
float offset = 0.5;
float amplitude = 0.5;
float noise = 0;
for (int i = 0; i < harmonics; i++) {
noise += TDSimplexNoise(uv * frequency) * amplitude;
frequency *= spread;
amplitude *= gain;
}
noise = sign(noise)*pow(abs(noise), exponent);
noise += offset;
vec4 color = vec4(noise);
fragColor = TDOutputSwizzle(color);
}
Period = 1/frequency (frequency is the scalar of the input of TDSimplexNoise(frequency * uv))
Harmonics = amount of iterations of noise
Harmonic spread = how much the frequency changes per iteration (scalar of the frequency)
Harmonic gain = how much the amplitude changes per iterations (scalar of the amplitude)
Exponent = takes the noise to a certain power (noise^exponent, when 2 this is a square, 0.5 a squareroot)
amplitude = the initial amplitude (first iteration)
offset = added to the noise
(note my ugly sign() abs() trick with the exponent power. I did this since pow(-x, a) gave me NaNs)
Hope this helps.
Cheers,
tim
I thought so too, I will just sample a noise TOP as usual, it already has all the options so no need to remake the wheel. Thank you for replying