Sign in to follow this  
pikebu

get all pixels of a triangle

Recommended Posts

pikebu    122
hi, i want to implement a z-buffer. now i need to calculate the depth (z value), for every pixel in my triangle. how can i get it? all i have is the x, y, z values in 3d space and my u and v values in 2d space. i don't know how to get every pixel in 2d space and the z value of it? hope that some of you math gurus can help me out of this.

Share this post


Link to post
Share on other sites
Guimo    463
You have the XYZ in the model space? in World space? in View space or in Projected space?

I guess you should read a computer graphics book. Foley books being the basic text, it has information about this.

Luck!
Guimo

Share this post


Link to post
Share on other sites
grhodes_at_work    1385
pikebu,

The algorithm you're looking for, to determine the pixels (including the Z, or depth, value), is called "polygon scan conversion". There are a number of websites that provide pseudocode and actual working code. You should be able to find some of these sites using any search engine.

Guimo suggested that you take a look at the book by Foley et al., titled "Computer Graphics: Principles and Practice". Its good advice that helps you to find the answer to your question. This book discusses the standard algorithm for polygon scan conversion and the entire model space to camera space to screen space pipeline that preceeds scan conversion.

Scan conversion has been discussed in the forum previously. Try doing a forum search for "polygon scan conversion." That may help you find some good websites quickly.

Hopefully these hints will get you started. If not, post again and perhaps sometime next week I can dig out a few web links for you. But, please understand I personally will not document the algorithms here. There's just too much good information on the web already, and I am only willing to point you to what is already out there.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this