# How can I set gl_Position's w component to 1?

In my vertex shader, I'd like to set the w component to 1.

How can this be done, after

gl_Position =  MVP * vec4(vertexPosition_modelspace, 1);

• why do you think you need to? – ratchet freak Jan 29 '18 at 14:49
• I wanted to switch off perspective divide. – Edward Jan 29 '18 at 19:41
• @Edward - "how do I switch off perspective divide?" might have been a better question then; ask about what you want to do, not how you want to do it. Further reading: meta.stackexchange.com/questions/66377/what-is-the-xy-problem – Maximus Minimus Jan 29 '18 at 19:46
• Then don't use a perspective projection but an orthographic projection matrix instead – ratchet freak Jan 29 '18 at 20:37
• I just wanted to see the effect switching it off had on a perspective projection. Seems to yield very similar results to an orthographic projection, when rendering a simple coloured cube. – Edward Jan 29 '18 at 22:30

## 1 Answer

You can use swizzles to access specific coordinates in the vector.

gl_Position.w = 1.0;