Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - lambdamu

Pages: [1]
1
Support / Re: General question regarding static sprite batching
« on: February 14, 2013, 02:41:53 am »
I don't really understand what do you mean by commit, since I'm creating the static sprite batch programmatically. I did call the build function though. Just in case, here's the snippet of my code in question:

Code: [Select]
tk2dSpriteCollectionData scd = (tk2dSpriteCollectionData) Resources.Load("BGCollection", typeof(tk2dSpriteCollectionData));
GameObject spriteBatcherGO = new GameObject("BGSpriteBatcher");
tk2dStaticSpriteBatcher staticSB = spriteBatcherGO.AddComponent<tk2dStaticSpriteBatcher>();
staticSB.spriteCollection = scd;
spriteBatcherGO.transform.parent = transform;

tk2dBatchedSprite[] batchedSpriteList = new tk2dBatchedSprite[noOfRows * noPerRow];
int index = 0;
for (int i = 0; i < noOfRows; ++i)
{
currentHeight = startHeight + i * spriteHeight;
for (int j = 0; j < noPerRow; ++j)
{
tk2dBatchedSprite batchedSprite = new tk2dBatchedSprite();
batchedSprite.spriteId = 0;
batchedSprite.position =  new Vector3((i % 2 == 0)?widthArray[j]:widthOddArray[j], currentHeight, tempZ);
batchedSprite.color = _color;
batchedSpriteList[index] = batchedSprite;
++index;
}
}

staticSB.batchedSprites = batchedSpriteList;
staticSB.Build();

I've done a quick check and there is no commit function for tk2dStaticSpriteBatcher... or am I looking in the wrong place?

2
Support / Re: General question regarding static sprite batching
« on: February 13, 2013, 03:57:28 am »
Thanks unikron, your post has been very helpful!

Just an additional question: Must all the sprites in the sprite batcher come from the same sprite collection?

--edit--
I realized yes, for each sprite batcher the sprite must be of the same collection. However if I want to extend beyond a single sprite collection I can create multiple sprite batchers, have I understood this portion correctly?

--edit2--
I've managed to get the basic static sprite batcher working, but just to clarify, can I change the colour (like have some sort of change in colour with respect to time) of the batched sprites while the game is running?

--edit3--
I have run some tests so far and results are a little... weird. It seems performance is better in terms of rendering time without the sprite batcher? Is this expected due to the savings tradeoff with VBO? Or could it be I have been doing something wrong...?

Without static sprite batcher:
Graphics: 89.1 FPS (11.2ms)
Draw Calls: 2 batched: 14
Tris: 44 Verts:92
Used Textures 2 - 192.3 KB
Render Textures: 0 - 0B switches: 0
Screen: 320x480 - 1.8 MB
VRAM usage: 1.8 MB to 2.1 MB (of 256.0 MB)
VBO Total: 236 - 171.1 KB
Shadow Casters: 0
Visible Skinned Meshes: 0 Animations:0

With static sprite batcher:
Graphics: 86.5 FPS (11.6ms)
Draw Calls: 2 batched: 14
Tris: 44 Verts: 92
Used Textures: 2 - 192.3 KB
Render Textures: 0 - 0 B switches: 0
Screen: 320 x 480 - 1.8 MB
VRAM usage: 1.8 MB to 2.1 MB (of 256.0 MB)
VBO Total: 211 - 137.6 KB
Shadow Casters: 0
Visible Skinned Meshes: 0 Animations: 0

I have screenshots but I don't know how to upload them here...

3
Support / General question regarding static sprite batching
« on: February 08, 2013, 05:05:26 am »
Hi all!

I have been reading the documentation about static sprite batching, and I admit I don't really have much background knowledge about rendering. I have several questions regarding the use of sprite batching:

1. Can static sprite batches be created programatically?
2. For the static sprite batch, does it mean I can't do anything to the individual sprites inside the batch in the game scene while it is running? Like to move the position of the sprites or animate the sprite?
3. Imagine a case where I have to create a background, whose size is determined at runtime, by tiling a single texture. If I were to do this programmatically, will sprite batching be faster than creating via prefab instantiating?
4. In general, what kind of scenarios can static sprite batching be applied to?

Thanks in advance for any kind response!

Pages: [1]