3D Noob

Started by
7 comments, last by FVIRTMAN 18 years, 11 months ago
Programing Lang: Java using LWJGL for OpenGL Im extremely new to 3D, ive been playing around for a little while and figured its time to actually start learning. So here is my first question. Say i want to create a terrain with hills and humps etc etc id assume id create the terrain using triangles. I've heard of a height map and read tutorials, but i still really have no idea what a height map actually looks like (i mean is it a file containing y co-ordinates for every vertex?) and how to contruct one. Another question is how do i make a sky lol? Thanks in advance, Nick
Advertisement
A height map basically is an image of your surface(terrain) from the top view. Each pixel encodes the height of your surface as a color. lets say between 0 and 255. You break your terrain/surface down into say a 64x64 'section' surface and encode each section's height into a number (0-255). now if you were to visiually represent these numbers as an image, it'll pretty much look like the top view of your surface as a greyscale (0-255) gradient. Hope that helped.
-pr06z3r
Thank you that definately help my understanding. But say my terrain is massive, would that mean creating many height maps??
Quote:Original post by NickyP101
Thank you that definately help my understanding. But say my terrain is massive, would that mean creating many height maps??


Depends, you could create a bunch of small heightmaps that you can tile together in such a way that you are reusing the same height maps multiple times. Heightmaps are rather easy to work with visually because you can look at a hightmap with an image editor and get a very good idea of what it's going to look like rendered.
You'll only ever need 1 reference to your heightmap, regardless of how big it is. The only thing you'll need to consider is exactly how much of it you want to draw, and at what quality (the last thing you want to do is start rendering a 10240x10240 point terrain (209715200 triangles (~210M))). You might want to take a look at quadtrees or octrees to see how to split the heightmap up so rendering doesn't take forever.
Sounds Good :)

So is every pixel in the height map a point on a triangle?
Quote:Original post by NickyP101
Sounds Good :)

So is every pixel in the height map a point on a triangle?


yep. Each pixel is going to represent one vertex. Keep in mind that you are going to probably want to scale off the heightmap.

in the heightmap.. the pixel's X will become the vertex's x, the pixel's y becomes the vertex's Z and the color becomes the vertex's Y. You will want to scale the vertex for the X and Z the same for each and scale by an even greater value for the Y value. That way it will have a nice gradient.
Ok im beginning to understand much better now, has anyone got an example of height mapping?
I don't have a code to give.
But you can easyly draw a Heigmap with Paint. A simple BMP can be enought.
Even for a big terran, you don't need a large BMP : I suggest you to put large dimensions between each quad :
(1 quad is defined by 4 pixels on the BMP, the neighbour quad has 2 common pixels).
You will say : yes, but I will see big quads !!
--> You can draw, on the near quads, a Bezier-Patch instead of a quads, than can be controlled by a LOD (level of detail) :
the next quads will be rounded and curved, and the far will be quads.
There is also many optimisation to put with heightmapping.
- level of details with bezier patchs are the first
- clipping is needed
- frustrum culling : you don't need to draw the quads which are behind your camera
- hidden faces : if you are front of a moutain, you don't need to compute the quads which are in the other slope : a simple dot product is enought to know if a quads is hidden or not.

(sorry for my bad english)

This topic is closed to new replies.

Advertisement