How do you modify or override the perspective division calculation in OpenGL?
Also is it possible to use x, y, z and w as variables in matrices in OpenGL?
How do you modify or override the perspective division calculation in OpenGL?
Also is it possible to use x, y, z and w as variables in matrices in OpenGL?
You can't. It's one of the few "hardwired" (or actually hardcoded on modern GPUs) things in OpenGL. But that's no problem. Just set
gl_Position.w = 1
at the very end of the vertex shader, which will effectively make the perspective division a no-op. However you then also have no perspective, so you'd have to implement that in your vertex shader as well. You could writegl_Position /= gl_Position.w;
as the very last statement in the vertex shader to do the perspective divide yourself, and bypass the built-in divide.I'm not quite sure what you mean by that.