Difference between revisions of "Project6SP15"
(→Project 6: Global Warming) |
(→1. Terrain) |
||
Line 23: | Line 23: | ||
* Load the height map image and store the elevation data in an unsigned char array of size 1024*1024. | * Load the height map image and store the elevation data in an unsigned char array of size 1024*1024. | ||
− | * Create a 1024*1024 array of vertex coordinates (Vector3). Populate the array as follows: the x values should correspond to the array's x index, the y values to the y index. For example: Vector3[x][y].x = x, Vector3[x][y].y = y. The z value should be the corresponding value from the height map array (Vector3[x][y].z = heightmap[x][y]) | + | * Create a 1024*1024 array of vertex coordinates (Vector3). Populate the array as follows: the x values should correspond to the array's x index, the y values to the y index. For example: Vector3[x][y].x = x, Vector3[x][y].y = y. The z value should be the corresponding value from the height map array (Vector3[x][y].z = heightmap[x][y]). |
* To render the height map, create a triangle mesh with 1023*1023*2 triangles, using the vertex array created above. Make yourself familiar with [http://en.wikipedia.org/wiki/Triangle_strip triangle strips] and use them to create the triangle mesh - this way it will render much faster than separate triangles. | * To render the height map, create a triangle mesh with 1023*1023*2 triangles, using the vertex array created above. Make yourself familiar with [http://en.wikipedia.org/wiki/Triangle_strip triangle strips] and use them to create the triangle mesh - this way it will render much faster than separate triangles. | ||
* For the vertex colors, use the same gray values as in the PPM file with the height map. We will add color later. | * For the vertex colors, use the same gray values as in the PPM file with the height map. We will add color later. | ||
Line 30: | Line 30: | ||
'''Notes:''' | '''Notes:''' | ||
* [http://www.chadvernon.com/blog/resources/directx9/terrain-generation-with-a-heightmap/ The tutorial at this link] may be helpful for this part of the project. | * [http://www.chadvernon.com/blog/resources/directx9/terrain-generation-with-a-heightmap/ The tutorial at this link] may be helpful for this part of the project. | ||
+ | * The description above uses a "z up" coordinate system - feel free to use a "y up" coordinate system instead. | ||
+ | * Feel free to scale each of the coordinate axes to a range more convenient for you. It may be useful to center the x/y values around the origin; or decide on a physical unit for the vertex coordinates, for instance feet or meters, so that you can display the terrain elevation at the correct height in relation to distances on the ground. | ||
+ | |||
+ | ==2. Water Level== | ||
+ | |||
+ | Now it is time to increase the water level. We simplify the effect of the increasing sea level by assuming that the water reaches every point on the terrain which is lower than the new water level (i.e., mountain ranges won't block the water). In computer graphics terms, all vertex elevations below the new water level are set to match the new water level. We ignore the | ||
<!-- | <!-- |
Revision as of 22:02, 8 May 2015
Project 6: Global Warming
In this project you will need to render a terrain with GLSL shader programs.
This project is due on Friday, May 15th, 2015 at 1:00pm. You need to present your results in the CSE basement labs as usual, grading starts at 12:15pm. Please upload your source code including your shaders to the Ted system by 1pm. You do not need to upload any binaries, including textures, 3D models, etc.
The discussion for this project will be on Monday, May 11th in CSB 002 (note the room change due to construction).
The total score for this project is 100 points, plus 10 for extra credit.
It is widely believed that as a consequence of Global Warming the sea level is going to rise. San Diego has many low lying areas, which would get severely affected even with a moderate increase of the sea level. There are web apps such as this one, which can give you an idea of which areas will be affected, but they are not as interactive as they could be.
The goal of this project is to create a highly interactive 3D visualization tool to show the effects of different water levels on San Diego. You will have to load and render a height map and allow the user to change the water level in real-time.
1. Terrain
In the first step you need to generate and display a 3D mesh out of this 2D height map image of San Diego. The image has a resolution of 1024*1024 pixels and covers an area of about 37*37 miles (60*60 kilometers). The image is in PPM format so that you can read it with your PPM reader from Project 5. The information in the red, green and blue channels is identical for each pixel - you can interpret any one of them as elevation. A gray value of zero translates to an elevation of zero (sea level), a value of 255 translates to an elevation of about 3,500 feet (1,000 meters).
For this project we recommend that you start with your code from project 6 and implement the terrain as a scene graph node. You will not need any of the 3D models from the previous projects. Feel free to keep the sky box - everything looks better with a sky box. You will need your mouse and keyboard routines to rotate, translate and scale the object space.
The steps to generate the height map are as follows:
- Load the height map image and store the elevation data in an unsigned char array of size 1024*1024.
- Create a 1024*1024 array of vertex coordinates (Vector3). Populate the array as follows: the x values should correspond to the array's x index, the y values to the y index. For example: Vector3[x][y].x = x, Vector3[x][y].y = y. The z value should be the corresponding value from the height map array (Vector3[x][y].z = heightmap[x][y]).
- To render the height map, create a triangle mesh with 1023*1023*2 triangles, using the vertex array created above. Make yourself familiar with triangle strips and use them to create the triangle mesh - this way it will render much faster than separate triangles.
- For the vertex colors, use the same gray values as in the PPM file with the height map. We will add color later.
- Support your mouse or keyboard commands to rotate, translate and scale the terrain.
Notes:
- The tutorial at this link may be helpful for this part of the project.
- The description above uses a "z up" coordinate system - feel free to use a "y up" coordinate system instead.
- Feel free to scale each of the coordinate axes to a range more convenient for you. It may be useful to center the x/y values around the origin; or decide on a physical unit for the vertex coordinates, for instance feet or meters, so that you can display the terrain elevation at the correct height in relation to distances on the ground.
2. Water Level
Now it is time to increase the water level. We simplify the effect of the increasing sea level by assuming that the water reaches every point on the terrain which is lower than the new water level (i.e., mountain ranges won't block the water). In computer graphics terms, all vertex elevations below the new water level are set to match the new water level. We ignore the