opengl代写: CS3388 – Assignment 4

CS3388 – Assignment 4, 2016

Posted: 17th November 2016 Due: 7th December 2016, 11:55 PM

Description

This assignment consists of the writing of a simple non-recursive ray-tracing program using OpenGL and C/C++ that creates an image of a scene containing a number of simple generic objects. The assignment is worth 10% of the final mark.

We intend to build a ray tracer application where the scene will contain at least three spheres of different sizes and colours on a plane. There will be ambient, diffuse and specular lights in the scene. The light will have specular reflection effect on the surface of the sphere(s). Also, the spheres will cast shad- ows on the floor and on each other’s surface (depending on the light position). Finally, the spheres (or balls) will bounce on the floor.

Following are the step by step instruction to build the ray tracer:

  • Define three generic spheres with different radius and simple color at- tributes.
  • Place a synthetic camera at a convenient distance from the spheres so that all the spheres are clearly visible.
  • Code and test the ray casting algorithm (cast the rays and compute in- tersection points, and normal vectors). Without shading, the ray tracer should render what would look like three circles of different colours within the rendering window.
  • Once this is working, add a white light source, and implement the diffuse lighting component. The 3D shape of the sphere should become visible, however no specular reflection will show on the sphere.
  • Place a plane to create a ground surface, and render it. At this point the scene should start to look more or less realistic.
  • Implement specular reflection and see that you get a bright spot on the sphere consonant with the position of the light.
  • At this point, the spheres do not cast shadow on the ground plane and on each other’s surface. Implement shadow ray casting to create that effect. Place the spheres at convenient distance from each other so that

    1

the shadow on their surface is clearly visible. However, the shadow area will appear completely black. You can use the ambient part of the lighting model to resolve this problem (there will be some marks for aesthetic part of the rendering).

• Animate the scene by bouncing the balls on the plane. The shadows should change accordingly.

The scene should look something like this:

There is a bonus mark of 1% of the total course grade, if you can implement reflection effect on the surface of the spheres.

What to submit?

Submit the program file(s) you have implemented. Put all the file(s) into a zip and submit via OWL (no files will be accepted by email). Please don’t submit any unnecessary files (such as the whole project).

Late penalty

The late policy is a penalty of 5% per day up to 3 days of lateness. Saturday and Sunday count as one penalty day.

2

Plagiarism

Copying the code is a serious academic offence, which will be treated as per university norms. Remind that changing variable names and white spaces do not make your code unique, it’s very easy to detect these cases using software.

General marking scheme

The marks will be distributed as follows: • Working program: 70%

– (will be divided into different parts of the assignment) • Documentation: 10%

  • –  Main comment block identifying the student (name, email, date, pur- pose of the program): 4%
  • –  Defining input and output parameters for a function: 3%
  • –  Purpose of functions/blocks of code: 3%

    • Program style: 10%

    – Meaningful variable names: 3%
    – Constants instead “magic numbers”: 2%
    – Readability (complete sentences, indentation, white spaces, etc): 2% – Code flows “nicely”: 3%

    • Program structure: 10%

    – Modular code: 4%
    – Uses appropriate data structure: 3%
    – Loops when needed/no loops when not needed: 3%

3