0

After multiplication by the projection matrix If any clip coordinate is less than -wc, or greater than wc, then the vertex will be discarded. Then perspective division is performed by W. But what happens if w = 0? OpenGL just doesn't do division?

genpfault
  • 51,148
  • 11
  • 85
  • 139
AProgTV
  • 1
  • 2
  • 1
    A point with `w=0` can only fulfill the clip condition `-w <= x,y,z <= w` it it is exactly `(0,0,0,0)`. Every sane projection matrix will ensure that both z and w won't be mapped to zero at the same time (for every finite view space point), so the issue does not really occur. In practice, you can assume everything `w_clip <= 0` to be clipped. – derhass Jan 20 '21 at 23:06
  • You should look for [good](https://learnopengl.com/Getting-started/Coordinate-Systems) tutorials first before asking – Sync it Jan 21 '21 at 09:52

2 Answers2

0

Perspective division is done when converting coordinates from clip space to normalised device coordinates. Before this the x,y and z are compared to the w component and as you said if any of the components are greater than wc or smaller than -wc it will be clipped.

The w component in clip space will have the same value as the z coordinate in viewspace, so for it to be equal to zero, the z component in view space would also need to be zero. In view space the camera's z component is zero. In front of the camera is the near plane and anything with a z less than the near plane will be clipped. The z component in viewspace will be rescaled ,in this case since it is zero, to the negative of the nearplanes z component. This means that z will be smaller than the w component which is zero, the vertice will be clipped and there will be no perspective division.

Here is a youtube video that I think sums up the process of perspective projection quite well

fltray10
  • 31
  • 6
0

if you got input position (x,y,z,w=1) or vector (x,y,z,w=0) then after multiplication with uniform homogenuous 3D transform matrix the resulting w is never zero if the input x,y,z is in the frustrum range ...

So in case your result has w=0 the point or vector is outside frustrum anyway so you can ignore such point/vector ...

Spektre
  • 49,595
  • 11
  • 110
  • 380