Assignment 5: Combined Camera + Lighting
- Due Nov 14, 2018 by 11:59pm
- Points 10
- Submitting a file upload
Objectives
Camera movement, perspective, lighting
Description
Create a very basic world consisting of a ground plane and a couple objects sitting around. Probably the easiest is use your existing cube object and scale/translate it to make the ground, then put a couple colored cubes sitting on it.
Implement camera motion with a perspective camera. You will need to modify your vertex shader to something like
glPos = ProjectionMatrix * ViewMatrix * ModelMatrix * a_position;
You will need to set the ProjectionMatrix using setPerspective which is defined in the matrix utility class. This only needs to be done once.
You will need to set the ViewMatrix using setLookAt which is also defined in the matrix utility class. This will need to update whenever you move your camera.
ModelMatrix is the matrix attached to each Geometry which specifies its location (and animation if such exists).
I recommend to use ASDW key controls for driving your camera around and JL for turning the direction of your camera. But you could choose any controls you like as long as the camera can be moved to look around your world.
Implement lighting in the fragment shader. You will need to pass normal vectors as an attribute with each vertex.Then you will have to pass them in a 'varying' variable to the fragment shader. You can use a constant light direction hard coded in your shader if you like. The hardest thing to get right is the coordinate spaces of the lighting direction (usually world coordinate) and the normal vectors (also needs to be world coordinates, but often defined originally in object coordinates).
Resources
Readings: Matsuda/Lea Ch7 and Ch8
Rubric
Criteria | Ratings | Pts | ||
---|---|---|---|---|
World Exists with at least a ground plane.
threshold:
pts
|
|
pts
--
|
||
A couple of objects are in the world so we can tell we are driving the camera around.
threshold:
pts
|
|
pts
--
|
||
It is possible to move the camera. i.e. the location of the camera EYE point moves around the ground plane.
threshold:
pts
|
|
pts
--
|
||
It is possible to rotate the camera
The EYE position doesnt move, only the AT direction changes.
threshold:
pts
|
|
pts
--
|
||
Lighting is implemented in the Fragment Shader
threshold:
pts
|
|
pts
--
|
||
Total Points:
25
out of 25
|