2
\$\begingroup\$

I'm currently working on a dynamic 'door' creator, and I'm trying to decide which is more efficient. Not much experience with 3D render speeds, so I'm asking before I choose which direction to go because its a lot of work either way. (The doors will be able to open/close.)

enter image description here

So I came up with two possibilities.

  1. I generate all the triangles (as in the left picture), and go on my way.
  2. I generate only two triangles, then create and save a whole new texture that is filled only with pixels that are not 'covered' by the door (the others are marked as transparent). I would then dynamically add the texture to a texture atlas. Then when the outside portion (gray) of the door is drawn, it would appear as in the right picture.

Hence, more vertices, or more textures? Before I start down one road, any advice on this? Or any other suggestions?

Thoughts: Creating a new texture for each instance would eventually take up too much memory, but they would be reusable. My gut says this would be better for a small game world with not many unique doors, so maybe I should just implement both and let the user decide.

\$\endgroup\$
1
\$\begingroup\$

If the engine or API you are using already has boned/skinned animation capability, creating a door with a single joint and no vertex weighting would handle the open/close animation with a single texture... If you have only a few unique doors modeling them should not be that big a deal. This has the benefit that the door is still in the scene, and you can animate the open/close easily. This would be the solution I would use.

It seems to me you are talking about subdividing the mesh based on the door texture and that just feels backwards to me. Also breaking the object into 2 meshes so you can animate opening the door will be a bit of work, as will be manually handling the animation.

If you want to go the transparent texture route, there is a dirty trick -- you can paint the door pixels with alpha 0 and and the shader/render pipeline will ignore the alpha unless you jump through some specific hoops to turn on blending in the rendering pipeline, at which point the "door" disappears until you stop enabling/disabling blending around the draw call for that object. This technique has no "door" in the world, the door will just be visible or not visible with no open/close animation effect unless you mess around with the blend settings to animate the transparency fading in and out.

From my point of view -- any graphics card with a gig of ram can handle a crudload of doors using any of these techniques.. none of them have a particular heavy rendering load compared to any of the others (a slightly larger vertex buffer vs 2 textures or a blend state change while rendering is trivial) .. and only the subdivision method really requires anything in the way of CPU overhead, and that's pretty much one time for each unique door type, so I don't see any real efficiency issues with any of these choices -- the question is what gives you the effect you want during game play.....

\$\endgroup\$
1
  • \$\begingroup\$ a second texture that hold where the door is (just a boolean map), 2 quads and some discards in the shader can do wonders \$\endgroup\$ – ratchet freak Sep 19 '14 at 8:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.