If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
![]() |
|
|
#51 | |
|
Senior Member
Join Date: Jan 2003
Location: Ottawa, Ontario
Posts: 1,783
|
Quote:
Here's a small tutorial I wrote two years ago about a robust software rasterizer using (half-)edge functions: Advanced Rasterization. It's suited for resolutions up to 2048x2048 and 4-bit sub-pixel precision but can be extended to much higher resolutions (including a guard band) and sub-pixel precision with 64-bit. A hardware implementation could obviously use an arbitrary precision. |
|
|
|
|
|
|
#52 | |
|
Moderator
Join Date: Feb 2002
Location: Redmond, WA
Posts: 3,164
|
Quote:
X/W Y/W (optionally)Z/W and W If W is 0 or close to it and your using a standard divide all information about X and Y are lost since infinity doesn't tell you much. Although you might be able to get away with clamping based on sign to some large number for rasterization purposes and assuming any infinity is basically at the nearplane. But I'd have thought this would lead to noticeable texture crawl as triangles approach the nearplane. |
|
|
|
|
|
|
#53 |
|
Member
Join Date: Jun 2002
Posts: 305
|
I actually 'hacked' a triangle setup algorithm running on the simulator unified shader (ARB instruction set) for a paper last year about mobile GPUs. With 32-bit fp it seemed to work relatively well for the Unreal Tournament trace I was using at resolutions of 320x240 and 640x480 ... until one explosion started to produce quite large glitches. It may had been a precission problem but I never got to find what was the real problem. You can check the simulator if you are interested, the hack is still there even if it hasn't been used or tested since then.
The algorithm used is the one based on Olano's paper. The inverse matrix is computed and from that matrix four linear equations are derived for the three edges and for Z. All other interpolators are computed in a much later stage using the barycentric coordinates (the results of the three edge equations for the fragment). No point in carrying all that info for fragments that are outside the triangle or fail Z before shading. All the emulation code related with triangle setup and fragment generation uses 64-bit fp just to be 'safe' (I didn't want to bother with fixed point arithmetic and speed is not a problem for the simulator). |
|
|
|
|
|
#54 | ||
|
Senior Member
Join Date: Jan 2003
Location: Ottawa, Ontario
Posts: 1,783
|
Quote:
Quote:
Using 64-bit floating point should indeed be fairly safe. It's pretty much equivalent to having a 53-bit fixed-point format with, well, a floating point. |
||
|
|
|
|
|
#55 | |
|
Member
Join Date: Jun 2002
Posts: 305
|
Quote:
|
|
|
|
|
|
|
#56 |
|
Recurring Membmare
Join Date: Aug 2003
Location: yes
Posts: 2,494
|
It probably was textured but due to failing texcoord interpolation a single texel got applied for the whole triangle.
|
|
|
|
|
|
#57 | |
|
Recurring Membmare
Join Date: Aug 2003
Location: yes
Posts: 2,494
|
Quote:
edited: No, it wouldn't, don't bother replying edited again: a "regular" near plane is defined by znear, and because pst-transform w would only depend on post-transform z (if it depends on anything at all), there will certainly be a way to figure out the z/w at the near plane. It should be possible to replace near-plane clipping by the comparison z/w to a precomputed z/w-near. w=0 shouldn't (TM) happen too often. In real world terms that's at the center of the eye/camera, not at the near plane. Last edited by Rolf N; 08-Sep-2006 at 23:05. Reason: Sudden, unexpected occurrence of certain thought processes |
|
|
|
|
|
|
#58 | |
|
Senior Member
Join Date: Feb 2002
Location: gjethus, Norway
Posts: 1,256
|
Quote:
Getting W= exactly 0 for a vertex generally requires a 100% exact floating-point cancellation to appear somewhere in the modelview+projection transform. It is as such a rather unlikely case, but one that does need to be handled or avoided. It can be avoided with ordinary geometric near-plane clipping; handling it is a bit non-trivial, but not impossible. |
|
|
|
|
|
|
#59 |
|
Senior Member
Join Date: Jan 2003
Location: Ottawa, Ontario
Posts: 1,783
|
Looking at the algorithm for doing setup with a matrix inverse, and how it depends solely on the vertex positions, I started wondering whether triangles that share an edge could have similar coefficients. Say we have a triangle strip, do we have to recompute the entire matrix inverse for each triangle, or can we use part of the previous one? This corresponds with changing one column in the matrix that needs to be inverted, in a cyclic manner.
After half a day of exercising my linear algebra skills, I found that it takes 20 multiplications to compute the new inverse from the previous one, versus 30 multiplications to do a full matrix inverse. It requires 16 additions versus 11 though, and still needs one reciproke. Either way, it's a nice tradeoff, especially when already using triangle strips exclusively. Any chance this is also used by any hardware? |
|
|
|
|
|
#60 | |
|
Member
Join Date: Jun 2002
Posts: 305
|
Quote:
|
|
|
|
|
|
|
#61 | |
|
Senior Member
Join Date: Jan 2003
Location: Ottawa, Ontario
Posts: 1,783
|
Quote:
But that's just theoretical... |
|
|
|
|
|
|
#62 | |
|
Tea maker
Join Date: Feb 2002
Location: In the Island of Sodor, where the steam trains lie
Posts: 4,382
|
Quote:
__________________
"Your work is both good and original. Unfortunately the part that is good is not original and the part that is original is not good." -(attributed to) Samuel Johnson "I invented the term Object-Oriented, and I can tell you I did not have C++ in mind." Alan Kay |
|
|
|
|
|
|
#63 | |
|
Senior Member
Join Date: Jan 2003
Location: Ottawa, Ontario
Posts: 1,783
|
Quote:
I think I did find a more practical result though: To compute the classical matrix inverse, a division by the deteminant is required. This takes 1 reciproke, 12 multiplications and 2 addtions. I believe this can be eliminated altogether. Without dividing by the determinant d, instead of computing u/w and 1/w we'd be computing d*u/w and d/w. Per pixel we're computing (d*u/w)/(d/w) = u. Looks like a win-win to me... |
|
|
|
|
|
|
#64 | |
|
Tea maker
Join Date: Feb 2002
Location: In the Island of Sodor, where the steam trains lie
Posts: 4,382
|
Quote:
__________________
"Your work is both good and original. Unfortunately the part that is good is not original and the part that is original is not good." -(attributed to) Samuel Johnson "I invented the term Object-Oriented, and I can tell you I did not have C++ in mind." Alan Kay |
|
|
|
|
|
|
#65 |
|
Senior Member
Join Date: Jan 2003
Location: Ottawa, Ontario
Posts: 1,783
|
Not "most", it only takes three multiplications and two additions, but yes I forgot to include it. So in total we can save 1 reciproke and 9 multiplications. Still not bad in my opinion, and it's beneficial for precision as well.
|
|
|
|
|
|
#66 |
|
Tea maker
Join Date: Feb 2002
Location: In the Island of Sodor, where the steam trains lie
Posts: 4,382
|
__________________
"Your work is both good and original. Unfortunately the part that is good is not original and the part that is original is not good." -(attributed to) Samuel Johnson "I invented the term Object-Oriented, and I can tell you I did not have C++ in mind." Alan Kay |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|