in my game i already wrote the part that loads the terrain in many tiles, and now i have to wrote the part that puts the vegetation on it.
I need a procedural way to set the coordinates.
I thought of usingx = sin(T(x,y))* size_of_the_tile's_side/2andy = cos(K(x,y))*size_of_the_tile's_side/2to calculate the position relative to the tile center(in this way i'm sure the coords can't fell out of the tile).
The problems i have are:
1) i can't use any random function (the vegetation must not change, every time you are on a tile the vegetation must be the same)
2) i need to have the T(x,y) and K(x,y) functions a bit vary, since i don't want the vegetation to be much repetitive(since sin & cos are periodic functions)
3) i need an "algorithm" to calculate how much vegetation add (i can't add always 50 trees, i need it to vary, and it should be dependent from the sector(so that the density is quite costant in macro-zones))
Long story short, i need to set how many vegetation to add and where..
Is there any docs, resources, papers to get informations from?
Thank you very much in advance
Ps: i said cos and sin since they are the simplest functions that always return [-1;+1], but i'm open to more complex functions
PPs: x and y are the integer index of the tile. Watching from above, the lower-left tile is (0,0) , the upper-right is the ,eg, (300,300)
PPPs: the game is 3D, but the z coord is not a problem, since i'll throw a ray from above and find the intersection with the terrain, and than i'll have the z coord of the hit point and the normal of that face(and then if the terrain is too steep i'll add a different type of vegetation, and i'll load different meshes in base of the height of the terrain)
Hi im really an amateur compared what to most people here, but I have a suggestion to you problem. Like a previous person replying said perlin noise is a good way to make deterministic procedural generation, that is a way of generating something that doesn't change when you look it up again.
Im not sure I understand, but are you using a lattice(2d array) and populating it using a sin/cos function, or are you placing the vegetation on different places inside the tile?
Personal experiences from using noise:
I've not implemented perlin noise as Ken Perlin done it, I took a Xor based pseudo random number generator (prng) and made it seedable with x, y coordinates and a single seed number. Thus I had deterministic noise that i could access one tile at a time. The noise is just a random number but can be used to with conditions to make statistical distribution of trees or terrain or whatever really. Its quite magic comparing to storing and manipulating a lattice. To make something more like Perlin Noise I made another function(method since I use Java) that used linear interpolation of different noise wavelength. This is really just adding an interpolation technique that is used when you access tiles in between high wavelength noise, and also adding different "octaves" that is of different wavelength and amplitude. So the number of octaves defines the number of executions of the noise function. The relation between the octaves was called persistance in a tuturial I read, but I've read conflicting uses of the word. My persistance in making a heigthmap is for example= Each octave -> amplitude / 2 and wavelength / 2. The result is high mountatins with smaller hills, and down to noised ground.
A response to your problem:
I've been thinking of using this to make vegetation also, And in this case I have thought about using a reversed persistance, that is higher amplitude on lower wavelengths. The result should be that trees are spaced apart like white noise on a tv when densely packed and over a bigger area small fluctuations of concentrations will be seen. And then it's up to you to decide how dense the forest or other flora should be.
I have no good solution on how to populate your area with trees. Im just thinking perverse thoughts about using cellular automata and some nifty rules. Like that a tile can only have so many neighbours before its tree dies, and that it needs some neighbors to come alive.
PS: Im using my heightmap to declare biome zones and then aplying varying vegetation depending on these. A climate zone is mostly a combination of height and latitude, since that would affect temperature and precipitation.