Terrain art with math

I used to think that the terrain is only formed by the noise, but with mathematics is more beautiful

@Chrisir
@ glv
@ paulgoux
@ josephh
@jb4x

hi for all and thanks for help this is my unfinished work but it is great progress for now and many thanks for all

1 Like

4 Likes

Well done!

I like it!

It is similar to what I tried.

See Math Projects · Kango/MathProjects Wiki · GitHub

1 Like
1 Like

nice work

but you have full control than me

Some of my 3d printer final prints

2 Likes

@Chrisir

1 Like

more math

1 Like

check out my sketch its a 2d perlin grid with sliders. Its kind of an old project and hasnt yet been converted to 3d. I have added the grid to my windows gui Lib, I still need to work on file acquisitions in android. The library will come with a boid/entity class, so you could add animals and plants etc.

how to use it ??? on android ?and how to add jar file ?

You should be able to run the sketch file by clicking on it everything is ready to go. Ill update the library file later to add more interactivity. For now the grid constructer requires an instance of bms. And the constructor is as follows.

new Grid(xpos, ypos, width, height, resolution, bms) 

nice :smile:

1 Like

Play around with the sliders. Some of them dont do anything, but all th required sliders are there the others are for the 3d version which is not finished yet.

ok … when you end inform me

I mean the grid ones…

i do understand you …

this is the full grid portion of the code. This is the code almost following the example in Sebastian Lagues’ vid. I have added the double for loop and probably wont as I currently have other projects to get on with. But my repo is updated with the latest library files.

public void display(){
    
      mouseLogic();
    //logic();
      keys();
      output.append = true;
      
      //applet.println("amp1 "+ amp1);
      applet.noiseSeed((int)(seed));
      if(pallete.click(8))save();
      agentsCounted = 0;
      if (border){
        applet.stroke(0);
        applet.fill(255);
        applet.rect(x,y,w,h);
      }
      if(sliderMenu!=null&&sliderMenu.visible&&sliderMenu.menu.smdown||sUpdate){
        update = true;
        mdown = true;
        
        
      }
      else update = false;
      if(mdown&&!applet.mousePressed&&contour)contourUpdate = true;
      if(!applet.mousePressed)mdown = false;
      if(scale<=0)scale = 0.0001f;
      //if(contour)applet.beginShape();
      
        
      if(canvas==null)canvas = applet.createGraphics(res*rows,res*cols,applet.JAVA2D);
      //if(update||keyUpdate||sysUpdate||begin)
      canvas.beginDraw();
      //canvas2.beginDraw();
      for(int i=0;i<rows;i++){
        for(int j=0;j<cols;j++){
          
          applet.noStroke();
          int p = j + i * cols;
          Grid_space a = squares.get(p);

          if(update||keyUpdate||sysUpdate||begin){
            amplitude = amp1;
            frequency = freq1;
            float height = 0;
            mapNoise[j][i] = 0;
            
            for(int k=0;k<octaves;k++){
              
              float y1 = fy + scale1*i*frequency + octaveOffsets.get(k).x;
              float x1 = fx + scale1*j*frequency + octaveOffsets.get(k).y;
              float n1 = applet.noise(x1,y1);

              height += (n1*amplitude);
              //float height = n1*amp1;
              amplitude *= persistance;
              frequency *= lacunarity;
            }
            mapNoise[j][i] = height;
              // if(height>sealevel)map[j][i] = applet.color(0, 0, 153);
              // else if(height>groundlevel)map[j][i] = applet.color(204, 204, 0);
              // else if(height>grasslevel)map[j][i] = applet.color(51, 153, 51);
              // else if(height>mountainlevel)map[j][i] = applet.color(102, 102, 153); 

              // with alpha
              // if (height>mountainlevel)map[j][i] = applet.color(102, 102, 153,mountainlevel*255); 
              // else if (height>grasslevel)map[j][i] = applet.color(51, 153, 51,grasslevel*255);
              // else if (height>groundlevel)map[j][i] = applet.color(204, 204, 0,groundlevel*255);
              // else if (height<sealevel)map[j][i] = applet.color(0, 0, 153,sealevel*255);
              if (height>mountainlevel)map[j][i] = applet.color(102, 102, 153); 
              else if (height>grasslevel)map[j][i] = applet.color(51, 153, 51);
              else if (height>groundlevel)map[j][i] = applet.color(204, 204, 0);
              else if (height<sealevel)map[j][i] = applet.color(0, 0, 153);

              a.col = applet.color(map[j][i]);
              debug(a);
              
              //a.get_neighbours(this);
              //a.getNeighbours4(this);
              
            if(applet.brightness(a.col) > max)max = applet.brightness(a.col);
            canvas.fill(a.col);
            canvas.noStroke();
            canvas.rect(a.x,a.y,a.w,a.h);
            a.compared = false;
            begin = false;
          }
          
          if(a.popVisited)applet.fill(a.popCol);
          int count_ = 0;
          if(agentsPopulated)updateAgents(count_,a);
          //if(contour)a.drawBoundaries();
          if (!mapScoped&&count_==0)agentsCounted ++;
      }}
//  g1.img = canvas.get((int)x,(int)y,(int)w,(int)h);
  g1.img = canvas.get();
  canvas.endDraw();
  float w1 = -(applet.width - w)/2;
  float h1 = -(applet.height - h)/2;
  applet.image(g1.img,x+w1,y+h1);
  
  applet.strokeWeight(1);
  if(!contour){
    // remember to change sobel back;
    g1.sobel = null;
  }else {
    if(g1.sobel==null||contourUpdate){
      g1.sobel(9,20);
      applet.println(scale1,frequency,amplitude,octaves);

      contourUpdate = false;
    }
    applet.image(g1.sobel,0,0);
  }
  sysUpdate = false;
  update = false;
  sUpdate = false;
  contourUpdate = false;
      //if (contour)applet.endShape(OPEN);
//  if(applet.frameCount%10==0)applet.println("grid display",mountainlevel);
  //applet.println(squaresCounted,squares.size());
  if (toggle&&pallete.visible)pallete.draw();
  if (toggle&&sliderSettings!=null&&sliderSettings.toggle) {
	  sliderSettings.displayTab();
	  sliderSettings.setvScroll(0,200);
  }
  if (squaresCounted==squares.size()) sdown = false;
  if (agentsCounted==squares.size()-rows&&agentsPopulated)mapScoped = true;
  if (bcount>=squares.size())Boundaries = true;

  applet.fill(0);
  applet.text(applet.frameRate,100,100);
      
  };

currently produces this

1 Like

@paulgoux

nice work