Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 27 November 2012 - 09:25 PM
Posted 27 November 2012 - 09:30 PM
Posted 27 November 2012 - 09:33 PM
“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”
Posted 27 November 2012 - 09:59 PM
Posted 27 November 2012 - 10:05 PM
Posted 27 November 2012 - 10:59 PM
Posted 28 November 2012 - 01:01 AM
http://www.youtube.com/watch?v=zHh9q_nKrbc)
Edited by MathAddict, 28 November 2012 - 01:16 AM.
Posted 28 November 2012 - 02:48 AM
Jeez, I'm an idiot.
Why not just have two squares with each holding one of the poles in its center, and laying one on the bottom of the other (ignoring the obvious deformation)?
So like, the edges of the squares would be the equator, and moving east and west would rotate the tiles on the square...
Though to be perfectly honest, at this point I'm beginning to wonder if it's possible to map this with circles.
Edited by max343, 28 November 2012 - 04:06 AM.
Posted 28 November 2012 - 04:56 AM
You can try that but it won't be a very accurate simulation of a planet.Jeez, I'm an idiot.
Why not just have two squares with each holding one of the poles in its center, and laying one on the bottom of the other (ignoring the obvious deformation)?
So like, the edges of the squares would be the equator, and moving east and west would rotate the tiles on the square...
Though to be perfectly honest, at this point I'm beginning to wonder if it's possible to map this with circles.
Posted 28 November 2012 - 06:06 AM
Posted 28 November 2012 - 07:57 AM
Posted 28 November 2012 - 11:55 AM
The provlem with making a cube UV is the wrapping mechanics of all of the edges. Also, I'd have to generate each face independently, and stitch them together, since the resulting UV shape isn't rectangular.I think the cleanest thing to do for planet-wide terrain generation in a game is to impose any mesh you want on the sphere (I would start with a cube map)...
What do mean by 3D Perlin noise? I'm completely familiar with the concept, but I'm confused as to how I would use it in this circumstance.and then use 3D noise to generate elevation.
I know this. That's why I'm having my problem. The land I'm generating looks like this. As you can see, it wraps in both the x and y direction; this may solve any confusion as to what exactly I meant by wrapping. If any of you are familiar with Java (I'm assuming so), here's the code for generating this:For example, go look at the earth's atlas. When you said that wrapping around from the south pole gets you to the north pole, that's wrong.
import java.util.Random; import java.awt.image.BufferedImage; import java.awt.image.WritableRaster; import java.io.*; import javax.imageio.ImageIO; public class Perlin { static int p = 8; static int size = (int)Math.pow(2,p)*4; //Multiply this by any power of 2 to get a good size image; you may be able to use other numbers, but I wouldn't reccomend it static int h = 0; public static void main(String[] args) throws IOException { Random rand = new Random(); BufferedImage image = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB); WritableRaster raster = image.getRaster(); int[][] height = new int[size][size]; int a = 0, b = 0, c = 0, d = 0, highest = 0, lowest = -1; for(int i = p-1; i > 0; i--){ int range = (int)Math.pow(2,i); int arraySize = size/range; int[][] current = new int[arraySize][arraySize]; for(int pointx = 0; pointx < arraySize; pointx++){ for(int pointy = 0; pointy < arraySize; pointy++){ current[pointx][pointy] = rand.nextInt(range); //Getting interpolation points; array gets more precise but less influential with each iteration } } for(int x = 0; x < size; x++){ for(int y = 0; y < size; y++){ int left = (x/range)%(size/range); //Getting corners; automatically wraps both horizontally and vertically using the modulus method int right = (x/range + 1)%(size/range); int up = (y/range)%(size/range); int down = (y/range + 1)%(size/range); a = current[left][up]; //Setting corners b = current[right][up]; c = current[left][down]; d = current[right][down]; h = (int)cosineInterpolate(cosineInterpolate(a, b, ((x%range)*1.0)/range), cosineInterpolate(c, d, ((x%range)*1.0)/range), ((y%range)*1.0)/range); //interpolates between the closest boundaries by interpolating horizontally on the top and bottom, then interpolating vertically height[x][y] += h; } } for(int x = 0; x < size; x++){ //Used to correct the contrast for(int y = 0; y < size; y++){ if(height[x][y] > highest){ highest = height[x][y]; } if(height[x][y] < lowest || lowest < 0){ lowest = height[x][y]; } } } } highest -= lowest; //Used to correct the contrast for(int x = 0; x < size; x++){ for(int y = 0; y < size; y++){ height[x][y] -= lowest; //Used to correct the contrast } } lowest -= lowest; //Used to correct the contrast for(int x = 0; x < size; x++){ for(int y = 0; y < size; y++){ int n = (int)(((height[x][y]*1.0)/highest)*255); //Correcting the contrast int[] green = {0, n, 0}; int[] blue = {0, 0, n}; int[] yellow = {n, n, 0}; if(height[x][y] > 128){ raster.setPixel(x, y, green); } else if(height[x][y] < 128){ raster.setPixel(x, y, blue); } else{ raster.setPixel(x, y, yellow); } } } File file = new File("perlinTest.png"); ImageIO.write(image, "png", file); } public static double cosineInterpolate(double a, double b, double x){ //Interpolates between the two specified points at a fraction x from 0-1 double ft = x * Math.PI; double f = (1 - Math.cos(ft)) * 0.5; return a*(1-f) + b*f; } }
Edited by Selenaut, 28 November 2012 - 11:56 AM.
Posted 28 November 2012 - 12:54 PM
for (j=0; j<HEIGHT; ++j) { for (i=0; i<WIDTH; ++i) { longitude = 2*pi*(i/WIDTH-0.5); latitude = pi*(j/HEIGHT-0.5); x = sin(latitude)*cos(longitude); y = sin(latitude)*sin(longitude); z = cos(latitude); elevation[j][i] = perlin_3D_noise(x, y, z); } }
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.