LWJGL 3D Terrain
by
, October 3rd, 2012 at 12:50 AM (7511 Views)
Updated post here (performance and quality significantly improved)
A break from tradition, this time I'm not going to be posting some kind of a tutorial/tip. Rather, I'm going to post a few screen-shots of my current project, which involves 3D terrains.
The terrain is randomly generated at the beginning of the test program using multiple 2D noise functions with increasing frequency and decreasing amplitude, and then bi-linearly interpolated together into a height map. In hind-sight, this method works well for cloud textures (which is where I took the code from to begin with) but not so much for realistic looking terrain.
The color is created using a scale where high elevations move towards a purple-ish hue and lower elevations are blue.
This is also my first true plunge into OpenGL/LWJGL, and the results really show. The terrain mesh is built from a 300x300 height map, but even with such a small map the FPS is really low (~70FPS). There are several reasons for this, chief among which I suspect is because I'm not implementing any sort of Level-of-Detail scaling, rather I'm just dividing each quad into two triangles and shoving them through OpenGL. This spits out ~180k triangles each frame, which my graphics card can handle just fine but my CPU can't (at least not how I'm doing it). I'm also not really taking too much care in my OpenGL code so I end up doing a lot of calculations (for example normals) in my render loop rather than caching them.
Screenshot 1:
Screenshot 2:
More to come in the future