Jump to content

Procedural generated landscape...


photo

Recommended Posts

Hi everyone! I'm trying to do a manager/tycoon type of game prototype. I recently moved from Unreal because of the landscape limitations and a total lack of runtime modifications. So far, i've tried the landscape tool in Unigine and is really amazing and have all that i need for my project.

What i need is a random map generation system. The idea is generate noise and masks procedurally, then create the heightmap and masks textures so it can be used in the landscape. I've been looking at the TerrainGenerator.cs example, so i think all of that is possible. Is not so fancy anyway hehe. The problem i have is that my programming skills are really, really, really bad (Blueprints, i´ll miss them), but i'm trying to learn and i think i can follow a script and know more or less what is happening... haha. So i have some trouble finding the right way to achieve all of this. If some charitable soul can point me in the right direction, i'll be eternally greatfull.

My first wall was finding a noise generator. the Math library for what i can tell don't have one (like Unity for example). I've seen that the Game class has a Perlin Noise function, so i've made a script who looks like this:

public static float[,] GenerateNoiseMap(int mapHeight, int mapWidth, vec2 scale, int frequency){
		
		float[,] noiseMap = new float[mapHeight, mapWidth];

		for(int y = 0; y < mapHeight; y++){
			for(int x = 0; x < mapWidth; x++){
				vec2 noiseValue = new vec2(x, y);
				noiseMap[x,y] = Game.GetNoise2(noiseValue, scale, frequency);
			}
		}

		return noiseMap;
		
	}

First, i have no idea the range of the return value of the GetNoise function hahaha... Then, if for some miracle this code is somehow right, i need to create and save a 16 bits grayscale texture out of this.

I think the Image class is the way to go, isn't? But i get lost there...

I know is a very noob question. I think now i kind of hate the Unreal Blueprints because i've never have to write a single line of code before... haha...

Well, thank you very much in advance. I'm really loving Unigine so far. Hope you are all safe... And sorry for my bad english... cheers!!!

Link to comment
×
×
  • Create New...