COMP3170 Assignment 3
Objectives
This assignment covers the following topics:
• 3D modelling with triangular meshes
• 3D Transformations
• Perspective cameras
• Illumination and shading
• Texturing
• Transparency
Your task is to build a simple 3D world using height-mapped terrain, with water and lighting
effects like this.
Framework
A basic framework for the assignment is available via GitHub classroom:
https://classroom.github.com/a/p3fFYFbF
Level files
The assignment framework includes a class that loads a level definition from a JSON file.
This file includes the following data:
level.json – an example level
{
"name" : "Island”,
"map" : {
"width" : 11,
"depth" : 11,
"height" : [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0,
0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,
0, 1, 0, 1, 2, 2, 2, 1, 0, 1, 0,
0, 1, 0, 1, 3, 3, 3, 1, 0, 1, 0,
0, 1, 0, 1, 4, 4, 4, 1, 0, 1, 0,
0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0,
0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]
},
"waterHeight" : 2,
}
This defines height map, consisting of a 11x11 grid of points with different heights, with
water covering everything up to height 2.
The resulting scene would look like this:
(Note this doesn’t include texturing or ripple effects described later)
A simple framework has been provided to read these files Java objects. Your assignment
should support this basic level format, and render any level that meets this spec.
Scene features
Your mark will be based on the features you implement, from the list below. Each feature
has a mark value attached. Completing more than 100% worth of features will not earn
additional marks.
Feature Marks
Terrain
- Heightmap mesh generation
- Diffuse & ambient lighting
(smooth fragment lighting)
- Texturing (one texture)
- Texture blending with terrain height
40%
20%
10%
5%
Water
- Diffuse & ambient lighting
- Transparency
- Specular lighting
- Ripple effect
5%
5%
10%
5%
Camera
- Fly through camera 5%
Light
- Animated sun 5%
General requirements
Your scene should be implemented using:
1) Anti-aliasing using 4x supersampling.
2) Backface culling
3) Mipmaps for all textures (with trilinear filtering)
4) Gamma correction (with a default gamma of 2.2)
Terrain
Height map mesh generation: 40%
Use the height-map data provided to generate a 3D mesh. The mesh should consist of width
by depth points (for the values specified in the level file) spaced in a grid in the x/z axes. The
y-coordinate of each point is given by the corresponding value in the height array. These
points should be joined into a mesh of triangles. So, a 20 by 20 height map will have 19x19
squares each represented with two triangles, as shown below.
Diffuse & ambient lighting: 20%
You should provide a terrain shader that implements diffuse and ambient lighting with the
following specs:
- Smooth Phong shading (i.e. in the fragment shader)
- Appropriate vertex normals computed by interpolating the face normals of
surrounding triangles
- Point light source determined by the position of the sun in the scene.
Texturing: 10%
The terrain shader should use a texture to determine the diffuse reflection coefficient of the
terrain. The texture should be tiled so each 1x1 square of the terrain contains 1 repetition of
the texture. Some appropriate textures are provided in the assignment framework, or you
can use a texture of your own choosing, as long as you have a license to use and distribute
it. Sources for all third-party assets should be documented in your report.
Textures should use mipmaps and trilinear filtering. Gamma correction should be applied
(with a default gamma of 2.2).
Texture-blending: 10%
Multiple textures (e.g. grass and rock) are used at different terrain heights (at your
discretion), with appropriate blending where they meet. (E.g. underwater terrain could use
a sand texture while above water is textured with grass).
Water
The water should be a single rectangle with width (x) and depth (z) dimensions to cover the
entire terrain. It should sit at the height specified by the ‘waterDepth’ property in the level
file. You should provide a specialised water shader to colour this.
Diffuse & ambient lighting: 5%
The water shader should implement ambient and diffuse lighting.
Transparency: 5%
The water should be semi-transparent showing the terrain below.
Specular lighting: 5%
The water shader should also implement smooth specular lighting, reflecting the light