projection matrix - OpenGL 3D Transformation: z-Aspect ratio -
projection matrix - OpenGL 3D Transformation: z-Aspect ratio -
i'm doing 3d perspective projection in opengl (webgl), doing myself uniform-matrices. everthing working fine, have aspect ration of 3:2 (600px x 400px) , distorts geometry rendered.
in 2d used prepare in model matrix dividing x , y through 1 / width , 1 / height respectively.
now have z worry , pretty clueless how / transform z not distort on 3:2 aspect ratio.
the model matrix not seem offer chance , don't know / in projection matrix.
edit: projection matrix:
@_pmatrix = [ 1, 0.0, 0.0, 0.0, 0.0, 1, 0.0, 0.0, 0.0, 0.0, -(f + n) / (f - n), -1, 0.0, 0.0, -2.0 * n * f / (f - n), 0.0 ]
column major order
edit 2: weird distortions on n < 1
you're missing *left*, *right*, *top*, *bottom*
in projection matrix.
2*n ----- 0 0 0 r-l 2*n 0 ----- 0 0 t-b r+l t+b -(f+n) ----- ----- ------ -1 r-l t-b f-n -2*f*n 0 0 0 ------ f-n
if define (r-l)/(t-b) = 3/2
such viewing volume appropriate size model, should set.
here slides describing various projection matrices , how they're derived: http://www.cs.unm.edu/~angel/cs433/lectures/cs433_17.pdf
they're edward angel, author of interactive computer graphics, got matrix. unfortunately opengl reddish book doesn't seem work through math @ all.
opengl projection-matrix 3dcamera
Comments
Post a Comment