Home Technical Talk

Why can't triangles be stretched over quads?

Triangles are almost always kept in groups of two.
It seems odd to me that one of them cannot be stretched to cover both of them.

(Here, a crappy diagram)

quads.gif

Is the reason computers don't draw groups of 2 triangles like this because it would burn through texture memory? (Or maybe this only makes sense in my head...Although I'd gladly have half the texture memory and twice the polygons.)

I have two unrelated questions, but I'd rather not clutter up the forum and post them in one place.

Do you guys know of any tools made specifically for texture baking?
As for as I know, Wings 3D doesn't support it. I'd rather not learn to do it in blender, if possible.

And second, I forgot second.

Replies

  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    I honestly don't know what you're getting at with your triangle question. You can't draw two triangles using one triangle like that, since what if the vertex normals, vertex colour etc are different? Using your method you'd have 3 vertices in completely different places compared to the original "two triangles" which are made up of 4 vertices (and each vertex may hold unique data).
    Not to mention the fact that it's completely changing how your mesh looks...

    To answer your other question, XNormal is a specific texture baking tool.
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    It only makes sense in your head! That would be the most expensive, limiting way to render ever.

    *Modeling would become the most painfull experience in the world ever. how on earth would you control the shape of your quad? you have 3 control points for a 4 sided face. what about ngons?

    *No face would share vertex normals so no smooth shading
    *The model would take more ram because every vert would have a unique Normal/texture coord.
    * This would waste masses of texture memory and texture memory is more of a restricting factor than poly count.

    *Sorting transparent faces is expensive and it would be very slow to render.

    *Things like shadows would be more expensive because they'd have to take into account transparency.
  • Yozora
    Options
    Offline / Send Message
    Yozora polycounter lvl 11
    I'm curious, is this how you would want to make a regular 6 sided cube?

    triangle.JPGtriangle2.JPG

    And then apply an alpha map to make all the corners that point out of the cube invisible?

    Even if you did do that, you'd have to unwrap each face as it's own shell and then somehow figure out how to lay them out in a logical way for texturing, while keeping in mind which corners need to be alpha'ed.

    This is just a cube... I'd love to see how you manage to make anything interesting with this method! The workflow will be a nightmare.
  • Noidea
    Options
    Offline / Send Message
    Good points, but I was assuming they would be modeled normally and ran through a tool.
    It was just an idea ._.
  • Electro
    Options
    Offline / Send Message
    Electro polycounter lvl 18
  • Mark Dygert
    Options
    Offline / Send Message
    Saving a few triangles isn't that important, its not going to markedly increase anything, however applying an opacity map to a bunch of triangles to make a box will no doubt be more expensive than using 8 more tris. It can also cause all kinds of opacity sorting issues.

    I can see it being used for things like particle FX where you might use tris instead of quads but that's hardly ground breaking.
  • rollin
    Options
    Offline / Send Message
    rollin polycounter
    maybe we all don't understand the higher logic behind the question
  • Xoliul
    Options
    Offline / Send Message
    Xoliul polycounter lvl 14
    This is probably some sort of reasoning that follows the lines of "less tri's is ALWAYS better"...
  • Noidea
    Options
    Offline / Send Message
    Xoliul wrote: »
    This is probably some sort of reasoning that follows the lines of "less tri's is ALWAYS better"...
    :) Way to contribute absolutely nothing.
  • Mark Dygert
    Options
    Offline / Send Message
    Well a lot of us are still trying to guess why you would want to do this and in what cases? A little clarification would help defend the idea but as it sits, its pretty useless. Sorry to be so blunt but you chimed back in to point out the worthlessness of a post... with more worthlessness?

    How would you handle deformation?
    How would it handle normals when your defining a corner in the middle of a triangle, but without a vertex?
  • adam
    Options
    Offline / Send Message
    adam polycounter lvl 19
    Hey, I remember having silly questions like this when I was learning too. Relax a bit guys, he was only wondering and now he knows.

    Noidea, I like your user name. :)
  • eld
    Options
    Offline / Send Message
    eld polycounter lvl 18
    And it touches on the greater understanding of how it works under the hood, which is useful for anyone.
  • Xoliul
    Options
    Offline / Send Message
    Xoliul polycounter lvl 14
    Noidea wrote: »
    :) Way to contribute absolutely nothing.

    I'm trying to figure out why on earth you would think in this way. Just guessing that, like many new artists, you have the idea that less tri's is always better. You haven't confirmed this in your reply yet, but I'll just go ahead and say that really isn't true, and that there is a lot more at play here than simply the tricount.
    Things like workflow, how easy it is to create a mesh, in all aspects. Sometimes it's easier to use more tri's so you can unwrap easier or bake easier, making it worth the tri premium. Sometimes it's even worth it to use so many tri's that you don't need textures anymore, like the cars in games such as PGR or GT. Sometimes it's better to combine many small items into a bigger one, to reduce drawcalls at the cost of higher tricount (things like a fence). You also need to consider the speed of current hardware, where there is a "bottom limit" tricount, a point from where lowering an object's tricount won't affect rendering speed anymore.

    ...usefull enough for you now ?
  • pior
    Options
    Offline / Send Message
    pior grand marshal polycounter
    Haha yeah Im with Adam on this one, I think it's kinda cool that you ask yourself that. in the end its totally wrong but who cares, now you know!

    (to put things very broadly, just think that once one triangle is written, the next adjacent one only needs one vert to be defined since one edge+1vert=1triangle. If everything was broken the way you suggest, you'd need ALOT more points stored since you couldn't reuse anything... Cube your way : 18 consecutive verts)

    Now I would have been much more impressed if you actually tried building something like that! Yo gotta test your ideas to the end hehe!

    (btw when I was 10 or so I was certain that duct-taping down the A and B buttons on my soon to be given gameboy would let me win at any platformer by casually pressing the right arrow only hehe. Thinking outside the box FTW!!!)
  • jrs100000
    Options
    Offline / Send Message
    jrs100000 polycounter lvl 8
    Maybe something like that could work as a compression format: define 4 points using three bisected lines and one point from the triangle to reconstruct a square. I cant imagine the savings in file size would be worth the loss of UV mapping, vertex weights/colors, or the ability to determine how that quad will split once its converted back into triangles.

    Edit: also, every quad would end up being perfectly flat. You could control orientation, but there could be no bend defined within the two reconstructed triangles.
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    :D we did descend like vultures didn't we. You could do with learning the tech before you start trying to redefine it though.

    Welcome to the Asylum NoIdea :)

    Pior: gotta try that with my motorbike.
  • Mark Dygert
    Options
    Offline / Send Message
    adam wrote: »
    Hey, I remember having silly questions like this when I was learning too. Relax a bit guys, he was only wondering and now he knows.

    Noidea, I like your user name. :)
    It might not be a silly question if it leads somewhere.
    I agree, be friendly to new people and ideas is a good way to go. But when they get a little uppity... well polycount only has so many cheeks.

    Some of the best innovative ideas start off as hair brain ideas but then turn into something great because someone has the follow through to keep vetting and refining the idea.

    You could actually be doing more harm than "us buzzards" by calling it a silly noob idea. It might very well be just that, but we could see where it goes by asking questions and brainstorming.

    Asking someone to defend their idea isn't picking on them, its helping them to refine it.

    Sooo... Knowing you can fit a quad inside of a tri, how can we use that in game development?

    The only idea I have so far is to use slightly larger triangles instead of quads when doing simple things like particle FX or possibly grass, leaves, bushes maybe even decals? There is a chance that you could double the tri count of bushes, leaves and particles which could be a pretty significant impact visually?

    That brings up new questions:
    1)To get a quad you have to use a pretty big triangle, which means some wasted space? Maybe stretching and distorting the UV's would utilize more of the space? Maybe scale the tri up so it covers 3 tiles putting 3 particles on one tri? For some effects that could be helpful.
    2) The opacity map isn't all that tight, meaning you could have large alphas causing a lot of sorting because they aren't as tight.
    3) More particles probably means more behind the scenes math, tracking their birth, death collision if any, that could get heavy with more?
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    Vig wouldnt using a larger tri for a particle just waste texture space. I mean your going to have to increase the size of the texture or reduce the size of the particles image to fit in correctly onto the tri to maintain a clear border without it being tiled. Quads are good because they natrually match the shape of the uv tile.

    When you think about it for every sprite on a sheet you would be wasting enough room for an additional sprite because of the bleed space needed to mask out the triangle.

    It could work in offline rendering pretty well i guess as the amount of cached geometry would be halved
  • Zack Fowler
    Options
    Offline / Send Message
    Zack Fowler polycounter lvl 11
    Vig: For VFX the main perf consideration is overdraw. Tri/vert count is almost always under the minimum threshold that Xoliul mentioned for all VFX I've seen. If anything artists often do not use enough geometry to cut down on the amount of masked out surface.

    As one example, even ignoring texture memory considerations, it is far cheaper overall to model out an empty window frame than put it on a single quad and mask out everything but the frame. Even when you are using a 1-bit alpha test. Because for each masked out pixel the renderer has to test both the window frame quad's shader for whether that pixel is masked, then in a second step test the unoccluded object and run its shader. If you use only geometry it only has to process 1 pixel shader instead of 2.
  • Mark Dygert
    Options
    Offline / Send Message
    TriBasedParticleSystem.jpg
    Something like that^
    Depending on the particle type you could get a few particles on each tri. You can get creative with the texture and the sheet to utilize more of it. With them swirling around and churning you probably won't notice that 4 particles are moving in unison.

    The same trick can be applied to bushes and leaves too. You just need to know that your texture is separated diagonally into two chunks.

    If you're mapping the tri to 0-1 space its going to be a huge waste, I agree but in some cases it might pay off, like above MIGHT work out better, with 4 visual particles to every engine particle.

    Notice you get one green for every 3 black, so green could be a fiery sprite and black a smokey sprite. If you control the rotation and pivot of the tri correctly you can pull off some neat effects, like fire on the inside and smoke on the out.

    I'm almost positive that this happens all the time in a lot of games which is why I said it wasn't new or ground breaking. Its probably easy to do with quads too. In fact you could probably move the two tris of a quad around on the UV tile to get a bunch of different flavors of particles from one sheet.
  • Piflik
    Options
    Offline / Send Message
    Piflik polycounter lvl 12
    But as Vig said...for example for leaves of trees or bushes you already use alpha mapped planes...if you used one triangle instead you can half the tricount or double the number of leaves...and if you stretch the triangle over the UV Square (so that the green/brown part in the OP's image fits the UV Square exactly) and set the Texture not to tile (should be possible, no?...if not then this idea fails ;)), you don't even loose any texture space.
  • Zack Fowler
    Options
    Offline / Send Message
    Zack Fowler polycounter lvl 11
    Again, for most games fill rate woes from transparency overdraw is a bigger problem than dropping your instanced bush prop from 500 tris to 300. This kind of stuff is just excessive optimization because of the things that Pior and Xoliul mentioned. Each additional vertex in a contiguous surface is cheaper to draw than the first few. Geometry transformation cost comes from the final imported vertex count, not triangle count. Even if you take a tree that uses nothing but quads and cut those all down to triangles, you aren't reducing its geometric memory and realtime cost by half -- you are at most reducing it by 25% because the triangles making up those quads all had 2 verts in common. Instead of 4 verts per surface you have 3.
  • Mark Dygert
    Options
    Offline / Send Message
    I think you can control the overdraw by sticking to shapes that fit well inside of a triangle and keeping in mind how it will tile.
    I'm not saying it will work for everything but it could work well in certain scenarios, specifically with particle FX where you have more to worry about than just tri count, birth/death, collision, scale and position.

    Even for static stuff, 25% is still pretty good, that means for every 4 bushes, you get one? Collectively that could pay off pretty well with things that repeat often? Adding more to sort can cause a crap load of problems in some engines so may you take the saved tris and put them in the scene some other way that doesn't cause sorting issues, like an interesting land mark item?

    It's not a revolutionary industry wide game changer but it could be one more tool in the tool bag if people haven't thought about it that way before.

    Anyway its one way you can apply the OP idea to the industry and have it work, which is better than "LOL U R TEH STUPIZ USE QUAD! LIC MOI CAT PIC!" Which is where this thread was headed...
Sign In or Register to comment.