Create filled triangles line by line
Blitz3D Forums/Blitz3D Programming/Create filled triangles line by line
| ||
Here is a CreateTriangle() function that should be quicker than the pixel-by-pixel approach used by the functions that work for all polygons. This one's just for triangles. There may already be one in the archives, but I did this partly as an exercise so here it is anywayj: |
| ||
Ooo, a challenge! I say pixel-by-pixel can be fast... Although I'm cheating, I already had that lying around. Last edited 2011 |
| ||
Two points: 1. Some of your triangles aren't actually being drawn, at least on my screen. When I change DrawTriangle1(x0,y0,x1,y1,x2,y2,1) to DrawTriangle1(x0,y0,x1,y1,x2,y2,0) most of the triangles don't appear. When they do (triangles 2 and 5, for example) the speed difference is less, but still considerable. However, 2. The reason is LockBuffer, which I just discovered makes a huge difference on ordinary drawing commands, like Line. (I thought it was just for WritePixelFast and such.) With the changes below CreateTriangle1 is faster on 2 and 5 at least. Still, CreateTriangle2 is pretty fast considering it's point-by-point... ;-) |
| ||
So are we going to see a software renderer soon, now that we can draw triangles quickly... |
| ||
I thought it was just for WritePixelFast and such. Same here. That's an interesting discovery! And... yeah at one time I thought it would be fun to try working on a software renderer, but didn't get much further than trying to texture triangles. It just seems a bit pointless given that a B3D one wouldn't be usable, while even mobile devices now have hardware 3D. (If I'm lucky, the triangles not being drawn had the wrong "spin", i.e. backfaces - otherwise I guess my triangle routine is broken.) That said, Devil's Child made one a while back. Try searching for VirtualGL. |
| ||
use that searcher (sure you know it!) http://blitzbasic.com/Community/posts.php?topic=88773#1007957 Juan |
| ||
you might all want to check out this: http://stuff.dev-ch.de/index.php?loc=13 my software renderer entirely written in Blitz. there is also a c++ version, which is about 10x faster Last edited 2011 |
| ||
That is extremely cool. You've got my attention with the C++ one. Software rendering is cool... fast software rendering is awesome! |
| ||
There's also the Ray SoftwareRenderer from the SoftPixel engine: http://softpixelengine.sourceforge.net/softwarerenderer.html For C, comes with source. Last edited 2011 |
| ||
thanks :) my c++ software renderer also supports stencil shadows, see: |
| ||
That's really cool.. Looks great |
| ||
What's the licence on that (specifically, on the source)? I for one want to look through it and learn something, but without a licence tag... |
| ||
everything there is open source, so free to use and modify. if you use complete parts of the code, i would appreciate a comment with my name and a link to the page. but yes, it's free. |
| ||
Thanks, that's very generous. |
| ||
@Axel Wheeler, can I use your fill triangle function, as part of an entry of my code, in the Code Archive? In other words, since the Code Archive is strictly Public Domain code can I use your function, in my function which will be posted as Public Domain code? Proper credits will be posted in the code at the top of listing and at the location of the triangle fill function. Nevermind. I used something else. Last edited 2011 |