get all pixels of a triangle

Started by
2 comments, last by grhodes_at_work 19 years, 5 months ago
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.
Advertisement
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
i have x y z in view space. and the additional u and v values in my projection view.

please help me out guys! :-)
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.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net

This topic is closed to new replies.

Advertisement