Project 6: Action! (Algo Answers)

You can find the handout for this project here.

Camera Rotation

How would you compute the matrix for a rotation of 90 degrees about the axis ? Hint: look at this lecture for a reminder on how to rotate about arbitrary axes.

Answer:

Explanation:

Recall Rodrigues' formula for an angle rotated about a normalized axis is:

Shader Uniforms

Given a texture object of m_tex1 and a shader object m_shader, please write pseudocode to set m_tex1 to be set to a uniform variable declared as uniform sampler2D texture1 contained in m_shader's source code. Assume nothing about the current state!

Answer:

Optional for setting uniform but required for drawing:

set active texture to GL_TEXTURE0

bind m_tex1 to target GL_TEXTURE_2D

Required to set uniform and for drawing:

store the location of texture1 from m_shader in a variable

set a single integer uniform at location found above to be set to 0

Explanation:

If we assume nothing about the state and wish to draw, we must both bind the texture to texture slot: GL_TEXTUREn and set the sampler2D uniform to an integer value of n.

Textures, Renderbuffers, Framebuffers Oh My!

Concept

For a framebuffer with color and depth attachments, please draw a schematic/diagram of the framebuffer indicating which attachments are textures and which are renderbuffers and why. Assume the usage of the framebuffer will be to draw a scene with a grayscale filter applied.

Answer:

TODO
Figure 1: FBOAttachments

Explanation:

A texture was choosen for the color buffer since we have to specifically sample from it in order to apply our grayscale filter. A renderbuffer was choosen for the depth buffer since we don't need to sample from it, therefore it is more optimal to only use a renderbuffer to store the depth attachment.

Functional Understanding

glTexImage2D

What is the difference between internal format and format in the call glTexImage2D?

Answer:

Internal format represents the format we wish to hold in our newly created texture. Format specifies what the format is of the input pixels if any so that OpenGL can read them in properly. For creating a texture in an FBO, the format parameter doesn't matter since we pass in a nullptr for the pixel data, but for a texture such as m_kitten_texture in the lab, we must specify this in order to read in the QImage properly.

glTexParameteri

What is the difference between using GL_NEAREST and GL_LINEAR when setting magnification and minification filters in glTexParameteri?

Answer:

GL_NEAREST when sampling between pixels will not compute any blending and choose a discrete pixel to sample from at any point. As the name implies it picks the nearest pixel to use for data. GL_LINEAR on the other hand uses linear interpolation when sampling between pixels in order to pick an output color.

Realtime vs. Ray

Recursive Reflections

Why do you think we are not implementing recursive reflections in this assignment? This question is open-ended; any well-thought-out answer will suffice.

Answer:

Recursive reflections require us to know scene data in order to shoot out rays recursively. However once we render once, we only have a 2D image to reference and it is impossible to do true reflection since we don't have this data. There are some common methods of imitating reflection such as "screen-space reflections", but as the name implies, you can only reflect what you see on the screen. So for example if there was one sphere on screen and one to the right offscreen, it would not be able to reflect the offscreen sphere onto the on screen sphere since that data was lost.

Differences

Apart from recursive reflections, what are the advantages to using offline rendering as opposed to realtime rendering? What are the advantages to using realtime rendering as opposed to offline? This question is open-ended; any well-thought-out answer will suffice.

Explanation:

Raytracing allows us to simulate physical lighting effects in a much simpler way such as soft shadows. Many computations are actually easier to understand conceptually from a raytracing perspective as well such as shadows (vs shadow mapping) and how different BSDFs behave.

On the other hand, realtime rendering at the moment is much more performant and allows us to use parallelization without even having to work for it!

Submission

Submit your answers to these questions to the "Algo 6: Action!" assignment on Gradescope. Instructions on using Gradescope are available here.