Can anyone explain me what what are steps to be performed in order to generate NDC from object space coordinates with below example.
float vertices[] = {
-2.0f, -12.0f,
2.0f, -12.0f,
-2.0f, 12.0f,
2.0f, 12.0f
};
here is my mvp matrix:
float MVP[16] = {
0.993, 0.054, -0.102, -0.102,
0.007, 0.852, 0.524, 0.524,
-0.115, 0.521, -0.846, -0.846,
0.575, -2.604, 4.061, 4.260 };
By my calculation I get:
X,Y,Z,W:
0.824918 7.111959 1.110172 1.000000
-1.111003 5.714332 1.090060 1.000000
-0.123152 0.698949 0.981588 1.000000
0.256286 0.747339 0.980855 1.000000
But those are wrong. By wrong I mean, if I do:
vec4 vert = mvp * vec4(inPos.x,inPos.y,0,1);
vert.xyzw/=vert.w;
gl_Position = vert;
in VS, i get different o/p as that of:
vec4 vert = mvp * vec4(inPos.x,inPos.y,0,1);
gl_Position = vert;