-5
\$\begingroup\$

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); 
\$\endgroup\$
6
  • 5
    \$\begingroup\$ why do you think you need to? \$\endgroup\$ Commented Jan 29, 2018 at 14:49
  • \$\begingroup\$ I wanted to switch off perspective divide. \$\endgroup\$ Commented Jan 29, 2018 at 19:41
  • 1
    \$\begingroup\$ @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 \$\endgroup\$ Commented Jan 29, 2018 at 19:46
  • \$\begingroup\$ Then don't use a perspective projection but an orthographic projection matrix instead \$\endgroup\$ Commented Jan 29, 2018 at 20:37
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Jan 29, 2018 at 22:30

1 Answer 1

4
\$\begingroup\$

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

gl_Position.w = 1.0;

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.