Hi,
I would like to know if games are using the vertex shader to change the location of an object,vertex in space.?
If they change the location is it small offest only or could it be a large offset?
Can I understand from the vertex location before the GPU and the transform matrics where will the vertex be in the 2d world?
Thanks,
Raz
Knowing vertex position on after projection
Started by raznitzan, May 19 2006 07:44 AM
5 replies to this topic
#1
Posted 19 May 2006 - 07:44 AM
#2
Posted 19 May 2006 - 08:00 AM
Yes you have all the freedom to change vertex positions in the vertex-shader as you like.
#3
Posted 19 May 2006 - 09:50 AM
Practically every vertex shader uses at least one matrix transform for the position. So there's no direct correlation between the input and output vertex position. Also, it's almost impossible to know which matrix is being used.
Why do you need to know?
Why do you need to know?
#4
Posted 19 May 2006 - 02:17 PM
raznitzan said:
Can I understand from the vertex location before the GPU and the transform matrics where will the vertex be in the 2d world?
It sounds like you're asking how to perform all the vertex transformations yourself, mapping from the vertex in object space to its 2D position in screen space? If so that is certainly possible. You have to transform it first by the modelview matrix, then by the projection matrix, then divide out the w (4th component). The result of these is the vertex location in normalized device-coordinates (NDC), which range from -1 to +1 on each axis. Then you just have to map the [-1, +1] range onto [0, screen_width] for x, and [0, screen_height] for y (the z-coordinate you can forget for now). Then you have the vertex location in screen space :yes:
reedbeta.com - developer blog, OpenGL demos, and other projects
#5
Posted 23 May 2006 - 09:35 PM
Wouldn't the vertex shader changes the vertex location in 2d space
#6
Posted 23 May 2006 - 09:42 PM
Well, the vertex shader is responsible for ALL the transformations that go from the vertex location you have put in your arrays to the location in eye space that is finally projected onto the screen. So you can move the vertices in 3D if you choose, or you can move them in 2D if you choose, or both.
reedbeta.com - developer blog, OpenGL demos, and other projects
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











