Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

View RSS Feed

helloworld922

LWJGL 3D Terrain

Rate this Entry
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

Updated October 3rd, 2012 at 05:12 PM by helloworld922

Categories
Uncategorized

Comments