平滑低八度的柏林噪音

时间:2012-01-25 18:17:34

标签: glsl shader webgl fragment-shader

我正在尝试使用找到的here噪声函数在片段着色器中创建超级简单的Perlin噪声云。

在低八度音阶时,我的输出是,因为缺少一个更好的词,'blobby'。我只想平滑这些斑点区域,并且声音平滑,但比一个八度音程更加细致。

片段着色器:

#ifdef GL_ES
precision mediump float;
#endif

uniform float time;
uniform vec2 resolution;

// Noise related functions go here ..

float surface3 ( vec3 coord ) {
        float frequency = 4.0;
        float n = 0.0;  

        n += 1.0    * abs( cnoise( coord * frequency ) );
        n += 0.5    * abs( cnoise( coord * frequency * 2.0 ) );
        n += 0.25   * abs( cnoise( coord * frequency * 4.0 ) );

        return n;
}

void main( void ) {
        vec2 position = gl_FragCoord.xy / resolution.xy;

        float n = surface3(vec3(position, time * 0.1));

        gl_FragColor = vec4(n, n, n, 1.0);
}

直播示例:
http://glsl.heroku.com/e#1413.0

左边是我现在所拥有的。我怎样才能用正确的图像实现更内联的东西?

1 个答案:

答案 0 :(得分:4)

最简单的方法是在曲面函数中取出两个噪声调用。只留下第一个噪音呼叫线,你得到的东西看起来像第一个:

http://glsl.heroku.com/e#1450.0

多倍频程噪声中的尖锐线条来自于使用abs(),移除abs()并将其替换为噪声值的平方或者执行类似0.5 *(1.0 + cnoise())的操作(如果cnoise输出为在-1..1之间。

这是一些摆弄的结果 http://glsl.heroku.com/e#1450.1

相关问题