DecalBatch now in libgdx

Update #2: Fixed things up. I’d advise you to check out the DecalTest linked to at the bottom of this post. Use a CameraGroupStrategy for best results (and OpenGL ES 2.0 compatibility)

Update: the API is kinda strange, i will change things around a little and make it compatible with GLES 2.0 as well. Hold out for a bit if you want to use it in production (1 day)

Took me quite a while, but today i integrated Vevusio’s super awesome DecalBatch into libgdx. What is a DecalBatch? Basically the same as a SpriteBatch but for 3D. You can render rotated/scaled/translated rectangles with a TextureRegion applied to them using the z-buffer for depth sorting.

Follow this link to learn more. There are two new tests in the gdx-tests project called DecalTest and TransformationTest which should give you a good idea about how this thing works. Additionally there are extensive Javadocs of course.

Here’s a pic:


Thanks to Vevusio for this great contribution. He left the community a while ago it seems, which is kinda sad.

7 thoughts on “DecalBatch now in libgdx

  1. Oooh, it\’s finally in, that\’s really cool!

    I just started using it a few days ago and have found a small problem with it, basically I used to use SpriteBatch and simply had one Sprite object per textureRegion that I moved around and then added to the batch for everything that needed the same texture. When I moved over to DecalBatch however, I couldn\’t do that, because when you add a Decal to the batch it will store it there in some kind of array or list, and because of that, when I then alter it\’s position and add it again, both of them will get altered, so I had to use different a Decals for each.

    I guess that it\’s more of an inconvenience than a real problem but it would be nice if you could change it to be more like how SpriteBatch does it.

  2. The thing is, DecalBatch can’t work like SpriteBatch. It’s underlying principle is different in that it can’t immediately draw stuff to an intermediate buffer as SpriteBatch does. It has to keep track of things, then before drawing sort stuff (via a GroupStrategy). So, you will have to create multiple Decals for your objects :/

  3. It’s only for rectangles or for various 3d objects? If only for rectangles what is the use case? Old fashion game in Wolfenstein 3D style?

  4. is there some guideline on what the performance overhead is for using these decals rather than a sprite batch?
    the code for doing an isometric map was great and used just a straight 2D spriteBatch for the floor plane. however, this requires some odd translations of the viewport – it would be more convenient to use decals, but i worry if there is a huge overhead for doing this, eg a 20×20 floor of tiles could be a big multiple for any small performance difference.

Leave a Reply

Your email address will not be published.