Sign in to follow this  

what is better: quads or tris?

This topic is 4733 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
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
honestly i do not care about direcxt as my engine is build on the OOP principle: deploy and forget. the engine just feeds the data to the render module. the module itself is then responsible for optimizing stuff. it can even store the model internally as tris, fans, strips or whatever if this suits the API better.

a benching of using tris only models or mixed models might be interesting. i guess though that with vertex buffers things should be less different in speed than using pure calls (like i use for the moment as a matter of testing).

how quads are split up i donno but i've set anyways the rule that quads are only allowed in models if they are mostly coplanar and will not break (meaning, involved in skin bending points). terrain patches use them too though as it is much simpler to work with quads than having to break it up into tris. but that's a first implenentation... all can change without me having to touch the engine layer-

Share this post


Link to post
Share on other sites
for certain data sets eg *particles/HUD stuff etc, quads can run faster than tris (less data sent).
also a nice reason to use quads, they look better with nearly ever model when its shown in wireframe than its looks if u used triangles

*yes there are pointsprites but they suck

Share this post


Link to post
Share on other sites

This topic is 4733 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this