![]() |
| [[ Home | Forums | 3D Engines Database | Wiki | Articles/Tutorials | Game Dev Jobs | IRC Chat Network | Contact Us ]] |
|
|
#1 |
|
DevMaster Staff
Join Date: Apr 2003
Location: Germany
Posts: 2,328
|
just an old code snippet i found on one of my code backup cds. i removed the clipping parts from the code since they don't really belong to the snippet title
Code:
___________________________________________
If Prolog is the answer, what is the question ? |
|
|
|
|
|
#2 |
|
DevMaster Staff
Join Date: Apr 2003
Location: Germany
Posts: 2,328
|
on a second thought the textured version might have been more interesting
maybe i can dig them up, too
___________________________________________
If Prolog is the answer, what is the question ? |
|
|
|
|
|
#3 |
|
DevMaster Staff
Join Date: Jan 2003
Posts: 1,201
|
Very interesting indeed...is this part of a software renderer you made?
|
|
|
|
|
|
#4 |
|
DevMaster Staff
Join Date: Apr 2003
Location: Germany
Posts: 2,328
|
i guess. it was a seperate code file i backed up for some reason. it must be several years old. i was surprised that the cd still worked at all. i'm trying to find more pieces of that renderer
___________________________________________
If Prolog is the answer, what is the question ? |
|
|
|
|
|
#5 |
|
DevMaster Staff
Join Date: Apr 2003
Location: Germany
Posts: 2,328
|
which reminds me, is there going to be an update on the software rendering tuts ? maybe i can be of help ???
___________________________________________
If Prolog is the answer, what is the question ? |
|
|
|
|
|
#6 |
|
DevMaster Staff
Join Date: Jan 2003
Posts: 1,201
|
That's a good idea! Or maybe you could write your own tutorial on rendering a triangle (with texturing maybe) as well as explaining the math and theory behind it. That would be an excellent tutorial.
|
|
|
|
|
|
#7 |
|
DevMaster Staff
Join Date: Apr 2003
Location: Germany
Posts: 2,328
|
i'll consider that
___________________________________________
If Prolog is the answer, what is the question ? |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Jan 2003
Posts: 868
|
This reminds me something too.... i always wondered how the trick which Chris Hecker discusses in his article actually works. I mean the stuff that you can precalculate the slopes only once and use combinations of them during the rendering process. If someone can point me to an article/tutorials that discusses that in detail and with nice and clean explanations i'll give that person five virtual bucks!!!
|
|
|
|
|
|
#9 |
|
DevMaster Staff
Join Date: Apr 2003
Location: Germany
Posts: 2,328
|
i thought the trick he did was not interpolating 1/z every pixel but only every n pixels... anyway, it's also at least 4-5 years since i read that particular article. i'll reread it if i can still find it. a lot of the good old information seems to be disappearing these days. maybe you have a link to it ?
[EDIT] : nm, his own site is still active... [/EDIT]
___________________________________________
If Prolog is the answer, what is the question ? |
|
|
|
|
|
#10 |
|
DevMaster Staff
Join Date: Apr 2003
Location: Germany
Posts: 2,328
|
hmmm, just pondered about this. if the difference between the z coords is small enough you might just use affine mapping.
though it's not a very brilliant idea it might speed up rendering by a big margin...
___________________________________________
If Prolog is the answer, what is the question ? |
|
|
|
|
|
#11 |
|
DevMaster Staff
Join Date: Apr 2003
Location: Germany
Posts: 2,328
|
sry, i completely misunderstood your post... anways, let me read through that article again...
___________________________________________
If Prolog is the answer, what is the question ? |
|
|
|
|
|
#12 |
|
DevMaster Staff
Join Date: Apr 2003
Location: Germany
Posts: 2,328
|
well, the trick you are reffering to is just 9th grade trigonometry. you should take a piece of paper and work it out. it's quite simple actually...
i don't even know how to explain it better than he does. it's all there in his paper.
___________________________________________
If Prolog is the answer, what is the question ? |
|
|
|
|
|
#13 |
|
Senior Member
Join Date: Jan 2003
Posts: 868
|
I'm not having problems with maths but i'm having troubles to translate that article from english
)) . Anyway i'll try some more. 10xP.S. The stuff with the dissapearing knowledge is true!!! |
|
|
|
|
|
#14 |
|
DevMaster Staff
Join Date: Apr 2003
Location: Germany
Posts: 2,328
|
sry, i didn't mean to be rude. anyways, if you can't understand the article we would have a hard time explaining it to you in englsih
![]()
___________________________________________
If Prolog is the answer, what is the question ? |
|
|
|
|
|
#15 |
|
Senior Member
Join Date: Aug 2004
Location: Ghent, Belgium
Posts: 1,056
|
Here's another way to sort vertices conveniently, without using indices:
Code:
Just a suggestion. Makes the code very clean in my opinion... |
|
|
|
|
|
#16 |
|
Senior Member
Join Date: Aug 2004
Location: Ghent, Belgium
Posts: 1,056
|
By the way, Chris Hecker's articles are worth gold when implementing a software rasterizer. I read each of them three times or more, and it was well worth it to understand every little bit he talks about.
Anyway, even though he presents the legacy method of rendering triangles, there are (better) alternatives. Triangle Scan Conversion using 2D Homogeneous Coordinates is more optimal for advanced rasterization... |
|
|
|
|
|
#17 |
|
DevMaster Staff
Join Date: Apr 2003
Location: Germany
Posts: 2,328
|
yeah... the articles are great. i loved them.
___________________________________________
If Prolog is the answer, what is the question ? |
|
|
|
|
|
#18 |
|
Senior Member
Join Date: Jan 2003
Location: Switzerland
Posts: 1,333
|
maybe we could link both topics together. yours having a link to nicks, and nicks back to yours, to show the two possible ways 'as one'
___________________________________________
davepermen.net -Loving a Person is having the wish to see this Person happy, no matter what that means to yourself. -No matter what it means to myself.... |
|
|
|
|
|
#19 |
|
DevMaster Staff
Join Date: Apr 2003
Location: Germany
Posts: 2,328
|
well... i'd feel kind of embarassed to put my years old childrens code next to that
![]()
___________________________________________
If Prolog is the answer, what is the question ? |
|
|
|
|
|
#20 |
|
Senior Member
Join Date: Jan 2003
Location: Switzerland
Posts: 1,333
|
hehe. hey, whats the problem. it's a working scanline software rastericer. you deserve credit.
___________________________________________
davepermen.net -Loving a Person is having the wish to see this Person happy, no matter what that means to yourself. -No matter what it means to myself.... |
|
|
|
|
|
#21 |
|
Senior Member
Join Date: Jan 2003
Posts: 868
|
he-hey! i wrote one too... don't i deserve a credit ???
![]() |
|
|
|
|
|
#22 |
|
Senior Member
Join Date: Aug 2004
Location: Ghent, Belgium
Posts: 1,056
|
Yeah, it looks a lot like the rasterizer I've been using in swShader for years. But, you have a nice way of handling the triangle in two pieces!
Besides, the rasterizer using half-space functions isn't perfect you know. The trivial implementation looks really elegant and small but it has flaws and is slow. To get good performance (only slightly faster than the scanline rasterizer) I had to use many many tricks that make things a lot messier. And converting it to MMX/SSE is madly complicated, even though I have years of assembly experience. ![]() |
|
|
|
|
|
#23 |
|
Senior Member
Join Date: Jan 2003
Location: Switzerland
Posts: 1,333
|
now i feel .. scared... NICK HAS PROBLEMS WITH ASSEMBLY!!
okay.. i definitely stay with raytracing for EVER. never looking back at rastericers AT ALL! ![]()
___________________________________________
davepermen.net -Loving a Person is having the wish to see this Person happy, no matter what that means to yourself. -No matter what it means to myself.... |
|
|
|
|
|
#24 | |
|
DevMaster Staff
Join Date: Apr 2003
Location: Germany
Posts: 2,328
|
Quote:
yeah man... thanks for ruining my life by getting me hooked up on this you bastard !!! it's your fault... just so that you know ![]()
___________________________________________
If Prolog is the answer, what is the question ? |
|
|
|
|
|
|
#25 | |
|
Senior Member
Join Date: Aug 2004
Location: Ghent, Belgium
Posts: 1,056
|
Quote:
The problem lies with SoftWire really. My automatic register allocator is currently unable to produce sufficiently efficient code. It puts things in registers that could really stay in memory, and vice-versa. So it creates a lot of spilling code (writing registers to temporary memory places to free them for other data), and also redundant copies (even though it uses copy propagation). I can add hints but that's not really elegant. The problem is more fundamental, in the way SoftWire works. It cannot look ahead at what data will be needed most, or even needed at all.This problem has been there from the start, but it was never experienced as a problem before because the generated code was still close to optimal, with only tiny inneficiencies. With the new rasterizer and quad pipeline, register pressure is really high. Every single component requires a full SSE register. So storing two 4D vector per pixel means eight registers are needed per quad, that's all of them. It's obvious that even a simple shader uses more than two vectors, and then I'm not even talking about temporaries that are needed for the SSE implementation, or things like z and w and the gradients. So SoftWire has a really hard time keeping the most useful data in registers. Anyway, don't panic, I know what needs to be done. I have to rewrite it so that registers aren't allocated immediately, but only when their associated variables are really used. Absolutely all register allocation operations (including copy propagation) have to be deferred to the very last moment. The implementation of it is very tricky since the generated code obviously has to be correct no matter what situation. Either way, that was what I referred to when saying the assembly implementation is "madly complicated". It should be worth it though, because I still have good hopes it will be 50-100% faster than processing one pixel at a time... |
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|