8
$\begingroup$

I'm using OpenGL to learn computer graphics. I'm trying to understand projection matrices. The following are shown in the OpenGL 'Red Book':

enter image description here

enter image description here

I don't understand why the width and height are divided by 2?

$\endgroup$
10
$\begingroup$

Because $x_{proj}$ doesn't vary from $0 \to width$, it varies from $-\tfrac{width}{2} \to \tfrac{width}{2}$.

What's important is not the width, but the minimum and maximum values of $x_{proj}$. Because $(0, 0)$ is in the centre of the viewport, not the corner, the min and max values are plus and minus half of the width.


BTW, the Red Book is not a great introduction to graphics in general. It's a technical standard, not a tutorial, so the explanation of concepts is just enough to be unambiguous - it's not trying to teach the material. It's also about a scanline rendering library in particular, so there's a lot of important concepts it doesn't describe at all, such as what BRDFs are important, how they relate to real-world surface properties, what an image really is, and many higher-level techniques.

And finally, even in the area it's about - how to use a GPU to accelerate rendering - it's hideously out of date. The GL architecture is based on GPUs from 20 years ago. Although lots of features have been added to keep up with changes to hardware, the fundamental abstractions are not a good way to understand current GPU architectures.

If you want to learn about the theory of computer graphics, start with a proper textbook such as Physically Based Rendering or Computer Graphics: Principles and Practice, or an online course. If you want to learn how to make a 3D application, start with a tutorial about the kind of application you're interested in (e.g. if it's a game, try a Unity tutorial).

$\endgroup$
  • $\begingroup$ Wow, this is exactly what I've been looking for. I started reading a Linear Algebra textbook...but what kind of mathematics do I need to know for physically based rendering? $\endgroup$ – mikeglaz Jun 25 '17 at 20:06
  • 2
    $\begingroup$ Wait, did you meant "Because $x_{proj}$ doesn't vary from $0 \rightarrow width$"? $\endgroup$ – mikeglaz Jun 25 '17 at 20:42
  • $\begingroup$ For openGL it needs to project to normalised device coordinates (-1 to 1) so it scales from -Width/2 to Width/2 $\endgroup$ – PaulHK Jun 26 '17 at 2:19
  • $\begingroup$ You should ask another question about PBR, but here is a good resource: learnopengl.com/#!PBR/Theory $\endgroup$ – Alan Wolfe Jun 26 '17 at 17:56
  • $\begingroup$ @mikeglaz I did, thank you. I'd say if you know some undergrad linear algebra and high-school optics, you're fine. Any particulars you don't already understand, you'll already have the grounding to understand by reading the appropriate Wikipedia page. $\endgroup$ – Dan Hulme Jun 26 '17 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.