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

<p>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.</p>

<hr>

<p>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 <em>teach</em> 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.</p>

<p>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.</p>

<p>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).</p>

CC BY-SA 3.0
2017-06-25T20:06:11.133Z
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?
mikeglaz
CC BY-SA 3.0
2017-06-25T20:42:15.407Z
Wait, did you meant "Because $x_{proj}$ doesn't vary from $0 \rightarrow width$"?
mikeglaz
CC BY-SA 3.0
2017-06-26T02:19:54.297Z
For openGL it needs to project to normalised device coordinates (-1 to 1) so it scales from -Width/2 to Width/2
PaulHK
CC BY-SA 3.0
2017-06-26T17:56:01.663Z
You should ask another question about PBR, but here is a good resource: https://learnopengl.com/#!PBR/Theory
Alan Wolfe
CC BY-SA 3.0
2017-06-26T19:22:05.960Z
@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.
Dan Hulme
CC BY-SA 3.0
2017-06-25T17:35:05.283Z
2017-06-26T19:20:52.603Z
2017-06-26T19:20:52.603Z
Dan Hulme
<p>I'm using OpenGL to learn computer graphics.  I'm trying to understand projection matrices.  The following are shown in the OpenGL 'Red Book':</p>

<p><a href="https://i.sstatic.net/Qi0UI.png" rel="noreferrer"><img src="https://i.sstatic.net/Qi0UI.png" alt="enter image description here"></a></p>

<p><a href="https://i.sstatic.net/FBZZ5.png" rel="noreferrer"><img src="https://i.sstatic.net/FBZZ5.png" alt="enter image description here"></a></p>

<p>I don't understand why the width and height are divided by 2?</p>

<projections><matrix>
Why are width and height divided by 2 in the perspective projection matrix?
mikeglaz
# Why are width and height divided by 2 in the perspective projection matrix?

(Asked by: username_0 on 2017-06-25)

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](https://i.sstatic.net/Qi0UI.png)](https://i.sstatic.net/Qi0UI.png)

[![enter image description here](https://i.sstatic.net/FBZZ5.png)](https://i.sstatic.net/FBZZ5.png)

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

**Tags:** projections, matrix


---

## 1 answers

### Answer by username_1 on 2017-06-25. Score: 11

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).

> **Comments:**
> **username_0**: 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?  
> **username_0**: Wait, did you meant "Because $x_{proj}$ doesn't vary from $0 \rightarrow width$"?  
> **username_2**: For openGL it needs to project to normalised device coordinates (-1 to 1) so it scales from -Width/2 to Width/2  
> **username_3**: You should ask another question about PBR, but here is a good resource: https://learnopengl.com/#!PBR/Theory  
> **username_1**: @username_0 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.  

---

