Quantcast
Channel: Answers for "Script vs Shader for animated texture"
Viewing all articles
Browse latest Browse all 10

Answer by ShenYuan

$
0
0
In my point, put uv calculation into the GPU(shader) side may not be a good idea especially when your target platform is mobile or some devices with poor graphic processor. What's more, calculate uv offset by using "modf(GameTime / Cycle)" can easily cause precision problem when the game need to be played for a long time or "Cycle" is too small. I myself have encountered this problem many many times. But if you made your calculation on the C# side, this gonna be a very very easy problem(just make a private sum time value instead of a global one, and reset it after every "Cycle"). I used to only put animate logic in shader when it happends on ParticleSystem. Because the particle system of my previous graphics engine only provide normalized particle age for each particle vertex. The only and efficient way for me is calculate them in shader. Keep in mind "switch texture" will cost extra performance. If you have a lot of instanced materials using different texture in one frame, then DO NOT USE Material.SetTexture(). But sprite-sheet have a big disadvantage, all frames of the animation must load at the same time and you can not unload those "Out of sight frame" (because they are stored in one texture). This means a big waste of memory some time. If you are trying to display a non-loop, long and high resolution animated frames, go for the Material.SetTexture(). Also don't forget use Resources.Unload() to handle the memory issue. Or just simply use VideoTexture(not available on iOS, but u can buy one plugin developed by PRIME31).

Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>