WorldKit icon indicating copy to clipboard operation
WorldKit copied to clipboard

Perlin noise octaves have incorrect offset.

Open hudmarc opened this issue 3 years ago • 0 comments

When setting the offfset of Perlin noise the sub octaves are not offset by the correct amount. The following code (in PerlinNoise.hlsl) should be changed from:

float StandardPerlinNoise(uint id, float amplitude, float2 offset){
    // Calculate vector
    float2 pos = IndexToFloatVector(id, HeightMapResolution);
    
    // Calculate x and y position
    float x = float(pos.x) / HeightMapResolution;
    float y = float(pos.y) / HeightMapResolution;
    
    // Generate noise
    return cnoise(float2(x * amplitude + offset.x, y * amplitude + offset.y));
}

to

float StandardPerlinNoise(uint id, float amplitude, float2 offset){
    // Calculate vector
    float2 pos = IndexToFloatVector(id, HeightMapResolution);
    
    // Calculate x and y position
    float x = (float(pos.x) + offset.x) / HeightMapResolution;
    float y = (float(pos.y) + offset.y) / HeightMapResolution;
    
    // Generate noise
    return cnoise(float2(x * amplitude , y * amplitude));
}

so that sub octaves are correctly offset by the offset value.

hudmarc avatar May 25 '22 23:05 hudmarc