3D flag: any tips for optimisation?


I’ve made this 3D flag for my super cool DJ visualization tool. I am curious to know if any of it is particularly taxing on the processor or whatever (120 sprites) or if anyone can think of any better ways to do this (sometimes people say things like “animating the tint is hugely taxing!” and i want to see if there are any things like that which I can avoid).

For example, right now each sprite is in a separate GO. But I could easily reduce the number of GOs, and therefore the number of animations, by about 2/3 (although the number of sprites would be the same).

	for i = sprites,1,-1 do
		sprite.play_flipbook("go"..i.."#sprite", ""..i)
		self.tint = vmath.vector4(0.1,0.14,0.324,1)
		go.set("go"..i, "position.x", spritewidth*i)
		go.animate("go"..i, "position.y", go.PLAYBACK_LOOP_PINGPONG, ygoal, go.EASING_INOUTSINE, duration, (i)/factor)
		go.animate("go"..i.."#sprite", "tint", go.PLAYBACK_LOOP_PINGPONG, vmath.vector4(0.8,0.3,0.7,1), go.EASING_INOUTSINE, duration, (duration/4)+(i/factor))
1 Like


That’s made out of 120 sprites…
…How? It’s a bunch of vertical slices or something?
…And it looks like each sprite has a flipbook animation, tint animation, and position animation…

“Hugely taxing” is very relative. If you just want one of these flags, no problem, but if you want 100 or more of them, that might start eating up your processing time. Personally I’d say that 120 sprites for a relatively simple animation like this is pretty excessive, but depending on what you want to do, that may not matter at all. You’ve already done the work.

I think the most efficient (at runtime) method would be to bake out this animated flag into a single flipbook animation—one sprite, one animation.

Another way: Use a single flat image of the flag with empty space on top and bottom and use a fragment shader with a sine wave to animate the waving offset and lighting.

Third: Use a single image with no extra space, and a subdivided rectangular model. Use a vertex shader to make it wave (in 3D) and a simple fragment shader to apply the lighting (similar to the default model shader).

1 Like


Yep, vertically sliced automatically using a tilemap :slight_smile: but it’s just one image per sprite, I use play flipbook to set the sprite but i use go animate for the position.y and the tint.

You are right, a flipbook animation would probably be best. I didn’t even think of that as I was having so much fun with this animation method. I might see if there is an easy way to make a screen recording into a sprite flipbook…

1 Like