Ilian Dinev

03-16-2009, 07:28 PM

DX has 3 matrices, GL has 2, and it seems to me that I can simply use only one matrix: something like the gl_ModelViewProjection.

I've long since replaced all fixed-func GLSL symbols, doing the maths myself - but keeping 2 matrices (project and mview) then multiplying them once per object to send the updated value to shaders.

In the math-correction tests I did, I noticed the difference between the two approaches is only one bit in the floats[6], the least significant bit in the mantissa.

My question is: can I simply use/provide only one "matrix stack", on which to first apply projection, then camera, then object transforms? If I need to transform a vertex from to world-space, I think multiplication with inverse-matrix of projection or camera should suffice (when I cannot simply redo the transformation-sequence starting from identity). Those projection and camera matrices get updated just once per camera per frame, after all.

This is mostly about coding-convenience and optimization.

I've long since replaced all fixed-func GLSL symbols, doing the maths myself - but keeping 2 matrices (project and mview) then multiplying them once per object to send the updated value to shaders.

In the math-correction tests I did, I noticed the difference between the two approaches is only one bit in the floats[6], the least significant bit in the mantissa.

My question is: can I simply use/provide only one "matrix stack", on which to first apply projection, then camera, then object transforms? If I need to transform a vertex from to world-space, I think multiplication with inverse-matrix of projection or camera should suffice (when I cannot simply redo the transformation-sequence starting from identity). Those projection and camera matrices get updated just once per camera per frame, after all.

This is mostly about coding-convenience and optimization.