Monday, October 14, 2019

opengl - Procedural Planets, Heightmaps and Textures


I am currently working on an OpenGL procedural planet generator. I hope to use it for a space RPG, that will not allow players to go down to the surface of a planet so I have ignored anything ROAM related. At the moment I am drawing a cube with VBOs and mapping onto a sphere.


I am familiar with most fractal heightmap generating techniques and have already implemented my own version of midpoint displacement (not that useful in this case I know).


My question is, what is the best way to procedurally generate the heightmap. I have looked at libnoise which allows me to make tilable heightmaps/textures, but as far as I can see I would need to generate a net like this.


Leaving the tiling obvious.


Could anyone advise me on the best route to take?


Any input would be much appreciated.




Answer



First of all, I'm not sure why you want to implement a height map (i.e. geometry displacement) if people won't be able to land, it just seems more efficient to normal map it or something.


With that said, what you want is to convert from an arbitrary (x, y, z) to a (u, v) coordinate, which is trivial. No cubemap needed.


alt text


alt text



  1. Every (u, v) texel has a height (heightmap RGB = height) and a position (x, y, z) = pos.

  2. Find and normalize the position, NORMAL(x, y, z) = N.

  3. New vertex = pos+N*height.



This will work better with a higher tessellation. Also use the proper libnoise spherical mapping for your heightmap, which will look something like this (but black and white):


alt text


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...