Skip to content

Commit

Permalink
Improved falloff of the falloff controller by varying the padding by …
Browse files Browse the repository at this point in the history
…the frequency of the noise
  • Loading branch information
john01dav committed Dec 20, 2015
1 parent 161a4a5 commit 4114391
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class FalloffPerlinNoiseTest{

public static void main(String[] args) throws IOException{
HeightMap heightMap = new HeightMap(4096, new PerlinNoiseTemplate(0L, 9, 2, new FalloffPerlinNoiseController(512)));
HeightMap heightMap = new HeightMap(2048, new PerlinNoiseTemplate(0L, 9, 2, new FalloffPerlinNoiseController()));
heightMap.generate();
heightMap.saveImage("./falloffislandperlinnoise.png");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
package src.john01dav.jnoise.templates.perlin;

import src.john01dav.jnoise.util.Coordinates;
import src.john01dav.jnoise.util.MathUtil;

public class FalloffPerlinNoiseController implements PerlinNoiseHeightController{
private int paddingSize;
private int mapSize;

public FalloffPerlinNoiseController(int paddingSize){
this.paddingSize = paddingSize;
}

@Override
public void init(int mapSize){
this.mapSize = mapSize;
}

@Override
public double getHeightMultiplier(int x, int y, int frequency){
if(x < 0 || x >= mapSize || y < 0 || y >= mapSize || distanceToEdge(x, y) < paddingSize){
if(x < 0 || x >= mapSize || y < 0 || y >= mapSize || distanceToEdge(x, y) < frequency){
return 0;
}else{
return 1;
Expand Down

0 comments on commit 4114391

Please sign in to comment.