Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm implementing a software renderer with this rasterization method, however, I was wondering if there is a possibility to improve it, or if there exists an alternative technique that is much faster. I'm specifically interested in rendering small triangles, like the ones from this 100k poly dragon:

Dragon

As you can see, the method I'm using is not perfect either, as it leaves small gaps from time to time (at least I think that's what's happening).

I don't mind using assembly optimizations. Pseudocode or actual code (C/C++ or similar) is appreciated.

Thanks in advance.

share|improve this question
    
you should try to find out what happens in the gaps –  Maik Semder Nov 23 '12 at 8:48
    
I think the answer to your question is, yes, it can be improved upon. Your question is a bit too broad. There isn't a correct answer. You're basically saying: "This is how I'm currently doing things, are there any other ways of doing it?" Yes, lots of ways. But your question isn't a good fit for this site. Try a more discussion oriented site, like gamedev.net or reddit.com/r/gamedev –  Byte56 Nov 26 '12 at 3:01

1 Answer 1

up vote 0 down vote accepted

Rasterizing triangles in software is commonly done using either Bresenham's algorithm or using a differential digital analyzer (DDA) with fixed point math to interpolate the values. Bresenham uses a lot of branching, so is probably less efficient than a fixed-point DDA on modern CPUs.

The tutorial you have linked uses an odd mix of C++ classes, floating point math, and a per-pixel function call to set the colors. You can do a lot better than that example by just writing less inefficient code! Both Bresenham and DDA will get you more numerical stability than mixing floats and ints haphazardly as in the linked tutorial (a probable cause of the gaps you see).

share|improve this answer
    
Thanks, I implemented a floating point DDA that works very good. –  Belgin Nov 28 '12 at 13:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.