I wrote a software rasterizer recently
[attachment=19092:tie3.png]
(this great model is taken from blender models com mady by 'admin')
This is working and I am happy but this is naively written (no asm no cache optymizations etc) and is slow (slower than it could be).
Especially my clipping code is weak.. I mostly just check if 2d triangle result lies in screen if no then clip, I also check some points of 2d triangle with depth buffer if no one is forward then clip the triangle (it is slightly inprecise but it is ok
for me). third - i also test if the whole triange lies back the camera plane then also clip.
I am looking for some techniques to do better clipping here.. preferably some easy ones in first, or medium hard, some hardest the last.. Could someone share some knowledge about such clipping?
Ps. (this model is 300 tys triangles in raw format (I wonder if i would split the data into vertexes and indexes it would fasten the drawing or slowing this... with indexes there is slightly less data probably but there in the code would be the look up for vertx instead of pure stream )
-----
EDIT
well after some thinking i invented something:
precomputing the visiblity, it goes such way:
from the given point of view (there are sphere of them)
some triangles of the model (say 30%) are visible
other (70%) are not - Divide this sphere on say 64
patches and precompute for every triangle if it is seen
from this 'patch' (it would be heavy to precompute,
for example cost of rendering a couple of frames
from couple of places on the patches, the testet
traingle the last to check if it pass the depth buffer -
so this is cost of 64patches x 5 places x noOfTriangles
so for example for this model 320x300 000 = 90 MFrames
this is a lot of precomputing :C but can be done i think)
then set the corresponding bit in some 64 word of flags
1 means form this patchg of visibility this triangle is seen
- that should be very simple to use and top eficient
clipping method :U - though this precomputation time scares me but this can be optymized (for example
it is easy to sign the triangles that goes out for sure,
it is harder to make sure the one that previously passed
will is totaly overvritten so it is also goes out, bout
probably by rendering in changed direction and suming
the onet that goes out will give the sum of the set that
is invisible)
I will try to implement it and check how it is working after some resting i shoul take