# Project 4: Illuminate (Algo Answers)

You can find the handout for this project here.

## Raytracing Pipeline

List at least three aspects of the fully fledged raytracing pipeline that were omitted in Intersect, but are required for Illuminate. Explain how you can use your code from Intersect to implement these components. There is not necessarily a correct answer! We are looking for a qualitative description of your approach.

There isn't a correct answer.

## Reflection Equation

Given an incoming light direction

Assuming both

**Answer:**

## Texture Coordinates

In Illuminate, you will be texture-mapping images onto your implicit shapes. One step of this process is taking a given intersection point, with *known UV coordinates*, and figuring out which pixel of the image we should use.

However, two different coordinate systems are in play here:

**Image coordinates**have their origin at the**top left**of a`width x height`

*pixel grid*. These are used for images like our Brush canvas, our Intersect output, and, most relevantly, images we use as textures.**Texture (UV) coordinates**have their origin at the**bottom left**of a*unit square*. These are used on the surfaces of our objects, as inputs to the equations you will write below.

Study the diagram below, then complete the next two questions, where you will define a mapping from UV coordinates to image coordinates.

### A Single Texture

Suppose we have an image of size

What is the pixel index

**Answer:**

Note that you'll have to check for cases where

**Explanation:**

We can think of this as a map from **continuous** UV coordinates that range in **integer** image indices that range in

- We can simply scale and floor
to obtain . - However, since UV coordinates use the bottom-left corner as their origin, while images use the top-left corner, we have to "flip"
before scaling and flooring.

### Repeated Textures

Suppose that we'd now like to repeat the texture

Now, what is the pixel index

**Answer:**

Again, you'll have to check for cases where

**Explanation:**

We can think of this as a map from **continuous** UV coordinates that range in **integer** image indices that range in

- See the previous question's answer for an explanation.
- Note that it's necessary to take the moduli of the floored indices, to get the actual pixel indices for the texture image.

## Shadow Generation

To test if some intersection point

Suppose point

**Answer:**

Conditionally, yes. If object **concave shape**, then self-shadowing is possible (i.e. one part of the object could shadow another).

**Note 1:** while it happens that none of the primitives you're using are concave, you are not obligated to optimize-out the shadow ray's intersection test with the original object.

**Note 2:** you do *not* want to detect **erroneous intersections** with the *exact point on object * from which the shadow ray starts. To avoid this problem, you must offset the starting point of the shadow ray by a small amount in the direction of the ray.

## Submission

Submit your answers to these questions to the "Algo 4: Illuminate" assignment on Gradescope. Instructions on using Gradescope are available here.