Skip to main content

C# Produceral Terrain Generation 1

New Project:

DESIGNABLE - PRODUCERAL - TERRAIN - GENEARTION

Goals:
- Generate random terain with noise
- user input to get certain structures
- use fractals to get more nature-like structures
- use erosion to get even more accurate results
- use weather to get biomes and direct erosion
- export to heightmap
- export to .obj

By designable i mean that if you need a big mountain in the middle for example, you can give the data and it generates a random terrain, but with the mountain(aslo random) always present in the right place, so you can have random terrain and design so the game doesnt break.

Progress.
I making heighmaps now.
the engine can produce maps in 24 bit. red is low green is mid and blue is high. there are around 16m heights. if you see lots of red, it still can me a big number on that pixel, because the blue is low and red is high, but blue counts more as 10000 is more than 10. so visualy it can be weird but evertthing is right example: RGB(234, 2, 4) this will result in a red color. though because of the blue part of 4 this is a large number: 1001011101010 = 4842 now RGB(240, 0 ,0) will look similar but its only worth 240. same with black. now the engine can do these things:

- Create a map
- copy a map. 
- print a map
- save a map as 24bit image

- average maps
- add maps
- subtract maps
- multiply maps
- divide maps

- make random noise
- cubic smooth  maps
- round smooth maps
- make a bulbs/hills from points with a diffrence function(hill noise, my invention :D)

LETS SEE SOME RESULTS:

random noise

noise with min and max defined


cubic smooth of  noise


1 iterartion of smoothing


2 iterations of smoothing

a hill made by my hill algorithm



2 hills made with my algorithm.
points can me chosen, so here is the design part

HERE IS THE ALGORITM(C#):

public void make128intermap(ref int[,] m,int max, int p1x, int p1y, int p2x, int p2y,int stencilsize)
        {
            for (int x = 0; x < 128; x++)
            {
                for (int y = 0; y < 128; y++)
                {
                    int x1d = System.Math.Abs(x - p1x);
                    int y1d = System.Math.Abs(y - p1y);
                    float dist1 = (float)System.Math.Sqrt(x1d * x1d + y1d * y1d);
                    int x2d = System.Math.Abs(x - p2x);
                    int y2d = System.Math.Abs(y - p2y);
                    float dist2 = (float)System.Math.Sqrt(x2d * x2d + y2d * y2d);
                    float temp1 = max / dist1 / (100/stencilsize);
                    float temp2 = max / dist2 / (100/ stencilsize);
                    m[x, y] = (int)(temp1 + temp2);
                }
            }
        }

quite simple he

now get some maps added:
very un-agressive noise (max = max pixel number / 1200)added to a hill map which was made stronger by adding it to its self.

DONE: Get some good stuff to begin with.
TODO: get perlin noise, and nice fractals with DLA to get lightning like structures to make rivers and mountains.

Cody Bloemhard

[tag: c#] [tag: OpenGL] [tag: Tortoise2D Engine] [tag: 2D] [tag: Game Engine] [tag: ocdy1001] [tag: ocdy1001official] [tag: Unity] [tag: Unity3D] [tag: Unity5] [tag: 3D] [tag: Cody Bloemhard]

Comments

Popular posts from this blog

Important:

Fast Matrix transformation method

In this video i show an optimized way of using matrices in games.
by: Cody Bloemhard
ocdy1001official@gmail.com
[tag: c#] [tag: OpenGL] [tag: Tortoise2D Engine] [tag: 2D] [tag: Game Engine] [tag: ocdy1001] [tag: ocdy1001official] [tag: Unity] [tag: Unity3D] [tag: Unity5] [tag: 3D] [tag: Cody Bloemhard] [tag: Shaders] [tag: Produceral] [tag: c++] [tag: assemblyX64] [tag: GLSL] [tag: OpenTK] [tag: HKU] [tag: Gerrit Rietveld College] [tag: programming] [tag: ict]

C# produceral terrain generation 2

here is the first exported .obj terrain. The clock wise winding was wrong first, but i inverted a for loop and now it does fine. One time the hole terrain(flat) was not filled with flat squares but with a very weird pattern. Also a mountain was inside out. It works now. This model is loaded in unity. ta [tag: c#] [tag: OpenGL] [tag: Tortoise2D Engine] [tag: 2D] [tag: Game Engine] [tag: ocdy1001] [tag: ocdy1001official] [tag: Unity] [tag: Unity3D] [tag: Unity5] [tag: 3D] [tag: Cody Bloemhard]