opengl - GLSL vertex shader gl_Position value -


i'm creating game uses orthogonal view(2d). i'm trying understand value of gl_position in vertex shader.

from understand x , y coordinates translate screen position in range of -1 1, i'm quite confused role of z , w, know w value should set 1.0

for moment use gl_position.xyw = vec3(position, 1.0);, position 2d vertex position

i use opengl 3.2.

remember opengl must work 3d , it's easier expose 3d details create new interface 2d.

the z component set depth of vertex, points outside -1,1 (after perspective divide) not drawn , values between -1,1 checked against depth buffer see if fragment behind drawn triangle , not draw if should hidden.

the w component perspective divide , allowing gpu interpolate values in perspective correct way. otherwise textures looks weird.


Comments

Popular posts from this blog

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -

How to run C# code using mono without Xamarin in Android? -