I would like to ask a few question about texture encoding and loading pvr.ccz file in Android. I'm using Cocos2dx Game Engine.
I can't load pvr.ccz file with texture encoding format PVRTCv2 and PVRTCv4. But, I can load it with RGBA 8888, RGBA 4444, etc. I've checked cocos2dx source. It just doesn't allow Android to load with those two encoding format. I would like to know if there is any work-around to load for those two encoding format in Android.
I've changed the pvr.ccz file encoding to RGBA 8888. And it can be loaded in both iOS and Android. But, the problem is when the pvr.ccz file is larger than approximately 2.4 MB, Android can't load it again. In memory usage, it's telling me that the size of pvr.ccz file is even larger than 16 MB. Maybe it's because Android decompress pvr.ccz file. I would like to know if there any work-around for that memory issue in Android.
I'm using Samsung Galaxy Tab P7500 to test and I assume it use PowerVR GPU. It should be ok with PVRTCv2 or PVRTCv4. But, in the source of cocos2dx, it's not checking anything related to GPU. It just don't allow Android to load PVRTCv2 or PVRTCv4. Our Game is using too many Graphic, if we are using RGBA 8888, the size of the game would become around 40 MB while the size would be only 18 MB when we use PVRTCv2.
Any Suggestion would be Appreciate !! ..
Thanks !
Have you considered doing a fork of cocos2d and tuning it for your needs?
If you are targeting more Android devices I would go for ETC1 compression for opaque textures first, gives decent compression and would make your apk smaller. Check android.opengl.ETC1Util namespace for some utility code to load just one compressed image (you will need to load each mipmap level from a compressed file).
For non-opaque textures use vendor specific extensions. Check this: Android OpenGL Texture Compression
Related
I'm working through the openGL ES 2.0 guide, and I just stumbled on this note for the GenerateMipmap(target) command:
If the level zero array is stored in a compressed internal format, the error INVALID_OPERATION is generated.
The way I understand that is that there is no function to automatically generate mipmaps for compressed textures in openGL ES 2.0 - and everything else I've looked at seems to indicate that, even though I've never seen it concretely confirmed anywhere. I've seen that the Mali texture compression tool can automatically generate mipmaps - but that only works on Windows, Linux and OS X - and not on Android. I need my app to compress the textures and mipmap them (the idea is that a user can take an image and apply it as a texture - I've already taken care of the aspect that the texture has to have a widths and heights of 2^n and 2^m respectively). The ETC1Util takes care of compressing textures (although it only takes care of the ETC1 format, and I'm still looking for a solution for textures with an alpha channel - but that's a different question for a different day, if Google doesn't help me there).
My question is: how do you compress and mipmap textures - most importantly ETC1, but ideally also PVRTC, ATITC, S3TC and ETC2 - at runtime on Android?
There's nothing in OpenGL or OpenGLES for generating compressed textures.
Generally, creating compressed textures is slow, and people almost always generate them offline. For runtime generated textures, people usually keep them in basic formats like 8888, 565 or 4444 because the trade-off of compression-time vs rendering efficiency is just not worth it.
That said, it's possible to find open source code for generating most compressed formats, and there's nothing stopping you from plugging that code into your game code. For ETC1 there's this (github version). For S3TC (aka DXT) there's squish (or many others).
I would like to know what is the speed difference at rendering SDK side and NDK side with bigger SVG files.
I have tried with NDK here but doesn't support bigger SVG files.
Probably the best SDK parser -at least this is I am using is androidsvg
Does it worth the effort to get into Native side? - no heap limit, if the recursive calls are rewritten to iterative ones.
SDK depends on device: 1-12 sec rendering with a big SVG file ( 350kb ).
I don't know how is with NDK, but I took 2x phone with same Android OS and same svg.
Nexus One with 4.2.2 ( Cyanogen mode )
Thl w8s , aka Galaxy s4 Chinese clone:
I starting I have printed out the max available memory, with large heap enabled.
Than loaded the svg file from assets. An svg made by artists, has around 350kb the file, and the SVG dom object has aroung 7-8Mb in memory, so this is not a circle + 1 rectangle....
Than based on screen resolution need to render the svg to a square area.
The 480x800 to a 356x356 area.
The 1080x1920 phone to a bigger area, you can do the math, now I am lazy. Anyway, this need to fill a lot more pixel area.
I think the 400 milliseconds it is an acceptable result from him to make a logo / background. Not need to re-draw often, since isn't a game element.
For games: at first time loading transform from SVG to png all files and use the cached one.
It will take time, only the first time.
It will take space , user can clear it. - than re-make, if needed
I use the following code to create mipmaps in my android app
gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_GENERATE_MIPMAP, GL11.GL_TRUE);
It works with most of my .png files, but some of them aren't loaded properly (appear as blank white textures) unless I turn off mipmapping. This is on 128 X 128 textures that are all saved as .png in adobe photoshop v 12.0
The textures that work always seem to have a relatively larger file size than the ones that don't, so I'm wondering if it sometimes uses some newer compression that isn't supported by android, and if so how do I turn it off. This is very frustrating and any help would be very appreciated.
PS I'm using a motorola atrix to test the app
While developing an Android app what format of sound/image should i should be using so that i can control the overall size of the app after completion.
here is a link to all the media types supported by Android.
For sound I would probably use a low-bitrate .mp3 or a .midi and for images either a compressed .jpg or .gif
For supported media formats see this.
For images you'll probably end up with JPG or PNG (if you need transparency). You should also scrape the images to remove all unnecessary meta data etc. For linux, a nice tool for this is Trimage.
Take a look at Supported Media Formats.
My choice would be:
Images: go with JPG for compression or PNG for quality and transparency support.
Audio: go with MP3-VBR (variable bit rate) for compression and quality.
The size of your file will be greatly affected by compression level. At some point, if you compress too much you will see/hear artifacts. The acceptable level of compression is subjective and really depends on the input data (image or audio). You should be testing different levels of compression to see what works.
Im an openGL es newbie, and am trying to figure out how to lower texture usage in my app. Im aware of ETC1 and the various other compressed texture formats but am having difficulty figuring out how i can convert my JPGs to ETC1 while the app is loading. I found ETC1Util which can generate during runtime, but this wouldnt really be helpful since my textures will never change. I would also really like to keep my app using api level 7 (ETC1Util was introduced in 8)
ImageTec's PVRTexTool allows you to convert your JPEG to PVR files with the compression of your choice (PVRTC or ETC1 basically). The site is full of interesting things and code around textures (eg. it's easy to make a .pvr loader).
It's also not too hard to use the provided PVRTexLib to write an offline tool that can process your JPEG files and include the tool in your build process (say you still have png/jpeg files in your project for convenience and having rules in your makefiles to generate compressed .pvr texture at build time).
A few weeks ago I've started a small gdk-pixbuf loader using PVRTExLib, might help:
https://github.com/media-explorer/gdk-pixbuf-texture-tool