Quiz
- Can you explain more about how NDC coordinates relate to canvas coordinates, and relatedly, unprojection? Thank you!
For sure! Once we get to NDC, the transformation to the canvas is just (1) squeeze out the Z dimension (we'll talk more about that next time, in the context of transparency), and (2) map [-1,+1] to [0,canvasWidth], which is just a linear mapping:
canvasX = (ndcX + 1)/2 * canvasWidth
and similarly for canvasY
Going the opposite way (from canvas to NDC) is just a bit of algebra.
But it sounds like I should do a better explanation in the reading.
- in order for things to make sense, should we always set the destination (target) of raycasting to the point where the camera is looking at? will that make the the most sense for a viewer trying to interact with the objects they see?
No, I think I misled you. When we use raycasting for picking, the origin of the ray is (typically) the camera location (the EYE), because that's the user's viewpoint.
Then the direction of the ray is determined by where the user's mouse is.
We convert the mouse location to NDC and then to world coordinates (which is the coordinate system for the EYE location), and finally subtract the two to get the direction.
- None right now. Thank you for the reading!
You're welcome!