计算机图形学代写: COMP 3801 Written Assignment 5

COMP 3801 Winter 2018

Written Assignment 5

Show how you arrive at each answer to receive partial credit for incorrect answers.

Submitting Your Assignment (see Canvas for due date/time)

All submissions must be online, through Canvas, as a PDF file. If you use Microsoft Word to write your answers (recommended), use “Save As…” and save as file type PDF. If you use Google Docs (also a good solution), use “Download as PDF Document”. Other software which generates a PDF file is also fine to use.

If you hand-write your answers, you are responsible for readability. The recommended method is to scan using one of the scanners in the library (or your own scanner), at 300 dpi or higher. If you must use your cell phone camera (not recommended), get the free Microsoft Office Lens App (iOS and Android). This app will correct perspective and adjust exposure for better readability.

Name:                                                                                                                                                                                           

 

1.   Texture Mapping

A fragment shader fetches the texture value at texture coordinates (0.5, 1.5). Describe in a brief phrase the location on the texture image (top, bottom, left, right, center, etc.) that will be sampled:

  1. If GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T are both set to GL_CLAMP_TO_EDGE.   [6 points]
  2. If GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T are both set to GL_REPEAT. [6 points]

Briefly describe under what circumstances WebGL uses the:

  1. GL_TEXTURE_MIN_FILTER [6 points]
  2. GL_TEXTURE_MAG_FILTER [6 points]
  3. For case c) above, describe the differences you would expect to see in the images generated by WebGL between the use of GL_NEAREST and GL_LINEAR_MIPMAP_LINEAR [7 points]
  4. For case d) above, describe the differences you would expect to see in the images generated by WebGL between the use of GL_NEAREST and GL_LINEAR [7 points]
  5. If your program does lighting calculations in addition to texture mapping, how would you most commonly incorporate an image texture map into the lighting calculations (just the general concept, not the details)? [6 points]

 

 

 

 

 

 

 

 

 

 

  1. Briefly describe how a bump map generates the illusion of a textured surface (just the general concept, not the details). [6 points]

 

 

 

 

2.   Depth, Blending, and Hidden Surfaces

  1. Partial fragment shader code is supplied below. Write the rest of the shader code to apply fog of RGB color (0.5, 0.6, 0.9) to the input color fColor based on a linear function of depth z (varies from 0.0 to 1.0), and set the output fragment color to the result (using the original alpha value from fColor). There should be no fog at depth 0.0, and complete fog at distance 1.0. [10 points]

varying vec4 fColor; // input color

void main() {        // enter your code below this line, with closing }

 

 

 

 

 

 

 

  1. Consider a perspective projection with near = 2.0 and far = 15.0, and four points with z values in viewing coordinates equal to , , and . After perspective projection and perspective division, what is the general relation between the distance  and the distance
    (where each  is the value of  after projection and perspective division)? Is  equal to, less than, or greater than ? What are the practical considerations in the choices of near and far for writing a WebGL program when using the Z-buffer with a perspective projection?                                                                                                        [10 points]

 

 

 

 

 

 

  1. For the same points and the same near and far values from part (b), but using an orthogonal projection, what is the general relation between the distance and the distance   (where each  is the value of  after orthogonal projection)? Is  equal to, less than, or greater than ? What are the practical considerations in the choices of near and far for writing a WebGL program when using the Z-buffer with an orthogonal projection? What effects, if any, are the same or different from the perspective projection?                                                                                                             [10 Points]

 

 

 

 

 

 

 

 

 

 

  1. Give a brief explanation of how back-face culling can speed up the rendering process, including details of which parts of the rendering process can be bypassed for back-facing triangles. [10 points]

 

 

 

 

 

 

 

 

 

 

 

 

  1. Give an example of an object or type of object for which back-face culling can be used, and an example of a different object or type of object for which back-face culling cannot be used. Give a brief explanation for each of your choices. [10 points]