is rendering invisible sprites in spritebatchnode cheap?

Forums Programming cocos2d support (graphics engine) is rendering invisible sprites in spritebatchnode cheap?

This topic contains 3 replies, has 3 voices, and was last updated by  cheaslum 2 years, 8 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
Author Posts
Author Posts
July 31, 2011 at 10:34 am #233873

cheaslum
Participant
@cheaslum

Is rendering invisible sprites in spritebatchnode a cheap process?

Instead of removing and adding sprites in each frame, I am making them invisible and visible. Is this correct approach?

Can someone explain what happens when sprite being rendered in spritebatchnode is set invisible?

Does it make any opengl call for the sprite set invisible?

July 31, 2011 at 10:49 am #341387

cocos2dbeginner
Participant
@cocos2dbeginner

You could just test it. Set a breakpoint to the opengl call and see if it is called.

But I think it’s still called if you set it to invisible. And I think it uses the same memory and cpu power like a visible sprite.

But I’m not really sure…

July 31, 2011 at 12:13 pm #341388

ImpresionesWeb
@impresionesweb

I’ve found some posts:

http://www.cocos2d-iphone.org/forum/topic/19028

Here @araker says:

“If they’re outside the screen, their data will still be send to the GPU, but they won’t be drawn anymore. So the overhead for bullets outside the screen is less, but still something to take into account depending on the number of bullets. When you’re experiencing performance issues try to set visible to NO when they’re outside the boundaries.”

http://www.cocos2d-iphone.org/forum/topic/11692

In this one @riq recommends to set NO to the visible property of the layers/batches and @araker (again!) explains why:

The batchNode calls -updateTransform of each child in its -visit (= where the magic happens). If the sprite is not visible it replaces its quad in the textureAtlas of the batchNode with a empty quad (line 487 in CCSprite). This empty quad still occupies the same amount of data, but will be discarded faster than a normal quad by the GPU.

I hope it helps to understand it better

July 31, 2011 at 11:03 pm #341389

cheaslum
Participant
@cheaslum

thanks …..

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.