PDA

View Full Version : Need advice - 2d height map terrain with relief shading

Javac
12-02-2003, 12:40 AM
Hi.
I'd like to create 2d height map terrains with relief shading effects(actually 2d image with 3d look - 2d because of no projection),each pixel in image represents an information of height in this coordinate).
I have 2 problems:
1. I don't know how to do it with OpenGL.
(and if should I do this with OpenGL?)
2. I don't know what is the light calculation formula(for color of each pixel) for this kind of pictures.
I did it first without OpenGL and used the usuall diffuse lighting formula ,but picture looks bad.
I found in Google a lot of tools for creating
relief shaded terrains,but they all are connected to 3d max or photoshop,but I need to do this in runtime with code.

So,please - anybody has an idea or experience on this?

Machiavelli
12-02-2003, 09:37 AM
This question seems a tad bit inappropriate for an advanced OpenGL forum...

Make sure you enable lighting and place a GL_LIGHT at some point like (100,100,100). This position will give you a 'sun-angle' with the sun to the northeast at 45 degrees above the horizon.

Set glColor3ub(128,128,128) for a light grey.

Starting at the southwest corner, cycle through your heightmap array and simply draw triangle strips for each 2 rows of points.

Remember that figuring out some of this stuff on your own is 95% of the fun. My advice is to resort to posting a question only during those times when your forehead is already quite bruised.

Good luck...
-Mike

Javac
12-21-2003, 07:09 AM
Actually my "forehead wasn't bruised" but I didn't have a time.Sorry if this question was too inappropriate ,but in beginners desk nobody had an answer,so I tried it here.
I found that the correct light position is north-west for terrains.It looks
really great.
My problem really was and still is - how to make height map that looks 3D (to get an 3d effect) and then to draw it in 2d space.