How would you generate a map with multiple biome’s and when two biome’s meet they have a smooth transition. Not sure where to start. Would you have multiple noise’s to generate the height of the terrain and the moisture values.
1 Like
Yes I think this is a good idea.
What you could do is use the lerpColor()
function to have a smooth transition.
Thanks for your opinion it helps to have someone else’s opinion in these sort of cases.
Yeah pretty much like that. I believe that’s voxel terrain.
I think this is the way to do it tell me if i am wrong . You generate groups that have random shapes and sizes. In these shapes they have a noise moisture, temperature and Altitude.
Yes you could try it. Feel free to post screen shots and your code here
This is my try to do different biomes with RGB colors :
void setup() {
size(800, 800);
background(0);
loadPixels();
for(int i=0;i<3;i++){
int x = (int)random(width);
int y = (int) random(height);
int radius = (int) random(100,900);
for(int xpos = 0;xpos<width;xpos++){
for(int ypos = 0;ypos<height;ypos++){
int loc = xpos+ypos*width;
float dist = dist(x,y,xpos,ypos);
if (dist <= radius){
if (i==0) pixels[loc] = color(map(dist,0,radius,255,0),green(pixels[loc]),blue(pixels[loc]));
else if (i==1) pixels[loc] = color(red(pixels[loc]),map(dist,0,radius,255,0),blue(pixels[loc]));
else if (i==2) pixels[loc] = color(red(pixels[loc]),green(pixels[loc]),map(dist,0,radius,255,0));
}
}
}
}
updatePixels();
}
void draw() {
noLoop();
}
Here you have the 3D version :
int square_size = 5;
int x_size = 80*2 , y_size = 80*2;
Square[][] list;
void setup(){
size(800,800,P3D);
background(255);
rotateX(radians(30));
translate(0,-200,-400);
lights();
list = new Square[x_size][y_size];
//Calculus
for(int i=0;i<3;i++){ //Doing the loop 3 times for RGB
int x_center = (int)random(x_size); //The center coordinates of the biome
int y_center = (int) random(y_size);
int radius = (int) random(x_size); //The radius influence of the biome
float xoff = 0,yoff = 0; //Initialize noise values
for(int x=0;x<x_size;x++){
for(int y=0;y<y_size;y++){
float dist = dist(x,y,x_center,y_center);
if (list[x][y]==null) list[x][y] = new Square(color(100)); //initialize a black square
if (dist <= radius){
list[x][y].add_components(i,dist,radius,noise(xoff,yoff)*map(dist,0,radius,250,0));
}
yoff += 0.1;
}
yoff = 0;
xoff += 0.1;
}
}
//display
for(int x=0;x<x_size;x++){
for(int y=0;y<y_size;y++){
list[x][y].display(x,y);
}
}
save(second()+minute()+hour()+".jpg");
noLoop();
}
void draw(){
}
class Square{
float red,green,blue;
int size;
Square(color cc){
red = red(cc);
green = green(cc);
blue = blue(cc);
size = 0;
}
void display(int x,int y){
//println(red,green,blue);
fill(red,green,blue);
pushMatrix();
translate(x*square_size,y*square_size);
box(square_size,square_size,size);
popMatrix();
}
void add_components(int i,float dist,int radius,float s){
if (i==0) red += map(dist,0,radius,255,0);
if (i==1) green += map(dist,0,radius,255,0);
if (i==2) blue += map(dist,0,radius,255,0);
size += s;
}
}
2 Likes
Wow it looks great and works good too thanks for your help on this.
1 Like