Sprite Animation

Posted By: preacherX

Sprite Animation - 12/05/16 20:55

Ist es normal/gewollt, dass wenn man ein Sprite, welches z.B. 512 Pixel breit ist, in eine Datei mit 12 Frames legt ("Beispiel+12.png") und dann aufruft, eine Oversize-Warnung erzeugt wird? Bei A7 passierte das meines Wissens nach nicht. Wie behandelt die Engine solch ein Sprite? Kann es bei älteren Grafikkarten dadurch zu Problemen kommen?
Oder wäre es sinnvoller, 12 einzelne Sprites zu erstellen und die Animation mit ent_morph durchzuführen?
Posted By: preacherX

Re: Sprite Animation - 01/04/17 13:35

I will try it in english and with an update of the question:

I'm getting an oversize error if I create a sprite with many frames ("example+12.png") even if one frame is only using a resolution of 128x512 pixel.

In A7 such a sprite was seperated into 12 pieces and generates no error.
But A8 seems to take the complete texture and uses the UV-coordinates for animation. But this could be a problem for some graphic cards, or not?

Can I change this behaviour to A7 somehow?
Posted By: jcl

Re: Sprite Animation - 01/11/17 17:01

From what I see in the source code, A8 indeed uses a single image for sprite animation. I think the only way to use separate images for animation is changing the bitmap in an entity action.
Posted By: sivan

Re: Sprite Animation - 01/12/17 08:34

or you can use a shader to animate the sprite like I did, then you can use rows and columns to keep texture size below limits. I used the following snippet in the pixel shader to animate the sprite LODs of my RTS units (animation frames stored in columns) and use to the correct animation sequence according to camera and character angle difference (stored as direction 0-7, where direction = angle/45), see comments at the end of lines placed a bit far:

to get actual values from entity skill:
Code:
float4 vecSkill41;							// x frame, y width, z direction, w height


pixel shader uv calculation:
Code:
//----------------------------------------------------------
// texture - keep its alpha afterwards
	
float2 Tile = 0;
Tile.x = frac(In.Tex.x * vecSkill41.y + floor(vecSkill41.x) * vecSkill41.y);				// x frame 0..7, 			y unit-width, 			frac for safety				frame is fine with floor(vecTime.w)
Tile.y = frac(In.Tex.y * vecSkill41.w + vecSkill41.z * vecSkill41.w);						// z direction 0..7, 	w unit-height, 		frac for safety
	
float4 Color = tex2D(colorSampler, Tile);										
   
//----------------------------------------------------------

Posted By: preacherX

Re: Sprite Animation - 01/15/17 00:21

Thanks for the response and thank you sivan for the example!
© 2024 lite-C Forums