Problem
I was going to using the Perlin Noise Reference implementation .
The algorithm code does not mention the range of values ββthat it will produce. From what I read about Perlin Noise, the result should be in the range [0,1]. This is not for this algorithm. Therefore, I played, showed the result on the diagram and realized that the result should be from -0.5 to 0.5.
Well, that is not the case either. Until you set the parameter x to any value and leave y and z equal to 0.
As soon as you e. g. have x and y, the result is one outside of -0.5 and 0.5.
Question
Does anyone know how to use this algorithm? In what range are the result values?
the code
I wrote a sample program in JavaFX using Perlin noise code :
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.chart.LineChart; import javafx.scene.chart.NumberAxis; import javafx.scene.chart.XYChart; import javafx.stage.Stage; public class NoiseChart extends Application { @Override public void start(Stage stage) {
Values ββin which the range [-0,5,0,5] is exceeded:
tx=0.5200000000000001, ty=10000.520000000011, perlin noise: -0.5000000000027285 tx=0.5400000000000001, ty=10000.540000000012, perlin noise: -0.5084454691119766 tx=0.5600000000000002, ty=10000.560000000012, perlin noise: -0.5135793753147445 tx=0.5800000000000002, ty=10000.580000000013, perlin noise: -0.515139185394058 tx=0.6000000000000002, ty=10000.600000000013, perlin noise: -0.512927358018701 tx=0.6200000000000002, ty=10000.620000000014, perlin noise: -0.5068223692749664
And the chart:

Or as a more suitable use case in an image in which the result of Perlin Noise is mapped to color values:
import javafx.application.Application; import javafx.beans.property.DoubleProperty; import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.control.Slider; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.image.PixelWriter; import javafx.scene.image.WritableImage; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.paint.Color; import javafx.stage.Stage; public class NoiseImage extends Application { DoubleProperty frequencyProperty = new SimpleDoubleProperty( 5); @Override public void start(Stage stage) { BorderPane root = new BorderPane(); ImageView imageView = new ImageView(createImage()); root.setCenter(imageView); HBox toolbar = new HBox(); Label frequencyLabel = new Label( "Frequency"); Slider frequencySlider = new Slider(0, 50, 5); frequencySlider.setPrefWidth(200); frequencySlider.setShowTickLabels(true); frequencySlider.setShowTickMarks(true); frequencySlider.valueProperty().bindBidirectional(frequencyProperty); frequencyProperty.addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { imageView.setImage(createImage()); } }); Label frequencyValueLabel = new Label( "Frequency"); frequencyValueLabel.textProperty().bind(frequencyProperty.asString()); toolbar.getChildren().addAll(frequencyLabel, frequencySlider, frequencyValueLabel); root.setTop(toolbar); Scene scene = new Scene(root, 800, 600); stage.setScene(scene); stage.show(); } public Image createImage() { double noise; int width = 256; int height = 256; WritableImage wr = new WritableImage(width, height); PixelWriter pw = wr.getPixelWriter(); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { double frequency = frequencyProperty.get() / (double) width; double tx = x * frequency; double ty = y * frequency; noise = ImprovedNoise.noise(tx, ty, 0); double gray = normalizeValue(noise, -.5, .5, 0., 1.);
Values ββwhere [-0,5,0,5] are exceeded:
... tx=250, ty=131, perlin noise: -0.5221718771387314 tx=250, ty=132, perlin noise: -0.5026623324564983 tx=251, ty=124, perlin noise: -0.5021001248099309 tx=251, ty=125, perlin noise: -0.5193524233279807 tx=251, ty=126, perlin noise: -0.5312601268638136 tx=251, ty=127, perlin noise: -0.5375809523803251 tx=251, ty=128, perlin noise: -0.5382082635276979 tx=251, ty=129, perlin noise: -0.5331735730625967 tx=251, ty=130, perlin noise: -0.5226452480286591 tx=251, ty=131, perlin noise: -0.5069234176982861 tx=252, ty=125, perlin noise: -0.509547880806866 tx=252, ty=126, perlin noise: -0.5202072536185804 ...
Screenshot:

Thank you for help!