# get all pixels of a triangle

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

## Recommended Posts

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 on other sites
You have the XYZ in the model space? in World space? in View space or in Projected space?

Luck!
Guimo

##### Share on other sites
i have x y z in view space. and the additional u and v values in my projection view.

##### Share on other sites
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.

1. 1
2. 2
3. 3
Rutin
19
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631424
• Total Posts
3000008
×