iOS Client Examples

The RenderReduce framework is a compiled iOS binary framework along with examples that demonstrate proper usage. All of the example apps are included in a single github repository.

The examples in the SKRRExamples repository illustrate different issues related to use of textures in SpriteKit. While it is possible to run the examples in the simulator one must actually run on 64 bit hardware to see accurate performance results.

  1. SKMaxTextureLoad
  2. SKSwiftCompare
  3. WhackAMoleHD
  4. SpriteKitFireAnimation

SKMaxTextureLoad Examples :

The SKMaxTextureLoad example displays the largest possible texture with dimensions 4096x4096. This texture is the max size that can be loaded under iOS. This one texture consumes about 68 Megs of memory. A second app named SKMaxTextureLoadOpt implements the same functionality, but the texture is loaded via RenderReduce. Using RenderReduce to decompress and render at the same time requires only about 17.5 Megs of memory. Note that there is no drop in performance and even while resizing this texture renders at 60 FPS.

SKSwiftCompare Example : Visual compression comparison

This example app shows how easily RenderReduce can be incorporated into a Swift implementation. This example app also provides a quick way to visually compare image compression results on the actual device.

The app displays the same image but with different compression settings displayed at a 1 to 1 pixel ratio. The image on the left side is the original and the image on the right side is the same image but with lossy compression applied. The usefulness of this app is in testing different compression settings to ensure that lossy compression applied to the image does not degrade the visual fidelity of the image when displayed on the actual device. By default the image on the right half is limited to a 65536 total unique colors, this results in a compression ratio of about 0.45 which saves more than half the memory as compared to the lossless original. See Data compression basics for background info.

Note that one can also view the results of over-compression, as this example also includes an image reduced to just 256 total colors. Modify didMoveToView to enable loading of the over-compressed image and notice the color banding in the right image. A developer can easily swap out a new original image and compressed result to determine the visual quality of different compression settings for new images.

WhackAMoleHD Example :

This example project is based on a cute little WhackAMole 2d game at Ray Wenderlich tutorials. The little mole images were loaded over a high quality iPad background image extracted from a high definition render of Big Buck Bunny. This iPad only HD implementation for SpriteKit shows a extremely detailed background image with mole holes superimposed over the background.

This example shows how a high quality 1 to 1 ratio background can be imported into an iPad app without sacrificing a large amount of memory. Normally a 2048x1536 texture would consume about 20 Megs of memory. With RenderReduce, this texture can be reduced to about 13.5 Megs of memory without noticeable quality loss. This example app uses regular SpriteKit texture loading for the mole elements, the focus here is on the background image.

SpriteKitFireAnimation Example :

The fire animation example shows how RenderReduce can be used to implement a SpriteKit animation. This example works on either iPhone or iPad. A developer will need to run the example app on an actual 64 bit device to appreciate the animation quality.

An experienced developer will be familiar with the shocking amount of space required to hold this kind of uncompressed video data in memory. The default SpriteKit animation method would require about 286 Megs of memory to hold the 60 animation frames in this fire animation. With RenderReduce the total in memory size of the animation data is reduced down to about 130 Megs of memory. That is still quite a lot and this method may not be the best option for production code, but the point of this example is to demonstrate code that does thread safe loading in the background.

This example is complex because it makes use of a roughly 1000x1000 animation with a full alpha channel to support composition over the background scene. The input data is attached to the project as a series of large PNG images and the RenderReduce encoding process can take more than a few seconds to complete. This example shows using RenderReduce to implement an large animation that runs at 60 FPS.