Texturing Polygons with two points behind LENS...

Game development specific discussions.
Post Reply
ryan_the_jedi_knight
Posts: 101
Joined: Mar 30, 2006 15:58

Texturing Polygons with two points behind LENS...

Post by ryan_the_jedi_knight »

I have managed to come up with a way to texture polygons with one point behind the lens (by figuring out where the two points would intersect on the projection plane, in 2D, and utilizing that), but I'm stumped at the problem when 2 points are clipped.

If anyone could help I'd be eternally grateful.
kinem
Posts: 87
Joined: Sep 24, 2008 15:55

Post by kinem »

I don't understand what you mean by the two points intersecting and so on, but I will tell you the way I textured.

At first I tried a complicated way in which the projection on the triangle on the screen was broken up into right triangles based on where the corners were. The right triangles are easy to program a loop for. That worked for most cases but it was buggy and sucked.

Then I realized that all I needed was to know where the edges of the polygon are on the screen. So now I have two functions of the vertical coordinate, which might be called Xmin(y) and Xmax(y). Each line that forms an edge of a convex polygon is either on the min or the max horizontally. Of course it is clipped to the rectangular screen. So if I can draw a wireframe projection of the polygon, then I have all of the information to find Xmin(y) and Xmax(y). This works just as well for convex polygons with any number of sides as it does for triangles.

Then I proceed (checking my 1/Z buffer) from Xmin to Xmax, going horizontally to keep the memory cache happy. I don't texture yet; I only do that at the end of the frame when every pixel in my polygon buffer knows what polygon (if any) is shown there.
Post Reply