CS 315 Homework 5 - The Great Outdoors

Due Date: Sun Nov 10 at 11:59pm
Ongoing deliverables are required; see below

Overview

For this assignment, you'll be taking what you've learned about OpenGL modeling and adding further rendering techniques in order to build a simple animated scene. The focus of this assignment is on lighting and texturing, but in order to see the effects properly you'll also be working with bigger, more complex models---such as the models you might find available online or construct through a 3D-modeling application like Blender.

Because many computer scientists (and professors of computer science) spend far too much time inside, your program should render an animated image of an outdoor scene. For example, maybe your scene shows a pleasant farm, cheerful camping on a moutain, or joyous boats in a harbor. It can have happy little clouds and happy little trees. Most any idea is fine--this is another chance to be creative! (If you're unsure or want to confirm that you're not thinking too big, check in with me). Your one restriction will be the memory and processing speed available on your phone/emulator (so smaller, less complex models can be better).

In the end, your scene should include:

  1. An animated light source (e.g., the sun) that changes position/direction over time
  2. A different appearance during "day" and "night"
  3. At least one (1) object loaded from a mesh file (using some mesh OTHER than the ones provided)
  4. At leas one (1) object that moves in some way (animation)
  5. At least three (3) objects (different models) shaded according to the Phong reflectance model
  6. At least one (1) object that has been textured
  7. At least one (1) object that uses an advanced mapping technique: bump mapping OR environmental mapping
    • Note that this portion of the assignment has been reduced in scope and weight, but includes further changes for extra credit.

This assignment should be completed individually. You are encouraged to discuss high-level issues with other students, but your code must be your own. We will also be going over pieces of this assignment in class as examples--you are welcome to use and adapt that code for your assignment.

Objectives

Necessary Files

You will need to download and extract a copy of the starter code for this assignment. This project includes a basic GLES program to get you started--if you run the program you should be able to see the teapot spinning on the screen!

Be sure and read through the starter code. It includes some changes from the previous code:

And of course, the zip file also contains a README.txt file that you will need to fill out. DO FILL THIS OUT.

Platform Options

As an experiment in order to ease the development process for people who are still struggling with the Android emulator, for this assignment you are welcome to develop in an alternate platform: in particular, using WebGL. WebGL is OpenGL ES for the web browser--it's exactly like what we're doing, but loading in an HTML5 Canvas rather than an Android View. See here for details.

Development Schedule

This assignment can be divided into a few different parts, described below. Each part corresponds to a topic we will be covering in class over the next week. I have included "due dates" for each part--these deadline will help to break up the assignment into more smaller parts (though each part builds on the first).

By each deadline, you will be asked to upload your working code that demonstrates that you have reached that milestone. I will try and "spot check" this code as time allows--if you want me to be sure and check your progress at a deadline, let me know.

The deadlines are at midnight on the following days:

Part 1: Modeling & Animation

Part 1 of this assignment should be primarily review: you will be working with models and the simple shaders already provided in order to create a simple animation. There are a few new details, but understanding them simply involves understanding the starting code

Note that this Part of the assignment effectively covers requirements 1-4 of your final scene. That may seem like a lot, but that's because much of it is provided for you!

Modeling the Scene & Loading a Mesh

The first step of this part involves being able to load and render a new triangle mesh.

The Sun

Once you have a model loaded and your scene is beginning to take shape, you should add in functionality to model the sun moving across the sky in your outdoor scene. The actual model of the sun isn't important--it can easily be off-camera (who wants to look at the sun anyway?), or simply a yellow sphere or even a very large point. What is important is that your light source moves in a circular arc around your scene.

As we will disuss in more detail through lecture, we often think of light as coming from a particular location--from a light source (like a lightbulb). Thus we can think of light as coming from a particular position, and often having a particular direction (think like a spotlight). In the second part of the assignment you will be implementing a more complicated illumination model, but for now we'll just focus on the position of the light and making that change over time--the direction of the light will be from the light's position to each of our vertices.

The Night Sky

Because your sun moves, you should be able to differentiate between day and night. That is, half the time there should be a sun (at a roving position in the sky), and half the time the scene should be "at night". At night, the sun should not be visible (and should not be lighting things!), but you should be able to see at stars (at least 4).

Animation Controls

In order to ease testing and grading, you should provide an interaction mechanism to both control the movement of the sun and whether it is day or night. A button that toggles day and night and a button that starts and stops the sun would be sufficient, though slides/etc. are of course welcome.


Having done these four things you should be well on your way to having a nice animated scene! Feel free to add more models (ideally in a format that makes them easy to comment out for testing), and add some animations to the models if you want your cows to wander over the farm or whatever.

Remember that Part 1 of this assignment is "due" Wed 10/30 at midnight.

Part 2: Lighting

In Part 2 of this assignment you will apply more complex lighting to your scene. You will be modifying or writing new shaders in order to effectively shade and render the objects in your scene. The part covers requirement 5 of your final scene.

Your program should implement the Phong Reflectance Model of illumination, applying this lighting to three separate "objects" in your scene. This model should include ambient, diffuse, and specular components. Note that it is okay to have 0 ambient light if you have enough light sources to suffice, such as through three-point lighting.

Your scene only needs to include one light source (the sun, which should be a point light), but you are welcome to include more. In particular, adding point lights or spot lights (with finite distance) could make for a compelling night scene!

Again, your scene should have different lighting models for day and for night. You can achieve this by using a separate shader for each, or by sending in a uniform variable (a bool?) to act as a "switch" in your single shader.

Finally, you are welcome to adapt the demo code from lecture. Your program should use Phong (per pixel) shading rather than Gouraud (per vertex) shading for at least one object.

Part 3: Texturing

In Part 3 of this assignment you will add textures to at least one (1) of your objects. Note that this will need to be a different object than you applied Phong lighting to (even though it is possible to combine the two techniques)--you will need to have at least one object that is lit without being textured.

I highly recommend you modify the ModelFactory to specify texture coordinates for the cube; this will help you test if your texture loading and shading code works.

If you wish to apply textures to one of your loaded meshes (and I expect you will), you'll need to make a couple of further changes:

Part 4: Advanced Texturing

In the final part of the assignment, you will be adding a more "complicated" lighting or texturing effect to one of the objects in your scene. There are a couple of different options for you:

Bump Mapping

You can texture an object using a Bump Map (normal map), rather than calculating the normals based on the geometry. This will allow you to add more detail "textures" (in the tactile sense) to objects without needing to increase the complexity of your model. For example, maybe you create an embossed cube, or a bumpy sphere, a watery quad, or some other effect.

Environmental Mapping

You can also texture an object with an environmental cube mapping, so that it looks like it is "reflecting" the environment.

Shadow Mapping (Optional! Extra Credit!)

Finally, fulfilling the requirements both of this part of the assignment and earning extra credit, you can implement shadow mapping for one or more objects. This will require doing a two-pass rendering--you'll need to render the scene using the light source as the eye, rendering the depth to a texture. You can then use this depth to calculate whether a fragment is in shadow or not.

We will discuss this algorithm from a high level in class, but you are welcome to try and implement it for this assignment. I recommend you start here, but there may be other resources to use as well (if you find any that are good, let me know!)

Extensions

There are numerous extensions for this assignment described sporatically above. The most prominent chance for extra credit involves creating changes or utilities that can help the rest of the class. For example, if you come up with a way to convert quads to triangles and share that with me so I can distribute it to the class, you can earn extra points. You get rewarded for helping others!

Adding further detail to your scene and rending can also lead to some extra credit--for example, processing material files, implementing a BRDF, adding special effects (fog, fire, etc), or even just making a complicated scene animation.

Adding extra interaction (e.g., the ability to move around the scene in a first-person view, push objects around, etc) would also be worth something. The possibilities are endless!

Submitting

BEFORE YOU SUBMIT: make sure your code is fully functional, but also documented and readable. Again, grading will be based primarily on functionality. I cannot promise that I can find any errors in your code that keep it from running, so make sure it works. But I will look over your code to check your implementation, so please make sure that is readable :)

Upload your entire project (including all the src, resources, layouts, libraries, etc) to the Hwk5 submission folder on hedwig. Also include a filled-in copy of the README.txt file in your project directory!

The homework is due at midnight on Sun, Nov 10.

Grading

This assignment will be graded based on approximately the following criteria: