ldebrasi

Hi Spine Team,

I found a bug in the libgdx runtime. If you convert a region into a mesh, this will be invisible in the game. That simple.
Spine version: 1.7.10
Libgdx version: latest nightly
Libgdx-runtime version: latest nightly.

Attached an example...
spine-bug.jpg
You do not have the required permissions to view the files attached to this post.
ldebrasi
  • Posts: 10

Nate

You need to draw using PolygonSpriteBatch. SpriteBatch doesn't know how to render a mesh.
User avatar
Nate

Nate
  • Posts: 9281

ldebrasi

Thanks Nate! It works ;)
ldebrasi
  • Posts: 10

just4phil

[SOLVED]

hi
i have an ghost-image with mesh and mesh-animation directly on the bone "root"
root -> slot -> image with mesh

i use a polygonspritebatch.
i see my ghost and the eyes are animated (eyes are only skeletal animated)
but the mesh-animation does not happen....

is there anything else i have to do to get the mesh animation rendered?
monster.spineAnimationstate.update(deltaTime);
monster.spineAnimationstate.apply(monster.skeleton);
monster.skeleton.updateWorldTransform();

spineSkeletonRenderer.draw(polygonSpriteBatch, monster.skeleton);
bye
phil

Unbenannt-4.png
You do not have the required permissions to view the files attached to this post.
just4phil

Kickstarter Backer
  • Posts: 23

just4phil

SORRY.... forget it. now it is working.
i have no idea what the problem was.... i guess some sort of eclipse refreshing....
just4phil

Kickstarter Backer
  • Posts: 23

Cuellarjmcg

Just a quick question: using PolygonSpriteBatch affects performance over regular SpriteBatch? I ask this because I read that SB is optimized for drawing quads, so if I use the PSB, will it be the same if I draw regular sprites?

I was going to test this, because my game right now works good on old hardware (using SB), so the difference will be noticiable (if any). BUT, a little of technical info would be good :D
Cuellarjmcg

Kickstarter Backer
  • Posts: 92

Nate

SpriteBatch uses indices set up for quads. It only needs to transfer vertex colors and positions to the GPU. PolygonSpriteBatch has to transfer indices and vertex colors and positions. How much this affects things depends. Give it a try, I'd like to hear how it goes. :)
User avatar
Nate

Nate
  • Posts: 9281

Cuellarjmcg

Err... PolygonSpriteBatch doesn't implement Batch (but SpriteBatch does?) so I cannot use it with Stages .___. I use Actors a lot so... maybe this can be changed in libgdx?
Cuellarjmcg

Kickstarter Backer
  • Posts: 92

Nate

Yeah I considered it when I added Batch but haven't got to it. Unless you mix your SpriteBatch and PolygonSpriteBatch drawing extensively, it would be better to keep them separate so you don't have the polygon overhead for drawing quads. If you want to use Spine skeletons in scene2d then yeah, you'd probably want PolygonSpriteBatch for everything to reduce flushes. I'll have it implement Batch soon.
User avatar
Nate

Nate
  • Posts: 9281

Cuellarjmcg

Nice, thank you very much :) well, because I designed everything to use one batch (and less render calls, one for UI and one for the game area), I would like to test it at the same scenario (to see just how much overhead it adds).

Anyways, nothing really urgent, so I will wait patiently :)
Cuellarjmcg

Kickstarter Backer
  • Posts: 92

Nate

It would be better to use two batches, SpriteBatch for the UI and PolygonSpriteBatch for the game area. If you use PolygonSpriteBatch for the UI, performance will be worse.
User avatar
Nate

Nate
  • Posts: 9281

Cuellarjmcg

Ah... good point. Ok I will do that change, so it will be ready for the update (I will need it to implement Batch still, as I use one Stage for UI and one for the game area .__.).

Thanks for the tips :)
Cuellarjmcg

Kickstarter Backer
  • Posts: 92

Nate

User avatar
Nate

Nate
  • Posts: 9281

Cuellarjmcg

Thanks Nate!. Today nightlies had the change, so I did some tests with the same scene, same conditions (drawing only quads, same quantity of actors, etc)...

And the results were really good! Using SpriteBatch for gui, and PolygonSpriteBatch for the game scene (which draws spine skeletons, simple sprites, particle effects, etc), the performance wasn't really bad - only like 1 or 2 fps less in a really crawled scene. It isn't noticeable, so I will leave it like that and start experimenting with FFD.

Thanks again for your work, both of you :D (Nate and Shiu).
Cuellarjmcg

Kickstarter Backer
  • Posts: 92

Nate

That's great to hear! What device was it?
User avatar
Nate

Nate
  • Posts: 9281

Cuellarjmcg

Nate wrote:That's great to hear! What device was it?
LG P350, which is really old hardware (natively, it runs froyo, but I use a custom gingerbread rom). The game runs at 60 fps, with drops of 5-10 fps when there are many effects on screen. With the change, it runs basically the same, 7 or 12 fps less under the same circunstances but still isnt noticeable.

I have another test device, a LG L3II, which is low end too but there the game runs better than on the P350 (solid 60 fps, even with many effects).
Cuellarjmcg

Kickstarter Backer
  • Posts: 92

kosanake

[SOLVED]

Ok, with casting to (PolygonSpriteBatch) it works :)
@Override
public void draw(Batch batch, float parentAlpha) {

skeletonRenderer.draw((PolygonSpriteBatch)batch, skeleton);

super.draw(batch, parentAlpha);
}
Hi guys! Is there any way to use draw() method of an actor?
Now i have to pass PolygonSpriteBath through actors constructor and then draw in act() method (and it works fine):
@Override
public void act(float delta) {

skeleton.setX(getX());
skeleton.setY(getY());

animationState.update(delta);
animationState.apply(skeleton);
skeleton.updateWorldTransform();

polygonSpriteBatch.begin();
skeletonRenderer.draw(polygonSpriteBatch, skeleton);
polygonSpriteBatch.end();

super.act(delta);
}
My scene2d constructor:
stage = new Stage(0, 0, false, polygonSpriteBatch);
This code in draw doesnt render mesh:
@Override
public void draw(Batch batch, float parentAlpha) {

skeletonRenderer.draw(batch, skeleton);

super.draw(batch, parentAlpha);
}
kosanake
  • Posts: 22

hydrip

I have hundreds of particles and some animated characters, and they are in random order. The begin() and end() are too heavy to be called multiple times on each render step. I need a way to use PolygonSpriteBatch only for the characters, and SpriteBatch for the particles, all with one begin and end. Is there a sample code available somewhere?
hydrip
  • Posts: 19

Nate

Try PolygonSpriteBatch for both skeletons and particles. That is the only way to do it in a single batch.
User avatar
Nate

Nate
  • Posts: 9281

hydrip

Nate wrote:Try PolygonSpriteBatch for both skeletons and particles. That is the only way to do it in a single batch.
That's how I did it from the beginning. Now, at a later stage in the project I'm trying to optimize the code, and I thought mixing the rendering with PolygonSpriteBatch and SpriteBatch would increase the performance.

I did a quick test and didn't notice any performance difference between PolygonSpriteBatch and SpriteBatch on my 2 year old Android tablet. I rendered the whole scene (mesh animations excluded) with both of them, and the performance was identical.

Another interesting finding was that the begin() and end() methods didn't have almost any performance impact either when I repeated them for each entity separately. So, I literally had hundreds of begins and ends run each render step, and I saw only a very small frame rate hit; maybe 2 - 3 frames.

Oh well, I have to find some other way to optimize my code.
hydrip
  • Posts: 19


Return to Runtimes