• Create Account

### #ActualRavyne

Posted 08 January 2013 - 01:32 PM

My math is rusty enough that I wouldn't consider this much more than conjecture, but I'd point out that what you're doing seems not to be equivalent.

If you work the first set of equations by substituting the first line into the second, you get:

gl_position = uProjection * (uView *uModel * vPosition);

whereas your second set of equations is simply:

gl_position = uProjection * uView *uModel * vPosition;

With the parenthesis in place, you're transforming a vector through the View and Model matrices (which are first multiplied together) to get an intermediate result, and then transforming that intermediate result by the Projection matrix to get the final result. Without the parenthesis in place, the Projection, View and Model matrices are all multiplied together first, and then used to transform the vector -- there is no intermediate. These are not the same formulas.

Due to floating-point error, even if these formulas were/are mathematically equivilent, the mere introduction of the intermediate result in a z-buffered position might introduce enough difference to place the point in front/behind the intended plane erroneously.

If you like, you can confirm my conjecture by adding the parenthesis into your second equation, and see if that gives results that are similar to the errors you saw.

### #1Ravyne

Posted 08 January 2013 - 01:30 PM

My math is rusty enough that I wouldn't consider this much more than conjecture, but I'd point out that what you're doing seems not to be equivalent.

If you work the first set of equations by substituting the first line into the second, you get:

gl_position = uProjection * (uView *uModel * vPosition);

whereas your second set of equations is simply:

gl_position = uProjection * uView *uModel * vPosition;

With the parenthesis in place, you're transforming a vector through the View and Model matrices (which are first multiplied together) to get an intermediate result, and then transforming that intermediate result by the Projection matrix to get the final result. Without the parenthesis in place, the Projection, View and Model matrices are all multiplied together first, and then used to transform the vector -- there is no intermediate. These are not the same formulas.

Due to floating-point error, even if these formulas were/are mathematically equivilent, the mere introduction of the intermediate result in a z-buffered position might introduce enough difference to place the point in front/behind the intended plane erroneously.

PARTNERS