Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Using many "images sheets" is bad practice?
Started by dodi_games Jun 01 2018 06:56 PM

5 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

dodi_games

[GLOBAL: userInfoPane.html]
dodi_games
  • Contributor

  • 267 posts
  • Corona SDK

Hi guys!

In my search to improve my App performance, I decided to put all the images on images sheets. I decided to do it that way because I could see that the texture memory, with all scenes open, reaches almost 200mb if I use individual images. Now, when changing to images sheets, I could see the texture memory hardly exceeds 80mb, which I found remarkably good but when doing the tests on devices I can feel how they heat up.

I'm not using 2048x2048 images sheets, I decided to use 2 or 3 medium sizes images sheets for each scene. Only the back and info icon are repeated in scenes, which are outside the images sheets and loaded individually, virtually every scene runs with their own images sheets.

What would be your opinion regarding the issue of using or not "image sheets" and in what way it would be correct to use them?

Thanks in advance!

I forgot to said: with individual images I get 200mb in texture memory but no device was heated.

[TOPIC: post.html]
#2

Michael Flad

[GLOBAL: userInfoPane.html]
Michael Flad
  • Contributor

  • 145 posts
  • Corona SDK

In general, using spritesheets you greatly reduce your drawcalls which can dramatically improve your performance which, in most of the cases actually should, at worst, reduce the stress on your device and reduce the produced heat as your app might only need 8ms per frame, resulting in more idle time for your GPU/CPU (reducing energy consumption, i.e. created heat).

 

The only thing I could even remotely imagine is that, using spritesheets you know get much better framerates resulting in much more computation/rendering done which, in the end, might result in more generated heat.

 

Maybe you could give this a try and measure your framerate in both versions?


  • dodi_games likes this

[TOPIC: post.html]
#3

dodi_games

[GLOBAL: userInfoPane.html]
dodi_games
  • Contributor

  • 267 posts
  • Corona SDK

@Michael Flad

Thanks for your quick response. I thought that the heating of the devices was due to the global load of the assets through images sheets, it is as if my App had 18 high resolution images of 768x1024. You can tell me where to read to learn to verify the framerates?

[TOPIC: post.html]
#4

SGS

[GLOBAL: userInfoPane.html]
SGS
  • Corona Geek

  • 1,852 posts
  • Corona SDK

Use system.getTimer() in an enterFrame() listener and subtract the time of the last event from the current system.getTimer().  Lets call this value dT.  Your frames per second will be 1000/dT.

 

This will wildly fluctuate so store it for say 30 loops and average the value.  You can also loop to find the minimum value in the array and that will be your slowest frame

 

As @Michael says, imagesheets are much easier on GPU.  But realistically texture memory usage should not vary so massively between image sheet/individual images - unless you have a lot of images that just cross a power of 2 boundary and they are being scaled up.


  • dodi_games likes this

[TOPIC: post.html]
#5

Michael Flad

[GLOBAL: userInfoPane.html]
Michael Flad
  • Contributor

  • 145 posts
  • Corona SDK

For simple usage I just smooth the value in a simple way like

 

local FPS = {
    lastTime = system.getTimer(),
    frameTime = 0,
    fps = 0,
}
 
function FPS:enterFrame( event )
    local deltaTime = event.time-self.lastTime
    self.lastTime = event.time
 
    local curFps = 1000 / deltaTime
    self.fps = self.fps * 0.95 + curFps * 0.05
    print( "FPS: "..self.fps )
end
 
Runtime:addEventListener( "enterFrame", FPS )

  • dodi_games likes this

[TOPIC: post.html]
#6

dodi_games

[GLOBAL: userInfoPane.html]
dodi_games
  • Contributor

  • 267 posts
  • Corona SDK

@all

Im going to track the framerates. I let you know what I find.

Thanks!


[topic_controls]
[/topic_controls]