Page 1 of 1

Creating a texture out of multiple images

Posted: Thu Apr 17, 2014 10:23 pm
by legacyblade
Hello everyone! I have until very recently been developing my game in 2D. But as development has gone on, I realized I'd like to switch to a 3D environment (as I'm going through great lengths to mimic 3D for my landscape via psudo mode7-ish stuff). I wish for my characters to be 2D sprites in the 3D environment.

I figured the simplest way to do this would to be to create an image plane and render the sprite to that, then draw the plane in the world. However, my sprites are comprised of several parts that are rotated dynamically to create smoother movement. I'm trying to do something similar to what's done in the paper mario games. (https://www.youtube.com/watch?v=g6hw-tJy6QU).

How would I go about creating a texture by combining and rotating various images? The head is one file, the arms are each their own file, the three animation frames for the foot are a file, etc. I want to place the head down, rotate the arm into whatever location it should be for the animation it's in, place the torso, then place two copies of the feet in their proper animation frame. Then I want to render this texture to a plane the dimensions of the resulting texture.

If the above is infeasible, would it be better to have a separate image plane for each part of the body (including eyes and mouth)? Or is this beyond the scope or Irrlicht?

There will be dozens of these sprites on the screen at any given time, so efficiency is a consideration.

Re: Creating a texture out of multiple images

Posted: Fri Apr 18, 2014 7:40 am
by hendu
You're considering ~20 sprites * N drawcalls. N = 1 if premade texture, but with cpu overhead; N = 6? if you draw each body part separately.

120 vs 20 draw calls is not a big difference even on a four-year old mobile ARM cpu. You can easily afford it, and have more than good performance everywhere. Further, as you don't have the cpu overhead of creating a texture and moving the data over, it may even be faster.

Summary: both ways are feasible, using one plane per body part is easier and likely faster.

Re: Creating a texture out of multiple images

Posted: Mon Apr 21, 2014 8:13 pm
by Neirdan
Code first, optimize later.

Re: Creating a texture out of multiple images

Posted: Fri Apr 25, 2014 1:23 am
by Mel
I'd recomend you to use simple skinned meshes created using planes which always faced the screen, or using a shader to perform such effect on its own, that's the simplest and fastest way. In fact, drawing a rotated image is the same as drawing a quad with the image as a texture and rotate the quad, hence, the skinning solution is your best bet here, and it is not a bad bet.