submit to reddit
Tweet
Follow ToxicBlob on Twitter
Technical

Not all PVRTC are created equal

PVRTC compression comparision (side by side)
PVRTexTool version 3.23 vs. Unity version 3.4.2. . . click to view comparison QuickTime

This post is of a technical nature. If you’re not a game developer, please do be patient. Sin or Win is coming, soon!

There are three options for textures when developing for iOS in Unity: True colour, 16-bit* and PVRTC compressed images. True colour & 16-bit images are great for image fidelity, but swallow lots of memory. On a limited platform like iOS one can’t have many of them without running into memory issues. So most developers crush their images into PVRTC which tends to have a fraction of the memory requirements. I have avoided using PVRTC because the results were horribly poor. However, this week I’ve been optimising Sin or Win and investigating my texture options led to this PVRTexTool discovery.

Typically, Unity’s built-in PVRTC compression results in unacceptably blurred and smudgy results. Then I stumbled across a reference in Unity’s Optimising iOS Graphics Performance documentation on PVRTexTool from Imagination Tech - creators of the PVRT format. Use another tool, Unity suggests, if your PVRTC is poor quality. Doing so result in the image above. Click on the image for a QuickTime comparison.

Bizarrely, the newly released Unity 3.4.2 comes with an old version of PVRTexTool** (version 3.11). I’ve filed a bug report with Unity, requesting for better compression to come with Unity 3.5 (or Unity 3.4.3!).

In the meantime, here’s how you take advantage of better compression today.

Install PVRTexTool from Imagination Tech:
  1. Download PVRTexTool from Imagination Tech. You’ll have to create a username and password to do so. Once that’s done, Mac users download the PVRTexTool file with the yellow folder icon
  2. Unarchive the file and you’ll get a PVRTexTool folder in your Downloads. Drag this to your Applications folder
  3. Documentation is in the “Documentation” folder
  4. Most interesting is the command line application PVRTexTool. It’s found at /Applications/PVRTexTool/PVRTexToolCL/MacOS_x86/PVRTexTool. There is a GUI version of the tool, but it has an annoying Windows interface and is more time consuming to use. The command line tool can be wrapped into your pipeline tools for seamless integration
Use PVRTexTool to convert an image:
  1. From the Terminal change to the folder where your image is. PVRTexTool takes images in BMP, TGA, JPG, PNG, GIF, DDS. I use PNG
  2. Run /Applications/PVRTexTool/PVRTexToolCL/MacOS_x86/PVRTexTool -fPVRTC4 -pvrtcbest -yflip 1 -square -iPICTURE.PNG replacing the green PICTURE.PNG with the name of your image. PVRTexTool will then take it’s time, but it’ll create PICTURE.PVR, a high quality PVRTC compressed image you can drag to Unity. Also, ensure that you use “-pvrtcbest” otherwise you’ll just create PVRTC images as poorly as Unity already does
I hope this helps fellow Unity users get more texture quality from their images. The only downside to this is that compression takes slightly longer. The resulting images look better and take up the same space as those converted with Unity. Hopefully Unity will add the ability to choose between Fast, Normal, High Quality and Best Quality PVRTC generation.


*Coming from film I was spoilt into thinking of 16-bits as 16-bits per colour channel. Really that’s known as 48-bit colour. 16-bit colour in Unity is a paltry 32,768 colours

**I couldn’t actually get PVRTexTool 3.11 to work, so definitely download the newest version from Imagination Tech
Comments

Publish Automator

DSC_3768 - Version 2

I’m back from sunny San Francisco after my first Unite conference. It was a wonderful trip. I visited old friends and met new ones. At the conference I gave the talk, “Artists as Programmers”, then helped out with the “Artist Discussion”. Lots of fun. I’m already looking forward to next years Unite.

During the talks I mentioned a tool I had written that speeds publishing assets to the Unity assets folder. It’s a python script I’ve written and embedded in an Automator task.

Here’s how I use it:

All my work-in-progress images, animations and meshes I keep organised in my Development folder (marked in grey below). As an example the background daytime & nighttime image is located at Sin or Win/Development/Environment/Artwork/Environment Art v019.psd. I tend to work at least double the desired size, and enjoy layers so this Photoshop image is 500+ megabytes. To export to Unity I save the image using Photoshop’s Save for Web interface, dumping the png to Sin or Win/Development/Environment/Publish/Environment Art v019.png.

I’ll work away in Photoshop updating several different images at a time. When it’s time to copy them all into Unity I’ll use my Publish Automator script. I select the updated images in the Publish folders and drag them all onto my publish tool in the Finder toolbar. My script then copies the files into the appropriate location in the Unity/Assets folder while also stripping their version number. This last bit is important. If the image retained it’s “v019” Unity would see it as a new image and I’d get a messy Unity/Assets folder as well as have to manually assign the image to existing materials. Working with the publish tool enables me to work outside the Unity/Assets folder with version history, and easily publish to the Unity/Assets folder with Unity updating automatically. The script also automatically creates any folders in the Unite/Assets folder that are needed.

It’s saved me a tonne of time by simplifying my workflow. Hopefully it’ll help your development pipeline.

Instructions for Installation
  1. Download, unzip and store where convenient
  2. Drag the icon to your Finder toolbar
  3. To change the Python script within the Automator action, right click on the Toxic Blob Publish Automator application and select “Show Package Contents”. Open the Contents folder. Then open document.wflow in your favourite text editor
  4. On line 74 is the variable “devPath” which is my “/Development” folder, and on line 75 is the variable “publishPath” which is my “/Unity/Assets” folder. Change both to suit your paths & save the file
  5. Drag any file(s) onto the tool and relax as it copies them into your Unity project. Note, I haven’t tested dragging folders onto the tool, and that may not work as you would expect, so stick to files
  6. If you find this tool useful, drop me an email or a tweet and let me know where you’re using it. Thanks!
Toxic Blob Publish Automator.zip (220 KB)

PublishTool
Comments