I see TextureIO doesn't have a TextureProvider for Imagination Technologies' PVRTC texture format.
What would be the easiest way to use PVRTC textures in JOGL2? |
Administrator
|
On 10/14/2013 03:38 PM, asambol [via jogamp] wrote:
> I see TextureIO doesn't have a TextureProvider for Imagination Technologies' > PVRTC texture format. > > What would be the easiest way to use PVRTC textures in JOGL2? Hi Alan, since we do not need to decode the data (like w/ JPG, PNG, ..) one can simply read the binary data and push it as texture data using that PVRTC type enum .. If you like to add this type to TextureIO to easy loading the data you are more than welcome .. I will assist (pls use git). Hope this helps. Cheers, Sven signature.asc (911 bytes) Download Attachment |
What PVRTC type enum are you reffering to?
My approach was to create a new TextureProvider, lets say PVRTCTextureProvider, which would contain logic for creating TextureData. However, constructor for TextureData requires stuff like width, height etc which I can only obtain by decoding the file. |
Here's what I tried:
public class PVRTCTextureProvider implements TextureProvider { @Override public TextureData newTextureData(GLProfile glp, File file, int internalFormat, int pixelFormat, boolean mipmap, String fileSuffix) throws IOException { boolean compressed = true; mipmap = false; boolean mustFlipVertically = false; Flusher flusher = null; // internalFormat = 0x8C02; // GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG internalFormat = 0x9138; // GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG pixelFormat = GL.GL_RGBA; int pixelType = GL.GL_UNSIGNED_BYTE; int border = 0; int width = 512; int height = 512; if (!fileSuffix.equals("pvr")) { return null; } ByteBuffer buffer = getBytesFromFile(file); // file as bytes TextureData textureData = new TextureData(glp, internalFormat, width, height, border, pixelFormat, pixelType, mipmap, compressed, mustFlipVertically, buffer, flusher); return textureData; } ... } However, it doesn't work. I have tried all possible combinations for pixelType, pixelFormat and internalFormat. On non PowerVR hardware I get transparent object, on PowerVR hardware I get a black square. I guess the problem is that the PVRTC format is compressed 4bpp, and I'm using GL_UNSIGNED_BYTE. I also tried PVR RGBA8888 uncompressed format with no success. Any hints? |
Administrator
|
On 10/16/2013 03:04 PM, asambol [via jogamp] wrote:
> Here's what I tried: > > public class PVRTCTextureProvider implements TextureProvider { > > @Override > public TextureData newTextureData(GLProfile glp, File file, > int internalFormat, int pixelFormat, boolean mipmap, > String fileSuffix) throws IOException { > > boolean compressed = true; > mipmap = false; > boolean mustFlipVertically = false; > Flusher flusher = null; > // internalFormat = 0x8C02; // GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG > internalFormat = 0x9138; // GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG > pixelFormat = GL.GL_RGBA; > int pixelType = GL.GL_UNSIGNED_BYTE; > int border = 0; > int width = 512; > int height = 512; > > if (!fileSuffix.equals("pvr")) { > return null; > } > ByteBuffer buffer = getBytesFromFile(file); // file as bytes > TextureData textureData = new TextureData(glp, internalFormat, width, height, border, pixelFormat, pixelType, mipmap, compressed, mustFlipVertically, buffer, flusher); > return textureData; > } > ... > } > > > However, it doesn't work. I have tried all possible combinations for > pixelType, pixelFormat and internalFormat. > > On non PowerVR I get transparent object, on PowerVR hardware I get black square. > > I guess the problem is that the PVRTC format is compressed 4bpp, and I'm using > GL_UNSIGNED_BYTE. I also tried PVR RGBA8888 uncompressed format with no success. > Shouldn't there be a simple demo from them ? If you like to add a bug report for this one .. and attach a simple test application (or better unit test git pull req.) .. we can work on this .. > Any hints? Haven't dealed w/ this format yet. I agree .. might has something to do w/ the data format .. hmm ~Sven signature.asc (911 bytes) Download Attachment |
I managed to solve it. I made a mistake by loading the entire file into ByteBuffer, instead of omitting PVR header and metadata (according to Imagination Tech. specification).
The procedure is actually very similar to loading DDS images - only the header is different and internalFormat needs to be changed according to Khronos specification: - PVRTC2 4bpp: internalFormat = 0x8C02; // GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG - PVRTC 4bpp: internalFormat = 0x9138; // GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG BTW, PVR can actually contain DXT1-5 and many other compressed/uncompressed formats. |
Administrator
|
Good job. Where can I find this spec? Here?
http://www.khronos.org/registry/gles/extensions/IMG/IMG_texture_compression_pvrtc.txt
Julien Gouesse | Personal blog | Website
|
PVRTC1: http://www.khronos.org/registry/gles/extensions/IMG/IMG_texture_compression_pvrtc.txt
PVRTC2: http://www.khronos.org/registry/gles/extensions/IMG/IMG_texture_compression_pvrtc2.txt PVR file format specification can be downloaded here: http://www.imgtec.com/powervr/insider/powervr-sdk-docs.asp (I think you need to sign up as a developer and sign NDA). |
Free forum by Nabble | Edit this page |