Jump to content
  • Advertisement
Sign in to follow this  
RPTD

what is better: quads or tris?

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

introduction: just had this discussion on some other forum. i've seen so far only game engines using tris as their main sources for models and other render stuff. as for my engine i noticed fiddeling around with my code that using quads together with tris that i managed to speed up rendering. i am though not sure why other engines do not use it. discussion questions: - are quads faster than tris or does it only 'look' like they are? - would an engine allowing quads be faster than a tris only engine?

Share this post


Link to post
Share on other sites
Advertisement
In the end it's all triangles. Quads can be implemented by the driver or API, but the hardware has no special interpretation of quads. On the other hand, quads are often generated by the modellers because models look smoother when constructed from them.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quads are converted to triangles, triangles are the native format of the GPU not quads. Drivers are written with triangles in mind so the performance you see will vary depending on the video card and how up-to-date the drivers are. You might be saving bandwidth but you are far better off using 32 bit integers for a 32 processor and triangles for a triangle rendering GPU.

Share this post


Link to post
Share on other sites
Direct3D does not have quads, so if you want to support more than OpenGL, quads are out.

Also, quads are not inherently faster than triangles if you use properly formed strips -- the data for a QUAD_STRIP and a TRIANGLE_STRIP is in fact exactly the same size and same rendering speed. If you use indexed lists, there are slightly fewer indices in a quad mesh than a triangle mesh, but instead you get mesh modeling constraints.

Share this post


Link to post
Share on other sites
what modelling constraints you mean? if something doesn't work with quads (because it's non-coplanar or ould bend too much in an animation) you can use tris.

also models usually tend to not be prepared in a format where you got strips or fans already. to optimize them you need some preprocessing steps. possible but would slow down loading process.

Share this post


Link to post
Share on other sites
If quads suit - use them. They are a specialised term. This means they may just be expanded to tris, or they may be optimised in some fashion (shared normal & simpler poly scan?). So basically if what you intend to draw to the screen is infact a quad then use the term & let gl make the best decision regarding it. You mentioned you may of saw a performance gain? Well using quads means less functions calls & smaller vertex arrays etc & that's got to be a good thing right?
Quote:
Direct3D does not have quads, so if you want to support more than OpenGL, quads are out.

Since when is "supporting" Direct3d supporting more than OpenGL? Direct3d covers a much smaller ground machine & os wise, which is all covered by gl anyway.
I will agree that using tris may provide room for expansion on future libraries for systems not covered but gl. But to be honest it's not worth the bother. If you do ever need to change it ain't gonna be many lines of code to split a quad into a couple of tris upon model loading anyway.
Often when coding you come accross specialised functions & even if you do know how they work it makes more sense imo to use the specialised name than add that few extra lines of code. It makes for more coheriantly readable code & the specialised version you access may even change in the future prehaps offering optimsation for the specific differences that it offers.

Bah that's all I can think to say, happy coding & happy last day

Share this post


Link to post
Share on other sites
Not really sure, but could sending quads to the GPU be a small speedup?

Granted, tri's are the native element of GPU's, so the quads will get converted. But what about the small speedup you get when feeding the GPU less information..? A quad is defined by less data than the two triangles it's made up from. Could this be the reason why OP got his little speed increase?

cu,
CipherCraft

Share this post


Link to post
Share on other sites
Surely a quad is similar to a triangle strip (or indeed, fan) consisting of only two triangles?

Or is it just me?

Either way, you're saving a little bit of time (presumably) by sending only four vertices rather than six (for two triangles)

Mark

Share this post


Link to post
Share on other sites
Quote:
Original post by hplus0603
Direct3D does not have quads, so if you want to support more than OpenGL, quads are out.


*ahem*maybe not on the PC*ahem* [smile]

Unless you're doing something like trying to fake a batch of quads by doing single batches of two-triangle strips or something, this isn't the kind of optimization you want to worry about until you're at the point where you can get hard profiling data.

I wonder what OpenGL's rules are about quads when they're not coplanar - where does the diagonal go?

Share this post


Link to post
Share on other sites
Quote:
Original post by superpig
Quote:
Original post by hplus0603
Direct3D does not have quads, so if you want to support more than OpenGL, quads are out.
*ahem*maybe not on the PC*ahem* [smile]

I was going to let that little piece of inside information remain inside info... but since you brought it up. The docs for the implied platform clearly indicate that when using quads, it is internally converted into two triangles, just as others have said. So, yeah, while it's available, there is no reason to use it. A cache friendly trilist should have the same speed as a cache friendly quadlist. The time it takes to fetch two more indices is pretty much zero, which is going to be overshadowed by the time it takes for the vertex shader and pixel shader to run for those primitives. If you have lots of back facing, or maybe even *very* small triangles, there is a chance that index fetch times could show up. In such cases you're better off adding decent LOD support rather than quad support.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!