Re: [Algorithms] Converting raw projection matrices between GL and D3D?
Brought to you by:
vexxed72
From: Aras P. <ne...@gm...> - 2007-02-15 18:50:02
|
> The only difference I can think of is that in OpenGL clip space, the Z > range is -1 to 1, whereas in Direct3D, the Z range is 0 to 1. Thus, you > can scale and offset the Z coordinate (column, if you're row-vector on > left; row, if you're column-vector on right) to adjust for this. Scale > elements 0,1,2 by 0.5, add 0.5 to the 3rd element. That was my first idea as well, but somehow it does not seem to work. Take the canonical GL perspective matrix, third row (assuming no negative scaling on Z): 0 0 (f+n)/(f-n) -2*f*n/(f-n) And the canonical D3D perspective matrix: 0 0 f/(f-n) -f*n/(f-n) Scaling by 0.5 (first 3 elements) and biasing by 0.5 (4th element) on GL matrix row would not produce the D3D values. But scaling&biasing on the orthogonal projection matrix would produce the correct result. Or am I missing something obvious here? -- Aras Pranckevicius work: www.unity3d.com home: nesnausk.org/nearaz |