So I was playing around with XNA working on a 3d engine with 2d sprites as characters and objects. After a while I became very unhappy with the way the sprites were being scaled and billboarded so I created a GameSprite class that takes all the information from the texture2D(pngs) and turns it into VertexPositionColor quads on init.

these are drawn with a basic effect, a struct quad, and a quadList.

        foreach (ColorQuad quad in currentFrame.quadList)
                quad.Indices.Length / 3);

(frames are different quads chopped up from the original image for animation, like a sprite sheet)

This creates a great 3D recreation of the sprite that can be zoom entirely with no blur.

Each GameSprite has its own basic effect file.

I was wondering if there was a way, maybe during LoadContent, that I could create these vertices and turn them into models for easier drawing and rendering in this 3D world and if this is even a good way to go about this and if I might experience longerterm problems using lots of these GameSprites and their many quads.

Thanks for reading!

  • \$\begingroup\$ It's definitely doable, either before run time (Make a content processor that creates a Mesh) or at runtime (Much the same, or you can do something like what you're doing now). A problem you will have though is that you're doing a draw call for each region in the picture, which means you have about 500 ColorQuad regions before you're being bottlenecked. You should be taking all those vertices and making them a single buffer of triangles, and drawing an entire sprite (or hell, even and entire group of sprites) in one draw call. \$\endgroup\$
    – Phil
    Commented Jan 13, 2013 at 5:34
  • \$\begingroup\$ This seems like very much the wrong approach. Why not draw the sprites with SamplerState.PointClamp? (see this question) \$\endgroup\$ Commented Jan 13, 2013 at 5:55
  • \$\begingroup\$ Thanks for both your answers thats exactly the kind of information I was looking for. \$\endgroup\$ Commented Jan 13, 2013 at 6:31


You must log in to answer this question.

Browse other questions tagged .