@@ -53,23 +53,31 @@ on to the fragment shader, like color and texture coordinates. These values will
5353then be interpolated over the fragments by the rasterizer to produce a smooth
5454gradient.
5555
56- Clip coordinates are [ homogeneous coordinates] ( https://en.wikipedia.org/wiki/Homogeneous_coordinates )
56+ A * clip coordinate* is a four dimensional vector from the vertex shader that is
57+ subsequently turned into a * normalized device coordinate* by dividing the whole
58+ vector by its last component. These normalized device coordinates are
59+ [ homogeneous coordinates] ( https://en.wikipedia.org/wiki/Homogeneous_coordinates )
5760that map the framebuffer to a [ -1, 1] by [ -1, 1] coordinate system that looks
5861like the following:
5962
60- ![ ] ( /images/clip_coordinates .svg )
63+ ![ ] ( /images/normalized_device_coordinates .svg )
6164
6265You should already be familiar with these if you have dabbed in computer
6366graphics before. If you have used OpenGL before, then you'll notice that the
6467sign of the Y coordinates is now flipped. The Z coordinate now uses the same
6568range as it does in Direct3D, from 0 to 1.
6669
6770For our first triangle we won't be applying any transformations, we'll just
68- specify the positions of the three vertices directly in clip coordinates to
69- create the following shape:
71+ specify the positions of the three vertices directly as normalized device
72+ coordinates to create the following shape:
7073
7174![ ] ( /images/triangle_coordinates.svg )
7275
76+ We can directly output normalized device coordinates by outputting them as clip
77+ coordinates from the vertex shader with the last component set to ` 1 ` . That way
78+ the division to transform clip coordinates to normalized device coordinates will
79+ not change anything.
80+
7381Normally these coordinates would be stored in a vertex buffer, but creating a
7482vertex buffer in Vulkan and filling it with data is not trivial. Therefore I've
7583decided to postpone that until after we've had the satisfaction of seeing a
0 commit comments