Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Color GetColorByCoordinate (float x, float y, float size, float seed) //This code generates the colors. It's really simple, Mathf.PerlinNoise(x,y) returns float (0-1) according to the "height" of x and y.
- {
- if (Mathf.PerlinNoise ((seed + x) / size, (seed + y) / size) < deepOcean) { //We take the height, and check for the apropriate layer. That's all.
- return veryDeepOceanColor; //The (seed+x) could be switched for some more complex calculation, but you can do that when assigning the seed. "/size" makes everything the right size.
- }
- if (Mathf.PerlinNoise ((seed + x) / size, (seed + y) / size) >= deepOcean && Mathf.PerlinNoise ((seed + x) / size, (seed + y) / size) < ocean) {
- return deepOceanColor;
- }
- if (Mathf.PerlinNoise ((seed + x) / size, (seed + y) / size) >= ocean && Mathf.PerlinNoise ((seed + x) / size, (seed + y) / size) < shallowWater) {
- return oceanColor;
- }
- if (Mathf.PerlinNoise ((seed + x) / size, (seed + y) / size) >= shallowWater && Mathf.PerlinNoise ((seed + x) / size, (seed + y) / size) < beach) {
- return shallowWaterColor;
- }
- if (Mathf.PerlinNoise ((seed + x) / size, (seed + y) / size) >= beach && Mathf.PerlinNoise ((seed + x) / size, (seed + y) / size) < forest) {
- return beachColor;
- }
- if (Mathf.PerlinNoise ((seed + x) / size, (seed + y) / size) >= forest && Mathf.PerlinNoise ((seed + x) / size, (seed + y) / size) < mountain) {
- return forestColor;
- }
- if (Mathf.PerlinNoise ((seed + x) / size, (seed + y) / size) >= mountain && Mathf.PerlinNoise ((seed + x) / size, (seed + y) / size) < mountainHigh) {
- return mountainColor;
- }
- if (Mathf.PerlinNoise ((seed + x) / size, (seed + y) / size) >= mountainHigh) {
- return mountainHighColor;
- }
- return Color.magenta; //The error color. If you did something wrong, you'll see magenta.
- }
Advertisement
Add Comment
Please, Sign In to add comment