Jump to content
  • Advertisement
Sign in to follow this  
ToastFlambe

Why split polygons into triangles?

This topic is 4887 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

For a software rendering engine, what are the advantages (if any) of converting , say, a quad into two triangles before drawing? I know this is what modern graphics cards do but is it so they only have to work with a fixed number of vertices or is there some "mathematical" advantage of trangles?

Share this post


Link to post
Share on other sites
Advertisement
The main reason for working with triangles is that all corners are always in a single plane. So interpolation of the in between 'pixels' is determinable.

cheers

Share this post


Link to post
Share on other sites
Its mostly a question of:

1. Simplifying the hardware
2. Simplifying the design
3. Improving the speed by adopting a constant special case

Triangles are a special case of a polygon. They are guaranteed to be always convex, and to render them, you don't need a loop or a sophisticated algorithm. Many algorithms (barycentric coordinates, for example), can be applied to triangles directly, while they require a more complex general case algorithm for other convex polygons.

Triangles are also the most basic polygon possible, so they are sort of a common element... And well, since you can convert any polygon into a set of triangles or a triangle strip, its just not a problem, is it?

Share this post


Link to post
Share on other sites
you cant really screw up a triangle. Only 2 cases where 3 points doesnt make a triangle. the 3 points are all the same point. Or the 3 points make up a straight line. and the first case is really just an extension of the 2nd case

Share this post


Link to post
Share on other sites
Quote:
Original post by Raymond_Porter420
you cant really screw up a triangle. Only 2 cases where 3 points doesnt make a triangle. the 3 points are all the same point. Or the 3 points make up a straight line. and the first case is really just an extension of the 2nd case


That's not really the reason, because you could also say that a triangle is a special case of a quad with two coincident vertices. These special cases are not a big problem, not even for n-gons.

ernow nailed it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Alt F4
For a software rendering engine, what are the advantages (if any) of converting , say, a quad into two triangles before drawing? I know this is what modern graphics cards do but is it so they only have to work with a fixed number of vertices or is there some "mathematical" advantage of trangles?

For a software renderer it can actually make sense to use quads. Mainly the polygon setup and rasterization time is halved. On the other hand, it becomes messy to work with, and most 3D formats only offer triangles. The performance benefit is also only minimal.

Or let's put it this way: I've seen several software renderers with support for quad rasterization, but without actually useful features like even texture mapping. So just don't waste your time with it. Maybe in a few months when you're reaching 100 FPS and you want 101, you can give it a try.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
another more important reason is triangles can approximate arbitrary topology, which quadrilaterals cannot. consider a circle or a sphere

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
sorry to post twice but another importatnt reason is scan line interpolation of triangle is rotatioaly invarient which rectangle and ngon scan line interpolation is not. scan line interpolation of triangles is mathematically equivilant to barycentric interpolation while scan line interpolation on a quad is NOT equivilent to bileanear interpolation across the quad. consider a quad with one pair of oposite verticies white and another black and imagin using scan line interpolation as it rotates and you will see it is rotationaly variant. also it I state the probably obvious that scan line interpolation on the two triangles that make up the quad is equivilent to bilinear interpolation across the quad, which is what we want in terms of quad rendering.


Tim W.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!