switch png to pvr with PVRTexTool in c++

This topic contains 9 replies, has 3 voices, and was last updated by  Simon 1 year ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #54291

    xiao
    Member

    Hi,
    I’m using PVRTexTool in C++ on macosx
    with ePVRTPF_PVRTCI_4bpp_RGBA, I got the PVR with black boundary
    with ePVRTPF_PVRTCII_4bpp, I got the PVR with Alpha from 0 to 17
    my code is as follows:

    {std::string testPath = "/Users/xiao/Documents/perforce/main_1.0_mac_2/PvZ2//tmpDist/all/atlases/sour";
        ImageLib::Image* image = ImageLib::GetImage(testPath);
        
        uint32* sourceBits = image->mBits;
        pvrtexture::PixelType powerVRLibraryTargetFormat(ePVRTPF_PVRTCII_4bpp);
        pvrtexture::CPVRTextureHeader pvrTextureHeader(pvrtexture::PixelType('b','g','r','a',8,8,8,8).PixelTypeID,
                                                       269,
                                                       512,
                                                       1,
                                                       1,
                                                       1,
                                                       1,
                                                       ePVRTCSpacelRGB,
                                                       ePVRTVarTypeUnsignedByteNorm,
                                                       false);
        pvrtexture::CPVRTexture texture(pvrTextureHeader, sourceBits);
        
        bool success = Transcode(texture, powerVRLibraryTargetFormat, ePVRTVarTypeUnsignedByteNorm, ePVRTCSpacelRGB, pvrtexture::ePVRTCBest);  // for test
        std::string testPVRImageOutput = testPath + ".pvr";
        
        success = texture.saveFile(testPVRImageOutput.c_str());}

    I’m looking forward to your help, Thank you!

    Attachments:
    You must be logged in to view attached files.
    #54296

    Lawrence
    Moderator

    Hi xiao,

    Which version of PVRTexTool are you using to get these two images? How are you displaying the results? Are you viewing them in PVRTexToolGUI?

    PVRTC1 textures have to be powers of two. 269×512 will therefore produce 512×512 textures.

    #54300

    xiao
    Member

    Hi,
    Thank you for you help. my version is 2016_R 1.2 and I viewed them in both PVRTexToolGUI and IOS devices.
    I know that PVRTC1 textures have to be powers of two, that’s why I’m trying PVRTC2 which supports NPOT.
    But neither of them made a nice texture. Please review my code in function Transcode, is any param wrong?
    Thank you again

    #54303

    Lawrence
    Moderator

    Thanks for the information.

    There is nothing wrong with your code. I’ve tested it with the 2016 r1.2 release of PVRTexTool on both Windows and OSX but cannot reproduce your texture. I end up with the attached.

    What platform are you targeting anyway? PVRTC2 is not exposed on IOS anyway, so sticking with PVRTC1 may be a necessity.

    Attachments:
    You must be logged in to view attached files.
    #54306

    xiao
    Member

    Thanks for your help. I produced the texture by c++ with PVRTexTool SDK. When using PVRTexTool GUI ,I can produce a texture as well as yours, but there are so many PNGs and I need to switch them automatically.

    PVRTC2 is not exposed on IOS? Where can I see this message?
    https://community.imgtec.com/forums/topic/which-devices-support-pvrtc2/
    what I see is “All PowerVR Series 5XT and Series6 GPUs are capable of fully supporting PVRTC2 texture decompression, including SGX543,SGX544 and SGX554, G6200 and G6400.”

    Meanwhile, is there anything I can do for the ePVRTPF_PVRTCI_4bpp_RGBA texture to make it better?
    Thank you very much.

    #54307

    Lawrence
    Moderator

    Hi xiao,

    Are you using the 2016 r1.2 version of PVRTexLib to match the GUI? Can you make sure that you aren’t using an older version of the library?

    That forum post is correct. Those GPUs support PVRTC 2, but the extension isn’t exposed on IOS.

    Regarding PVRTC 1, I cannot reproduce your compressed image either. Just compressing it at highest quality I get a far better image than you’re getting. To get the best possible image, call the Bleed function before Transcode:

    bool success = Bleed(texture);
    success &= Transcode(texture, powerVRLibraryTargetFormat, ePVRTVarTypeUnsignedByteNorm, ePVRTCSpacelRGB, pvrtexture::ePVRTCBest);

    This spills colour (RGB) into fully transparent areas to aid the compressor, resulting in a much better image. I’ve attached the result.

    I hope this helps.

    Attachments:
    You must be logged in to view attached files.
    1 user thanked author for this post.
    #54313

    xiao
    Member

    Hi,
    It’s so amazing that I get a far better texture than I was geting. The function Bleed works.Thanks for your patience.

    By the way, The function Bleed return false when I pass a texture with BGRA8888 format, do you know the reason?

    The texture with RGBA8888 format works well.

    Thank you very much, you helped me a lot

    1 user thanked author for this post.
    #54315

    Lawrence
    Moderator

    The Bleed function only works with RGBA, and not BGRA or any other channel order. You can easily convert the texture from whatever it is to RGBA8888 before calling the Bleed function by doing the following:

    bool success = Transcode(texture, pvrtexture::PixelType('r', 'g', 'b', 'a', 8, 8, 8, 8).PixelTypeID, ePVRTVarTypeUnsignedByteNorm, ePVRTCSpacelRGB);
    success &= Bleed(texture);
    success &= Transcode(texture, powerVRLibraryTargetFormat, ePVRTVarTypeUnsignedByteNorm, ePVRTCSpacelRGB, pvrtexture::ePVRTCBest);
    #54318

    xiao
    Member

    Thank you

    #54423

    Simon
    Moderator

    PVRTC2 is not exposed on IOS?

    I’m afraid so. Despite it being available in hardware (in some form) for around a decade it’s just not accessible. It confuses me too.

Viewing 10 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic.