#65493 - keldon - Tue Jan 03, 2006 5:48 pm
[Images not permitted - Click here to view it]
The image shows an issue I am getting with my fixed point texture mapping algo. It displays fine using floating points and all I have really done is replaced the floats with fixed point numbers.
The red line and the 3 coloured dots were added for reference points. The cyan dots represents the 2 3-point polygons used to render the square. The yellow dot is just a marker for where I am getting incorrect results.
The same horizontal delta is used across the each 3 point polygon. It appears that the fixed point delta in this case is a little lower than it should be due to precision.
I am currently using 16:16 fixed point for su deltas despite the fact that su is in the range of 0 to 1. Could the be the very reason? If so then should I use 1:31 fixed point for su deltas? And how would I go about multiplying 2 fixed point numbers with different points?
My fixed point conversion methods:
The image shows an issue I am getting with my fixed point texture mapping algo. It displays fine using floating points and all I have really done is replaced the floats with fixed point numbers.
The red line and the 3 coloured dots were added for reference points. The cyan dots represents the 2 3-point polygons used to render the square. The yellow dot is just a marker for where I am getting incorrect results.
The same horizontal delta is used across the each 3 point polygon. It appears that the fixed point delta in this case is a little lower than it should be due to precision.
I am currently using 16:16 fixed point for su deltas despite the fact that su is in the range of 0 to 1. Could the be the very reason? If so then should I use 1:31 fixed point for su deltas? And how would I go about multiplying 2 fixed point numbers with different points?
My fixed point conversion methods:
Code: |
inline int ftoi ( float f ){
return (int)((float)(1 << 16) * f); } inline int itoi ( int i ){ return i << 16; } inline int fpmul ( int a, int b ){ return (int)(((long long)a * (long long)b) >> 16); } inline int rdiv ( int b ) { return ((1 << 31) /b)<< 1; } inline int fpdiv ( int a, int b ) { return (int) (((long long)a << 16) / (long long)b); } inline float itof ( int i ) { return (float)i / (float)(1 <<16); } |