Jump to content
  • Advertisement
Sign in to follow this  
fir

subpixel-acurate triangle rasterization routine needed

This topic is 1742 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to wrote/use software subpixel-acurate triangle rasterization routine (in c, with z-depth buffer testing on my own).

 

I wrote one but it is only 'pixel acurate' (does not do 'edge blending') it is also long (a few hundred lines as far as i remember) it uses scanline approach -it works but Im looking for better one.

 

 The trouble with my old routine is also, that when I have many small triangles pattern far away, many artifacts creeps over it when it moves, and it does not look so good - I am not sure if this pixel-creeps-effect it is related to depth fighting or some xy-fighting (If somebody knows what do I mean - I am not specialist in th theme of pixel perfection in software rasterization, though i would like to learn it)

 

Could someone help/advice with that ? (Close problem I have with circle (ball) rasterisation, I need good routine with good subpixel accuracy with depth buffer )

Edited by fir

Share this post


Link to post
Share on other sites
Advertisement

My old GBA demo has some software rasterization code in it. Check the .c files that begin with "Tri"

http://deku.rydia.net/program/eternity-source.zip

http://deku.rydia.net/program/eternity.zip

 

Various versions... flat triangle, shaded, textured, perspective correct textured. Some are made for back-to-front drawing, but most are for front-to-back using a C-buffer (coverage buffer). You still have to sort your tris, but no overdraw. I might have written a Z-buffer version at some point, but it doesn't look like it's in there. I went the C-buffer route because Z buffering was slower, and I was planning to do an S-buffer rasterizer afterward, which is similar. But I never finished it.

 

Looks like TriTex.c is the cleanest. Line 84 is where the subpixel correction happens. Basically, you take the fractional portion of the top vertex Y position, and advance all your gradients by that before you start the main for(y) loop. Here's where I learned the technique (I can't believe this page still exists after all this timesmile.png) http://freespace.virgin.net/hugo.elias/graphics/x_polysc.htm

Share this post


Link to post
Share on other sites

My old GBA demo has some software rasterization code in it. Check the .c files that begin with "Tri"

http://deku.rydia.net/program/eternity-source.zip

http://deku.rydia.net/program/eternity.zip

 

Various versions... flat triangle, shaded, textured, perspective correct textured. Some are made for back-to-front drawing, but most are for front-to-back using a C-buffer (coverage buffer). You still have to sort your tris, but no overdraw. I might have written a Z-buffer version at some point, but it doesn't look like it's in there. I went the C-buffer route because Z buffering was slower, and I was planning to do an S-buffer rasterizer afterward, which is similar. But I never finished it.

 

Looks like TriTex.c is the cleanest. Line 84 is where the subpixel correction happens. Basically, you take the fractional portion of the top vertex Y position, and advance all your gradients by that before you start the main for(y) loop. Here's where I learned the technique (I can't believe this page still exists after all this timesmile.png) http://freespace.virgin.net/hugo.elias/graphics/x_polysc.htm

 

Much tnx :) I will take my time tu 'munch' it (may be a couple of weeks, I am working slowly on it) 

 

As to Hugo elias page I also used it more than 10 years ago, from time to time encounter a people who mention it, :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!