Optimization for changing pixels of sprite in Unity3D -


problem :

after month, i'm coming prototype painting on sprite mini game. see in thread i've figured out solution painting on sprite , because of big nested loop in script, mini game isn't @ situation (i mean low fps). i've tried use method instead of texture2d.setpixel() used texture2d.setpixels() before fps low.

so right now, don't find solutions problem. last thing comes mind parallel for.

what think, guys ?

answer :

with pocketiger see. used texture2d.setpixels , texture2d.getpixels mini game 256 * 256 sprite, game on 60 fps , 512 * 512 sprite, on 25 fps. it's better use texture2d.setpixel , texture2d.getpixel still it's not , need use opengl commands. fps rather texture2d.setpixel it's not because of using texture2d.setpixels it's because, limit loop statement smaller square rather whole sprite order moving in loop it's not much.

there's few things have out when using setpixels().

1) first of if need update multiple pixels never use setpixel() setpixels() instead because that's way better performance.

2) apply() function pretty heavy on performance , calling every frame draw performance lot well. if looping sure exclude apply function loop.

for(var i:int = 0 ... blahblahblah) {  setpixel on i; } apply(); 

3) helps lot if texturesizes on power of 2 (32x32 // 64x64 // 128x128 // 512x512 .... etc.). setpixels() , apply() commands perform way more poorly otherwise.

if you've tried i've suggested , fps count still low can still try decrease size of textures or around , experiment native opengl calls way faster require deep dive shaders , whatnot.

here's source thread gathered information if interested in more details. kudos unity community.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -